]> git.pld-linux.org Git - packages/kernel.git/blob - linux-2.6-xfs-cvs-20040102.patch
- [sparc32] grsec disabled.
[packages/kernel.git] / linux-2.6-xfs-cvs-20040102.patch
1 diff -urN linux.org/fs/xfs/linux/xfs_aops.c linux/fs/xfs/linux/xfs_aops.c
2 --- linux.org/fs/xfs/linux/xfs_aops.c   2003-12-31 05:48:20.000000000 +0100
3 +++ linux/fs/xfs/linux/xfs_aops.c       2004-01-02 04:21:43.000000000 +0100
4 @@ -51,10 +51,11 @@
5  #include "xfs_inode.h"
6  #include "xfs_error.h"
7  #include "xfs_rw.h"
8 +#include "xfs_iomap.h"
9  #include <linux/mpage.h>
10  
11  STATIC void convert_page(struct inode *, struct page *,
12 -                       page_buf_bmap_t *, void *, int, int);
13 +                       xfs_iomap_t *, void *, int, int);
14  
15  void
16  linvfs_unwritten_done(
17 @@ -85,11 +86,9 @@
18         vnode_t         *vp = XFS_BUF_FSPRIVATE(bp, vnode_t *);
19         int             error;
20  
21 -       if (atomic_read(&bp->pb_hold) < 1) 
22 -               BUG();
23 -
24 +       BUG_ON(atomic_read(&bp->pb_hold) < 1);
25         VOP_BMAP(vp, XFS_BUF_OFFSET(bp), XFS_BUF_SIZE(bp),
26 -                       BMAP_UNWRITTEN, NULL, NULL, error);
27 +                       BMAPI_UNWRITTEN, NULL, NULL, error);
28         XFS_BUF_SET_FSPRIVATE(bp, NULL);
29         XFS_BUF_CLR_IODONE_FUNC(bp);
30         XFS_BUF_UNDATAIO(bp);
31 @@ -117,7 +116,7 @@
32                 vnode_t *vp = LINVFS_GET_VP(inode);
33                 int     error;
34  
35 -               VOP_BMAP(vp, offset, size, BMAP_UNWRITTEN, NULL, NULL, error);
36 +               VOP_BMAP(vp, offset, size, BMAPI_UNWRITTEN, NULL, NULL, error);
37         }
38  }
39  
40 @@ -126,26 +125,26 @@
41         struct inode            *inode,
42         loff_t                  offset,
43         ssize_t                 count,
44 -       page_buf_bmap_t         *pbmapp,
45 +       xfs_iomap_t             *iomapp,
46         int                     flags)
47  {
48         vnode_t                 *vp = LINVFS_GET_VP(inode);
49 -       int                     error, nmaps = 1;
50 +       int                     error, niomaps = 1;
51  
52 -       if (((flags & (BMAP_DIRECT|BMAP_SYNC)) == BMAP_DIRECT) &&
53 +       if (((flags & (BMAPI_DIRECT|BMAPI_SYNC)) == BMAPI_DIRECT) &&
54             (offset >= i_size_read(inode)))
55                 count = max_t(ssize_t, count, XFS_WRITE_IO_LOG);
56  retry:
57 -       VOP_BMAP(vp, offset, count, flags, pbmapp, &nmaps, error);
58 +       VOP_BMAP(vp, offset, count, flags, iomapp, &niomaps, error);
59         if ((error == EAGAIN) || (error == EIO))
60                 return -error;
61 -       if (unlikely((flags & (BMAP_WRITE|BMAP_DIRECT)) ==
62 -                                       (BMAP_WRITE|BMAP_DIRECT) && nmaps &&
63 -                                       (pbmapp->pbm_flags & PBMF_DELAY))) {
64 -               flags = BMAP_ALLOCATE;
65 +       if (unlikely((flags & (BMAPI_WRITE|BMAPI_DIRECT)) ==
66 +                                       (BMAPI_WRITE|BMAPI_DIRECT) && niomaps &&
67 +                                       (iomapp->iomap_flags & IOMAP_DELAY))) {
68 +               flags = BMAPI_ALLOCATE;
69                 goto retry;
70         }
71 -       if (flags & (BMAP_WRITE|BMAP_ALLOCATE)) {
72 +       if (flags & (BMAPI_WRITE|BMAPI_ALLOCATE)) {
73                 VMODIFY(vp);
74         }
75         return -error;
76 @@ -156,10 +155,10 @@
77   * Finds the corresponding mapping in block @map array of the
78   * given @offset within a @page.
79   */
80 -STATIC page_buf_bmap_t *
81 +STATIC xfs_iomap_t *
82  match_offset_to_mapping(
83         struct page             *page,
84 -       page_buf_bmap_t         *map,
85 +       xfs_iomap_t             *iomapp,
86         unsigned long           offset)
87  {
88         loff_t                  full_offset;    /* offset from start of file */
89 @@ -170,10 +169,10 @@
90         full_offset <<= PAGE_CACHE_SHIFT;       /* offset from file start */
91         full_offset += offset;                  /* offset from page start */
92  
93 -       if (full_offset < map->pbm_offset)
94 +       if (full_offset < iomapp->iomap_offset)
95                 return NULL;
96 -       if (map->pbm_offset + map->pbm_bsize > full_offset)
97 -               return map;
98 +       if (iomapp->iomap_offset + iomapp->iomap_bsize > full_offset)
99 +               return iomapp;
100         return NULL;
101  }
102  
103 @@ -183,30 +182,30 @@
104         struct buffer_head      *bh,
105         unsigned long           offset,
106         int                     block_bits,
107 -       page_buf_bmap_t         *mp)
108 +       xfs_iomap_t             *iomapp)
109  {
110 -       page_buf_daddr_t        bn;
111 +       xfs_daddr_t             bn;
112         loff_t                  delta;
113         int                     sector_shift;
114  
115 -       ASSERT(!(mp->pbm_flags & PBMF_HOLE));
116 -       ASSERT(!(mp->pbm_flags & PBMF_DELAY));
117 -       ASSERT(mp->pbm_bn != PAGE_BUF_DADDR_NULL);
118 +       ASSERT(!(iomapp->iomap_flags & IOMAP_HOLE));
119 +       ASSERT(!(iomapp->iomap_flags & IOMAP_DELAY));
120 +       ASSERT(iomapp->iomap_bn != IOMAP_DADDR_NULL);
121  
122         delta = page->index;
123         delta <<= PAGE_CACHE_SHIFT;
124         delta += offset;
125 -       delta -= mp->pbm_offset;
126 +       delta -= iomapp->iomap_offset;
127         delta >>= block_bits;
128  
129         sector_shift = block_bits - BBSHIFT;
130 -       bn = mp->pbm_bn >> sector_shift;
131 +       bn = iomapp->iomap_bn >> sector_shift;
132         bn += delta;
133 -       ASSERT((bn << sector_shift) >= mp->pbm_bn);
134 +       ASSERT((bn << sector_shift) >= iomapp->iomap_bn);
135  
136         lock_buffer(bh);
137         bh->b_blocknr = bn;
138 -       bh->b_bdev = mp->pbm_target->pbr_bdev;
139 +       bh->b_bdev = iomapp->iomap_target->pbr_bdev;
140         set_buffer_mapped(bh);
141         clear_buffer_delay(bh);
142  }
143 @@ -222,7 +221,7 @@
144  probe_unwritten_page(
145         struct address_space    *mapping,
146         unsigned long           index,
147 -       page_buf_bmap_t         *mp,
148 +       xfs_iomap_t             *iomapp,
149         page_buf_t              *pb,
150         unsigned long           max_offset,
151         unsigned long           *fsbs,
152 @@ -245,11 +244,11 @@
153                 do {
154                         if (!buffer_unwritten(bh))
155                                 break;
156 -                       if (!match_offset_to_mapping(page, mp, p_offset))
157 +                       if (!match_offset_to_mapping(page, iomapp, p_offset))
158                                 break;
159                         if (p_offset >= max_offset)
160                                 break;
161 -                       map_buffer_at_offset(page, bh, p_offset, bbits, mp);
162 +                       map_buffer_at_offset(page, bh, p_offset, bbits, iomapp);
163                         set_buffer_unwritten_io(bh);
164                         bh->b_private = pb;
165                         p_offset += bh->b_size;
166 @@ -394,11 +393,12 @@
167         struct buffer_head      *curr,
168         unsigned long           p_offset,
169         int                     block_bits,
170 -       page_buf_bmap_t         *mp,
171 +       xfs_iomap_t             *iomapp,
172 +       int                     startio,
173         int                     all_bh)
174  {
175         struct buffer_head      *bh = curr;
176 -       page_buf_bmap_t         *tmp;
177 +       xfs_iomap_t             *tmp;
178         page_buf_t              *pb;
179         loff_t                  offset, size;
180         unsigned long           nblocks = 0;
181 @@ -407,8 +407,8 @@
182         offset <<= PAGE_CACHE_SHIFT;
183         offset += p_offset;
184  
185 -       pb = pagebuf_lookup(mp->pbm_target,
186 -                           mp->pbm_offset, mp->pbm_bsize, 0);
187 +       pb = pagebuf_lookup(iomapp->iomap_target,
188 +                           iomapp->iomap_offset, iomapp->iomap_bsize, 0);
189         if (!pb)
190                 return -EAGAIN;
191  
192 @@ -433,10 +433,10 @@
193         do {
194                 if (!buffer_unwritten(bh))
195                         break;
196 -               tmp = match_offset_to_mapping(start_page, mp, p_offset);
197 +               tmp = match_offset_to_mapping(start_page, iomapp, p_offset);
198                 if (!tmp)
199                         break;
200 -               map_buffer_at_offset(start_page, bh, p_offset, block_bits, mp);
201 +               map_buffer_at_offset(start_page, bh, p_offset, block_bits, iomapp);
202                 set_buffer_unwritten_io(bh);
203                 bh->b_private = pb;
204                 p_offset += bh->b_size;
205 @@ -444,8 +444,8 @@
206         } while ((bh = bh->b_this_page) != head);
207  
208         if (unlikely(nblocks == 0)) {
209 -               printk("XFS: bad unwritten extent map: bh=0x%p, mp=0x%p\n",
210 -                       curr, mp);
211 +               printk("XFS: bad unwritten extent map: bh=0x%p, iomapp=0x%p\n",
212 +                      curr, iomapp);
213                 BUG();
214         }
215  
216 @@ -461,26 +461,26 @@
217                 struct page             *page;
218  
219                 tlast = i_size_read(inode) >> PAGE_CACHE_SHIFT;
220 -               tloff = (mp->pbm_offset + mp->pbm_bsize) >> PAGE_CACHE_SHIFT;
221 +               tloff = (iomapp->iomap_offset + iomapp->iomap_bsize) >> PAGE_CACHE_SHIFT;
222                 tloff = min(tlast, tloff);
223                 for (tindex = start_page->index + 1; tindex < tloff; tindex++) {
224 -                       page = probe_unwritten_page(mapping, tindex, mp, pb,
225 +                       page = probe_unwritten_page(mapping, tindex, iomapp, pb,
226                                                 PAGE_CACHE_SIZE, &bs, bbits);
227                         if (!page)
228                                 break;
229                         nblocks += bs;
230                         atomic_add(bs, &pb->pb_io_remaining);
231 -                       convert_page(inode, page, mp, pb, 1, all_bh);
232 +                       convert_page(inode, page, iomapp, pb, startio, all_bh);
233                 }
234  
235                 if (tindex == tlast &&
236                     (tloff = (i_size_read(inode) & (PAGE_CACHE_SIZE - 1)))) {
237 -                       page = probe_unwritten_page(mapping, tindex, mp, pb,
238 +                       page = probe_unwritten_page(mapping, tindex, iomapp, pb,
239                                                         tloff, &bs, bbits);
240                         if (page) {
241                                 nblocks += bs;
242                                 atomic_add(bs, &pb->pb_io_remaining);
243 -                               convert_page(inode, page, mp, pb, 1, all_bh);
244 +                               convert_page(inode, page, iomapp, pb, startio, all_bh);
245                         }
246                 }
247         }
248 @@ -542,13 +542,13 @@
249  convert_page(
250         struct inode            *inode,
251         struct page             *page,
252 -       page_buf_bmap_t         *maps,
253 +       xfs_iomap_t             *iomapp,
254         void                    *private,
255         int                     startio,
256         int                     all_bh)
257  {
258         struct buffer_head      *bh_arr[MAX_BUF_PER_PAGE], *bh, *head;
259 -       page_buf_bmap_t         *mp = maps, *tmp;
260 +       xfs_iomap_t             *mp = iomapp, *tmp;
261         unsigned long           end, offset, end_index;
262         int                     i = 0, index = 0;
263         int                     bbits = inode->i_blkbits;
264 @@ -575,17 +575,17 @@
265                 tmp = match_offset_to_mapping(page, mp, offset);
266                 if (!tmp)
267                         continue;
268 -               ASSERT(!(tmp->pbm_flags & PBMF_HOLE));
269 -               ASSERT(!(tmp->pbm_flags & PBMF_DELAY));
270 +               ASSERT(!(tmp->iomap_flags & IOMAP_HOLE));
271 +               ASSERT(!(tmp->iomap_flags & IOMAP_DELAY));
272  
273                 /* If this is a new unwritten extent buffer (i.e. one
274                  * that we haven't passed in private data for, we must
275                  * now map this buffer too.
276                  */
277                 if (buffer_unwritten(bh) && !bh->b_end_io) {
278 -                       ASSERT(tmp->pbm_flags & PBMF_UNWRITTEN);
279 +                       ASSERT(tmp->iomap_flags & IOMAP_UNWRITTEN);
280                         map_unwritten(inode, page, head, bh,
281 -                                               offset, bbits, tmp, all_bh);
282 +                                       offset, bbits, tmp, startio, all_bh);
283                 } else if (! (buffer_unwritten(bh) && buffer_locked(bh))) {
284                         map_buffer_at_offset(page, bh, offset, bbits, tmp);
285                         if (buffer_unwritten(bh)) {
286 @@ -618,19 +618,19 @@
287  cluster_write(
288         struct inode            *inode,
289         unsigned long           tindex,
290 -       page_buf_bmap_t         *mp,
291 +       xfs_iomap_t             *iomapp,
292         int                     startio,
293         int                     all_bh)
294  {
295         unsigned long           tlast;
296         struct page             *page;
297  
298 -       tlast = (mp->pbm_offset + mp->pbm_bsize) >> PAGE_CACHE_SHIFT;
299 +       tlast = (iomapp->iomap_offset + iomapp->iomap_bsize) >> PAGE_CACHE_SHIFT;
300         for (; tindex < tlast; tindex++) {
301                 page = probe_delalloc_page(inode, tindex);
302                 if (!page)
303                         break;
304 -               convert_page(inode, page, mp, NULL, startio, all_bh);
305 +               convert_page(inode, page, iomapp, NULL, startio, all_bh);
306         }
307  }
308  
309 @@ -661,20 +661,21 @@
310         int             unmapped) /* also implies page uptodate */
311  {
312         struct buffer_head      *bh_arr[MAX_BUF_PER_PAGE], *bh, *head;
313 -       page_buf_bmap_t         *mp, map;
314 +       xfs_iomap_t             *iomp, iomap;
315         unsigned long           p_offset = 0, end_index;
316         loff_t                  offset, end_offset;
317         int                     len, err, i, cnt = 0, uptodate = 1;
318 -       int                     flags = startio ? 0 : BMAP_TRYLOCK;
319 +       int                     flags = startio ? 0 : BMAPI_TRYLOCK;
320         int                     page_dirty = 1;
321  
322  
323         /* Are we off the end of the file ? */
324         end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT;
325         if (page->index >= end_index) {
326 -               unsigned remaining = i_size_read(inode) & (PAGE_CACHE_SIZE-1);
327 -               if ((page->index >= end_index+1) || !remaining) {
328 -                       return -EIO;
329 +               if ((page->index >= end_index + 1) ||
330 +                   !(i_size_read(inode) & (PAGE_CACHE_SIZE - 1))) {
331 +                       err = -EIO;
332 +                       goto error;
333                 }
334         }
335  
336 @@ -684,16 +685,19 @@
337                 end_offset = i_size_read(inode);
338  
339         bh = head = page_buffers(page);
340 -       mp = NULL;
341 +       iomp = NULL;
342  
343         len = bh->b_size;
344         do {
345 -               if (!(PageUptodate(page) || buffer_uptodate(bh)) && !startio) {
346 -                       goto next_bh;
347 -               }
348 +               if (offset >= end_offset)
349 +                       break;
350 +               if (!buffer_uptodate(bh))
351 +                       uptodate = 0;
352 +               if (!(PageUptodate(page) || buffer_uptodate(bh)) && !startio)
353 +                       continue;
354  
355 -               if (mp) {
356 -                       mp = match_offset_to_mapping(page, &map, p_offset);
357 +               if (iomp) {
358 +                       iomp = match_offset_to_mapping(page, &iomap, p_offset);
359                 }
360  
361                 /*
362 @@ -701,21 +705,21 @@
363                  * extent state conversion transaction on completion.
364                  */
365                 if (buffer_unwritten(bh)) {
366 -                       if (!mp) {
367 -                               err = map_blocks(inode, offset, len, &map,
368 -                                               BMAP_READ|BMAP_IGNSTATE);
369 +                       if (!iomp) {
370 +                               err = map_blocks(inode, offset, len, &iomap,
371 +                                               BMAPI_READ|BMAPI_IGNSTATE);
372                                 if (err) {
373                                         goto error;
374                                 }
375 -                               mp = match_offset_to_mapping(page, &map,
376 +                               iomp = match_offset_to_mapping(page, &iomap,
377                                                                 p_offset);
378                         }
379 -                       if (mp) {
380 +                       if (iomp) {
381                                 if (!bh->b_end_io) {
382                                         err = map_unwritten(inode, page,
383                                                         head, bh, p_offset,
384 -                                                       inode->i_blkbits,
385 -                                                       mp, unmapped);
386 +                                                       inode->i_blkbits, iomp,
387 +                                                       startio, unmapped);
388                                         if (err) {
389                                                 goto error;
390                                         }
391 @@ -734,18 +738,18 @@
392                  * We can return EAGAIN here in the release page case.
393                  */
394                 } else if (buffer_delay(bh)) {
395 -                       if (!mp) {
396 -                               err = map_blocks(inode, offset, len, &map,
397 -                                       BMAP_ALLOCATE | flags);
398 +                       if (!iomp) {
399 +                               err = map_blocks(inode, offset, len, &iomap,
400 +                                       BMAPI_ALLOCATE | flags);
401                                 if (err) {
402                                         goto error;
403                                 }
404 -                               mp = match_offset_to_mapping(page, &map,
405 +                               iomp = match_offset_to_mapping(page, &iomap,
406                                                                 p_offset);
407                         }
408 -                       if (mp) {
409 +                       if (iomp) {
410                                 map_buffer_at_offset(page, bh, p_offset,
411 -                                       inode->i_blkbits, mp);
412 +                                       inode->i_blkbits, iomp);
413                                 if (startio) {
414                                         bh_arr[cnt++] = bh;
415                                 } else {
416 @@ -766,22 +770,22 @@
417                                  * was found, and we are in a path where we
418                                  * need to write the whole page out.
419                                  */
420 -                               if (!mp) {
421 +                               if (!iomp) {
422                                         size = probe_unmapped_cluster(
423                                                         inode, page, bh, head);
424                                         err = map_blocks(inode, offset,
425 -                                               size, &map,
426 -                                               BMAP_WRITE | BMAP_MMAP);
427 +                                               size, &iomap,
428 +                                               BMAPI_WRITE | BMAPI_MMAP);
429                                         if (err) {
430                                                 goto error;
431                                         }
432 -                                       mp = match_offset_to_mapping(page, &map,
433 +                                       iomp = match_offset_to_mapping(page, &iomap,
434                                                                      p_offset);
435                                 }
436 -                               if (mp) {
437 +                               if (iomp) {
438                                         map_buffer_at_offset(page,
439                                                         bh, p_offset,
440 -                                                       inode->i_blkbits, mp);
441 +                                                       inode->i_blkbits, iomp);
442                                         if (startio) {
443                                                 bh_arr[cnt++] = bh;
444                                         } else {
445 @@ -799,14 +803,8 @@
446                                 }
447                         }
448                 }
449 -
450 -next_bh:
451 -               if (!buffer_uptodate(bh))
452 -                       uptodate = 0;
453 -               offset += len;
454 -               p_offset += len;
455 -               bh = bh->b_this_page;
456 -       } while (offset < end_offset);
457 +       } while (offset += len, p_offset += len,
458 +               ((bh = bh->b_this_page) != head));
459  
460         if (uptodate && bh == head)
461                 SetPageUptodate(page);
462 @@ -814,8 +812,8 @@
463         if (startio)
464                 submit_page(page, bh_arr, cnt);
465  
466 -       if (mp)
467 -               cluster_write(inode, page->index + 1, mp, startio, unmapped);
468 +       if (iomp)
469 +               cluster_write(inode, page->index + 1, iomp, startio, unmapped);
470  
471         return page_dirty;
472  
473 @@ -849,7 +847,7 @@
474         bmapi_flags_t           flags)
475  {
476         vnode_t                 *vp = LINVFS_GET_VP(inode);
477 -       page_buf_bmap_t         pbmap;
478 +       xfs_iomap_t             iomap;
479         int                     retpbbm = 1;
480         int                     error;
481         ssize_t                 size;
482 @@ -866,32 +864,32 @@
483                 size = 1 << inode->i_blkbits;
484  
485         VOP_BMAP(vp, offset, size,
486 -               create ? flags : BMAP_READ, &pbmap, &retpbbm, error);
487 +               create ? flags : BMAPI_READ, &iomap, &retpbbm, error);
488         if (error)
489                 return -error;
490  
491         if (retpbbm == 0)
492                 return 0;
493  
494 -       if (pbmap.pbm_bn != PAGE_BUF_DADDR_NULL) {
495 -               page_buf_daddr_t        bn;
496 +       if (iomap.iomap_bn != IOMAP_DADDR_NULL) {
497 +               xfs_daddr_t             bn;
498                 loff_t                  delta;
499  
500                 /* For unwritten extents do not report a disk address on
501                  * the read case.
502                  */
503 -               if (create || ((pbmap.pbm_flags & PBMF_UNWRITTEN) == 0)) {
504 -                       delta = offset - pbmap.pbm_offset;
505 +               if (create || ((iomap.iomap_flags & IOMAP_UNWRITTEN) == 0)) {
506 +                       delta = offset - iomap.iomap_offset;
507                         delta >>= inode->i_blkbits;
508  
509 -                       bn = pbmap.pbm_bn >> (inode->i_blkbits - BBSHIFT);
510 +                       bn = iomap.iomap_bn >> (inode->i_blkbits - BBSHIFT);
511                         bn += delta;
512  
513                         bh_result->b_blocknr = bn;
514 -                       bh_result->b_bdev = pbmap.pbm_target->pbr_bdev;
515 +                       bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
516                         set_buffer_mapped(bh_result);
517                 }
518 -               if (pbmap.pbm_flags & PBMF_UNWRITTEN) {
519 +               if (iomap.iomap_flags & IOMAP_UNWRITTEN) {
520                         if (create) {
521                                 if (direct)
522                                         bh_result->b_private = inode;
523 @@ -902,29 +900,32 @@
524                 }
525         }
526  
527 +       /* If this is a realtime file, data might be on a new device */
528 +       bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
529 +
530         /* If we previously allocated a block out beyond eof and
531          * we are now coming back to use it then we will need to
532          * flag it as new even if it has a disk address.
533          */
534         if (create &&
535             ((!buffer_mapped(bh_result) && !buffer_uptodate(bh_result)) ||
536 -            (offset >= i_size_read(inode)) || (pbmap.pbm_flags & PBMF_NEW))) {
537 +            (offset >= i_size_read(inode)) || (iomap.iomap_flags & IOMAP_NEW))) {
538                 set_buffer_new(bh_result);
539         }
540  
541 -       if (pbmap.pbm_flags & PBMF_DELAY) {
542 +       if (iomap.iomap_flags & IOMAP_DELAY) {
543                 if (unlikely(direct))
544                         BUG();
545                 if (create) {
546                         set_buffer_mapped(bh_result);
547                         set_buffer_uptodate(bh_result);
548                 }
549 -               bh_result->b_bdev = pbmap.pbm_target->pbr_bdev;
550 +               bh_result->b_bdev = iomap.iomap_target->pbr_bdev;
551                 set_buffer_delay(bh_result);
552         }
553  
554         if (blocks) {
555 -               size = (pbmap.pbm_bsize - pbmap.pbm_delta); 
556 +               size = (iomap.iomap_bsize - iomap.iomap_delta); 
557                 bh_result->b_size = min_t(ssize_t, size, blocks << inode->i_blkbits);
558         }
559  
560 @@ -939,7 +940,7 @@
561         int                     create)
562  {
563         return linvfs_get_block_core(inode, iblock, 0, bh_result,
564 -                                       create, 0, BMAP_WRITE);
565 +                                       create, 0, BMAPI_WRITE);
566  }
567  
568  STATIC int
569 @@ -950,7 +951,7 @@
570         int                     create)
571  {
572         return linvfs_get_block_core(inode, iblock, 0, bh_result,
573 -                                       create, 0, BMAP_SYNC|BMAP_WRITE);
574 +                                       create, 0, BMAPI_SYNC|BMAPI_WRITE);
575  }
576  
577  STATIC int
578 @@ -962,7 +963,7 @@
579         int                     create)
580  {
581         return linvfs_get_block_core(inode, iblock, max_blocks, bh_result,
582 -                                       create, 1, BMAP_WRITE|BMAP_DIRECT);
583 +                                       create, 1, BMAPI_WRITE|BMAPI_DIRECT);
584  }
585  
586  STATIC int
587 @@ -976,15 +977,15 @@
588         struct file     *file = iocb->ki_filp;
589         struct inode    *inode = file->f_dentry->d_inode->i_mapping->host;
590         vnode_t         *vp = LINVFS_GET_VP(inode);
591 -       page_buf_bmap_t pbmap;
592 +       xfs_iomap_t     iomap;
593         int             maps = 1;
594         int             error;
595  
596 -       VOP_BMAP(vp, offset, 0, BMAP_DEVICE, &pbmap, &maps, error);
597 +       VOP_BMAP(vp, offset, 0, BMAPI_DEVICE, &iomap, &maps, error);
598         if (error)
599                 return -error;
600  
601 -        return blockdev_direct_IO(rw, iocb, inode, pbmap.pbm_target->pbr_bdev,
602 +       return blockdev_direct_IO(rw, iocb, inode, iomap.iomap_target->pbr_bdev,
603                 iov, offset, nr_segs,
604                 linvfs_get_blocks_direct,
605                 linvfs_unwritten_convert_direct);
606 diff -urN linux.org/fs/xfs/linux/xfs_globals.c linux/fs/xfs/linux/xfs_globals.c
607 --- linux.org/fs/xfs/linux/xfs_globals.c        2003-12-31 05:47:44.000000000 +0100
608 +++ linux/fs/xfs/linux/xfs_globals.c    2004-01-02 04:21:43.000000000 +0100
609 @@ -36,9 +36,57 @@
610   */
611  
612  #include "xfs.h"
613 +
614 +#include "xfs_fs.h"
615 +#include "xfs_buf.h"
616 +#include "xfs_inum.h"
617 +#include "xfs_log.h"
618 +#include "xfs_clnt.h"
619 +#include "xfs_trans.h"
620 +#include "xfs_sb.h"
621 +#include "xfs_ag.h"
622 +#include "xfs_dir.h"
623 +#include "xfs_dir2.h"
624 +#include "xfs_imap.h"
625 +#include "xfs_alloc.h"
626 +#include "xfs_dmapi.h"
627 +#include "xfs_quota.h"
628 +#include "xfs_mount.h"
629 +#include "xfs_alloc_btree.h"
630  #include "xfs_bmap_btree.h"
631 +#include "xfs_ialloc_btree.h"
632 +#include "xfs_btree.h"
633 +#include "xfs_ialloc.h"
634 +#include "xfs_attr_sf.h"
635 +#include "xfs_dir_sf.h"
636 +#include "xfs_dir2_sf.h"
637 +#include "xfs_dinode.h"
638 +#include "xfs_inode.h"
639 +#include "xfs_bmap.h"
640  #include "xfs_bit.h"
641 +#include "xfs_rtalloc.h"
642 +#include "xfs_error.h"
643 +#include "xfs_itable.h"
644  #include "xfs_rw.h"
645 +#include "xfs_da_btree.h"
646 +#include "xfs_dir_leaf.h"
647 +#include "xfs_dir2_data.h"
648 +#include "xfs_dir2_leaf.h"
649 +#include "xfs_dir2_block.h"
650 +#include "xfs_dir2_node.h"
651 +#include "xfs_dir2_trace.h"
652 +#include "xfs_acl.h"
653 +#include "xfs_cap.h"
654 +#include "xfs_mac.h"
655 +#include "xfs_attr.h"
656 +#include "xfs_attr_leaf.h"
657 +#include "xfs_inode_item.h"
658 +#include "xfs_buf_item.h"
659 +#include "xfs_extfree_item.h"
660 +#include "xfs_log_priv.h"
661 +#include "xfs_trans_priv.h"
662 +#include "xfs_trans_space.h"
663 +#include "xfs_utils.h"
664  
665  /*
666   * System memory size - used to scale certain data structures in XFS.
667 @@ -69,10 +117,34 @@
668   */
669  cred_t sys_cred_val, *sys_cred = &sys_cred_val;
670  
671 -/* Export XFS symbols used by xfsidbg */
672 +/*
673 + * Export symbols used for XFS debugging
674 + */
675  EXPORT_SYMBOL(xfs_next_bit);
676  EXPORT_SYMBOL(xfs_contig_bits);
677  EXPORT_SYMBOL(xfs_bmbt_get_all);
678  #if ARCH_CONVERT != ARCH_NOCONVERT
679  EXPORT_SYMBOL(xfs_bmbt_disk_get_all);
680  #endif
681 +
682 +/*
683 + * Export symbols used for XFS tracing
684 + */
685 +#ifdef XFS_ALLOC_TRACE
686 +EXPORT_SYMBOL(xfs_alloc_trace_buf);
687 +#endif
688 +#ifdef XFS_BMAP_TRACE
689 +EXPORT_SYMBOL(xfs_bmap_trace_buf);
690 +#endif
691 +#ifdef XFS_BMBT_TRACE
692 +EXPORT_SYMBOL(xfs_bmbt_trace_buf);
693 +#endif
694 +#ifdef XFS_ATTR_TRACE
695 +EXPORT_SYMBOL(xfs_attr_trace_buf);
696 +#endif  
697 +#ifdef XFS_DIR2_TRACE
698 +EXPORT_SYMBOL(xfs_dir2_trace_buf);
699 +#endif   
700 +#ifdef XFS_DIR_TRACE
701 +EXPORT_SYMBOL(xfs_dir_trace_buf);
702 +#endif
703 diff -urN linux.org/fs/xfs/linux/xfs_ioctl.c linux/fs/xfs/linux/xfs_ioctl.c
704 --- linux.org/fs/xfs/linux/xfs_ioctl.c  2003-12-31 05:48:05.000000000 +0100
705 +++ linux/fs/xfs/linux/xfs_ioctl.c      2004-01-02 04:21:43.000000000 +0100
706 @@ -943,7 +943,7 @@
707                                         bulkreq.ubuffer, &done);
708                 } else {
709                         error = xfs_bulkstat(mp, NULL, &inlast, &count,
710 -                               (bulkstat_one_pf)xfs_bulkstat_one,
711 +                               (bulkstat_one_pf)xfs_bulkstat_one, NULL,
712                                 sizeof(xfs_bstat_t), bulkreq.ubuffer,
713                                 BULKSTAT_FG_QUICK, &done);
714                 }
715 diff -urN linux.org/fs/xfs/linux/xfs_iomap.c linux/fs/xfs/linux/xfs_iomap.c
716 --- linux.org/fs/xfs/linux/xfs_iomap.c  2003-12-31 05:47:27.000000000 +0100
717 +++ linux/fs/xfs/linux/xfs_iomap.c      2004-01-02 04:21:43.000000000 +0100
718 @@ -67,6 +67,7 @@
719  #include "xfs_buf_item.h"
720  #include "xfs_trans_space.h"
721  #include "xfs_utils.h"
722 +#include "xfs_iomap.h"
723  
724  #define XFS_WRITEIO_ALIGN(mp,off)      (((off) >> mp->m_writeio_log) \
725                                                 << mp->m_writeio_log)
726 @@ -74,14 +75,14 @@
727  #define XFS_WRITE_IMAPS                XFS_BMAP_MAX_NMAP
728  
729  STATIC int
730 -_xfs_imap_to_bmap(
731 +xfs_imap_to_bmap(
732         xfs_iocore_t    *io,
733         xfs_off_t       offset,
734 -       int             new,
735         xfs_bmbt_irec_t *imap,
736 -       page_buf_bmap_t *pbmapp,
737 +       xfs_iomap_t     *iomapp,
738         int             imaps,                  /* Number of imap entries */
739 -       int             pbmaps)                 /* Number of pbmap entries */
740 +       int             iomaps,                 /* Number of iomap entries */
741 +       int             flags)
742  {
743         xfs_mount_t     *mp;
744         xfs_fsize_t     nisize;
745 @@ -93,35 +94,32 @@
746         if (io->io_new_size > nisize)
747                 nisize = io->io_new_size;
748  
749 -       for (pbm = 0; imaps && pbm < pbmaps; imaps--, pbmapp++, imap++, pbm++) {
750 -               pbmapp->pbm_target = io->io_flags & XFS_IOCORE_RT ?
751 +       for (pbm = 0; imaps && pbm < iomaps; imaps--, iomapp++, imap++, pbm++) {
752 +               iomapp->iomap_target = io->io_flags & XFS_IOCORE_RT ?
753                         mp->m_rtdev_targp : mp->m_ddev_targp;
754 -               pbmapp->pbm_offset = XFS_FSB_TO_B(mp, imap->br_startoff);
755 -               pbmapp->pbm_delta = offset - pbmapp->pbm_offset;
756 -               pbmapp->pbm_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount);
757 -               pbmapp->pbm_flags = 0;
758 +               iomapp->iomap_offset = XFS_FSB_TO_B(mp, imap->br_startoff);
759 +               iomapp->iomap_delta = offset - iomapp->iomap_offset;
760 +               iomapp->iomap_bsize = XFS_FSB_TO_B(mp, imap->br_blockcount);
761 +               iomapp->iomap_flags = flags;
762  
763                 start_block = imap->br_startblock;
764                 if (start_block == HOLESTARTBLOCK) {
765 -                       pbmapp->pbm_bn = PAGE_BUF_DADDR_NULL;
766 -                       pbmapp->pbm_flags = PBMF_HOLE;
767 +                       iomapp->iomap_bn = IOMAP_DADDR_NULL;
768 +                       iomapp->iomap_flags = IOMAP_HOLE;
769                 } else if (start_block == DELAYSTARTBLOCK) {
770 -                       pbmapp->pbm_bn = PAGE_BUF_DADDR_NULL;
771 -                       pbmapp->pbm_flags = PBMF_DELAY;
772 +                       iomapp->iomap_bn = IOMAP_DADDR_NULL;
773 +                       iomapp->iomap_flags = IOMAP_DELAY;
774                 } else {
775 -                       pbmapp->pbm_bn = XFS_FSB_TO_DB_IO(io, start_block);
776 +                       iomapp->iomap_bn = XFS_FSB_TO_DB_IO(io, start_block);
777                         if (ISUNWRITTEN(imap))
778 -                               pbmapp->pbm_flags |= PBMF_UNWRITTEN;
779 +                               iomapp->iomap_flags |= IOMAP_UNWRITTEN;
780                 }
781  
782 -               if ((pbmapp->pbm_offset + pbmapp->pbm_bsize) >= nisize) {
783 -                       pbmapp->pbm_flags |= PBMF_EOF;
784 +               if ((iomapp->iomap_offset + iomapp->iomap_bsize) >= nisize) {
785 +                       iomapp->iomap_flags |= IOMAP_EOF;
786                 }
787  
788 -               if (new)
789 -                       pbmapp->pbm_flags |= PBMF_NEW;
790 -
791 -               offset += pbmapp->pbm_bsize - pbmapp->pbm_delta;
792 +               offset += iomapp->iomap_bsize - iomapp->iomap_delta;
793         }
794         return pbm;     /* Return the number filled */
795  }
796 @@ -132,54 +130,54 @@
797         xfs_off_t       offset,
798         ssize_t         count,
799         int             flags,
800 -       page_buf_bmap_t *pbmapp,
801 -       int             *npbmaps)
802 +       xfs_iomap_t     *iomapp,
803 +       int             *niomaps)
804  {
805         xfs_mount_t     *mp = io->io_mount;
806         xfs_fileoff_t   offset_fsb, end_fsb;
807         int             error = 0;
808 -       int             new = 0;
809         int             lockmode = 0;
810         xfs_bmbt_irec_t imap;
811         int             nimaps = 1;
812 -       int             bmap_flags = 0;
813 +       int             bmapi_flags = 0;
814 +       int             iomap_flags = 0;
815  
816         if (XFS_FORCED_SHUTDOWN(mp))
817 -               return -XFS_ERROR(EIO);
818 +               return XFS_ERROR(EIO);
819  
820         switch (flags &
821 -               (BMAP_READ | BMAP_WRITE | BMAP_ALLOCATE |
822 -                BMAP_UNWRITTEN | BMAP_DEVICE)) {
823 -       case BMAP_READ:
824 +               (BMAPI_READ | BMAPI_WRITE | BMAPI_ALLOCATE |
825 +                BMAPI_UNWRITTEN | BMAPI_DEVICE)) {
826 +       case BMAPI_READ:
827                 lockmode = XFS_LCK_MAP_SHARED(mp, io);
828 -               bmap_flags = XFS_BMAPI_ENTIRE;
829 -               if (flags & BMAP_IGNSTATE)
830 -                       bmap_flags |= XFS_BMAPI_IGSTATE;
831 +               bmapi_flags = XFS_BMAPI_ENTIRE;
832 +               if (flags & BMAPI_IGNSTATE)
833 +                       bmapi_flags |= XFS_BMAPI_IGSTATE;
834                 break;
835 -       case BMAP_WRITE:
836 +       case BMAPI_WRITE:
837                 lockmode = XFS_ILOCK_EXCL|XFS_EXTSIZE_WR;
838 -               bmap_flags = 0;
839 +               bmapi_flags = 0;
840                 XFS_ILOCK(mp, io, lockmode);
841                 break;
842 -       case BMAP_ALLOCATE:
843 +       case BMAPI_ALLOCATE:
844                 lockmode = XFS_ILOCK_SHARED|XFS_EXTSIZE_RD;
845 -               bmap_flags = XFS_BMAPI_ENTIRE;
846 +               bmapi_flags = XFS_BMAPI_ENTIRE;
847                 /* Attempt non-blocking lock */
848 -               if (flags & BMAP_TRYLOCK) {
849 +               if (flags & BMAPI_TRYLOCK) {
850                         if (!XFS_ILOCK_NOWAIT(mp, io, lockmode))
851                                 return XFS_ERROR(EAGAIN);
852                 } else {
853                         XFS_ILOCK(mp, io, lockmode);
854                 }
855                 break;
856 -       case BMAP_UNWRITTEN:
857 +       case BMAPI_UNWRITTEN:
858                 goto phase2;
859 -       case BMAP_DEVICE:
860 +       case BMAPI_DEVICE:
861                 lockmode = XFS_LCK_MAP_SHARED(mp, io);
862 -               pbmapp->pbm_target = io->io_flags & XFS_IOCORE_RT ?
863 +               iomapp->iomap_target = io->io_flags & XFS_IOCORE_RT ?
864                         mp->m_rtdev_targp : mp->m_ddev_targp;
865                 error = 0;
866 -               *npbmaps = 1;
867 +               *niomaps = 1;
868                 goto out;
869         default:
870                 BUG();
871 @@ -192,30 +190,30 @@
872         offset_fsb = XFS_B_TO_FSBT(mp, offset);
873  
874         error = XFS_BMAPI(mp, NULL, io, offset_fsb,
875 -                       (xfs_filblks_t)(end_fsb - offset_fsb) ,
876 -                       bmap_flags,  NULL, 0, &imap,
877 +                       (xfs_filblks_t)(end_fsb - offset_fsb),
878 +                       bmapi_flags,  NULL, 0, &imap,
879                         &nimaps, NULL);
880  
881         if (error)
882                 goto out;
883  
884  phase2:
885 -       switch (flags & (BMAP_WRITE|BMAP_ALLOCATE|BMAP_UNWRITTEN)) {
886 -       case BMAP_WRITE:
887 +       switch (flags & (BMAPI_WRITE|BMAPI_ALLOCATE|BMAPI_UNWRITTEN)) {
888 +       case BMAPI_WRITE:
889                 /* If we found an extent, return it */
890                 if (nimaps && (imap.br_startblock != HOLESTARTBLOCK))
891                         break;
892  
893 -               if (flags & (BMAP_DIRECT|BMAP_MMAP)) {
894 +               if (flags & (BMAPI_DIRECT|BMAPI_MMAP)) {
895                         error = XFS_IOMAP_WRITE_DIRECT(mp, io, offset,
896                                         count, flags, &imap, &nimaps, nimaps);
897                 } else {
898                         error = XFS_IOMAP_WRITE_DELAY(mp, io, offset, count,
899                                         flags, &imap, &nimaps);
900                 }
901 -               new = 1;
902 +               iomap_flags = IOMAP_NEW;
903                 break;
904 -       case BMAP_ALLOCATE:
905 +       case BMAPI_ALLOCATE:
906                 /* If we found an extent, return it */
907                 XFS_IUNLOCK(mp, io, lockmode);
908                 lockmode = 0;
909 @@ -225,7 +223,7 @@
910  
911                 error = XFS_IOMAP_WRITE_ALLOCATE(mp, io, &imap, &nimaps);
912                 break;
913 -       case BMAP_UNWRITTEN:
914 +       case BMAPI_UNWRITTEN:
915                 lockmode = 0;
916                 error = XFS_IOMAP_WRITE_UNWRITTEN(mp, io, offset, count);
917                 nimaps = 0;
918 @@ -233,10 +231,10 @@
919         }
920  
921         if (nimaps) {
922 -               *npbmaps = _xfs_imap_to_bmap(io, offset, new, &imap,
923 -                                       pbmapp, nimaps, *npbmaps);
924 -       } else if (npbmaps) {
925 -               *npbmaps = 0;
926 +               *niomaps = xfs_imap_to_bmap(io, offset, &imap,
927 +                                       iomapp, nimaps, *niomaps, iomap_flags);
928 +       } else if (niomaps) {
929 +               *niomaps = 0;
930         }
931  
932  out:
933 @@ -251,29 +249,25 @@
934         int             *fsynced,
935         int             *ioflags)
936  {
937 -       vnode_t         *vp = XFS_ITOV(ip);
938 -
939         switch (*fsynced) {
940         case 0:
941                 if (ip->i_delayed_blks) {
942                         xfs_iunlock(ip, XFS_ILOCK_EXCL);
943 -                       filemap_fdatawrite(LINVFS_GET_IP(vp)->i_mapping);
944 +                       xfs_flush_inode(ip);
945                         xfs_ilock(ip, XFS_ILOCK_EXCL);
946                         *fsynced = 1;
947                 } else {
948 -                       *ioflags |= BMAP_SYNC;
949 +                       *ioflags |= BMAPI_SYNC;
950                         *fsynced = 2;
951                 }
952                 return 0;
953         case 1:
954                 *fsynced = 2;
955 -               *ioflags |= BMAP_SYNC;
956 +               *ioflags |= BMAPI_SYNC;
957                 return 0;
958         case 2:
959                 xfs_iunlock(ip, XFS_ILOCK_EXCL);
960 -               sync_blockdev(vp->v_vfsp->vfs_super->s_bdev);
961 -               xfs_log_force(ip->i_mount, (xfs_lsn_t)0,
962 -                                               XFS_LOG_FORCE|XFS_LOG_SYNC);
963 +               xfs_flush_device(ip);
964                 xfs_ilock(ip, XFS_ILOCK_EXCL);
965                 *fsynced = 3;
966                 return 0;
967 @@ -400,7 +394,7 @@
968         xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
969         xfs_trans_ihold(tp, ip);
970  
971 -       if (!(flags & BMAP_MMAP) && (offset < ip->i_d.di_size || rt))
972 +       if (!(flags & BMAPI_MMAP) && (offset < ip->i_d.di_size || rt))
973                 bmapi_flag |= XFS_BMAPI_PREALLOC;
974  
975         /*
976 @@ -499,7 +493,7 @@
977          * We don't bother with this for sync writes, because we need
978          * to minimize the amount we write for good performance.
979          */
980 -       if (!(ioflag & BMAP_SYNC) && ((offset + count) > ip->i_d.di_size)) {
981 +       if (!(ioflag & BMAPI_SYNC) && ((offset + count) > ip->i_d.di_size)) {
982                 xfs_off_t       aligned_offset;
983                 unsigned int    iosize;
984                 xfs_fileoff_t   ioalign;
985 diff -urN linux.org/fs/xfs/linux/xfs_iops.c linux/fs/xfs/linux/xfs_iops.c
986 --- linux.org/fs/xfs/linux/xfs_iops.c   2003-12-31 05:46:55.000000000 +0100
987 +++ linux/fs/xfs/linux/xfs_iops.c       2004-01-02 04:21:43.000000000 +0100
988 @@ -110,7 +110,7 @@
989         vattr_t         va;
990         vnode_t         *vp = NULL, *dvp = LINVFS_GET_VP(dir);
991         xfs_acl_t       *default_acl = NULL;
992 -       xattr_exists_t  test_default_acl = _ACL_DEFAULT_EXISTS;
993 +       attrexists_t    test_default_acl = _ACL_DEFAULT_EXISTS;
994         int             error;
995  
996         /*
997 @@ -552,61 +552,6 @@
998         block_truncate_page(inode->i_mapping, inode->i_size, linvfs_get_block);
999  }
1000  
1001 -
1002 -
1003 -/*
1004 - * Extended attributes interfaces
1005 - */
1006 -
1007 -#define SYSTEM_NAME    "system."       /* VFS shared names/values */
1008 -#define ROOT_NAME      "trusted."      /* root's own names/values */
1009 -#define USER_NAME      "user."         /* user's own names/values */
1010 -STATIC xattr_namespace_t xfs_namespace_array[] = {
1011 -       { .name= SYSTEM_NAME,   .namelen= sizeof(SYSTEM_NAME)-1,.exists= NULL },
1012 -       { .name= ROOT_NAME,     .namelen= sizeof(ROOT_NAME)-1,  .exists= NULL },
1013 -       { .name= USER_NAME,     .namelen= sizeof(USER_NAME)-1,  .exists= NULL },
1014 -       { .name= NULL }
1015 -};
1016 -xattr_namespace_t *xfs_namespaces = &xfs_namespace_array[0];
1017 -
1018 -#define POSIXACL_ACCESS                "posix_acl_access"
1019 -#define POSIXACL_ACCESS_SIZE   (sizeof(POSIXACL_ACCESS)-1)
1020 -#define POSIXACL_DEFAULT       "posix_acl_default"
1021 -#define POSIXACL_DEFAULT_SIZE  (sizeof(POSIXACL_DEFAULT)-1)
1022 -#define POSIXCAP               "posix_capabilities"
1023 -#define POSIXCAP_SIZE          (sizeof(POSIXCAP)-1)
1024 -#define POSIXMAC               "posix_mac"
1025 -#define POSIXMAC_SIZE          (sizeof(POSIXMAC)-1)
1026 -STATIC xattr_namespace_t sys_namespace_array[] = {
1027 -       { .name= POSIXACL_ACCESS,
1028 -               .namelen= POSIXACL_ACCESS_SIZE,  .exists= _ACL_ACCESS_EXISTS },
1029 -       { .name= POSIXACL_DEFAULT,
1030 -               .namelen= POSIXACL_DEFAULT_SIZE, .exists= _ACL_DEFAULT_EXISTS },
1031 -       { .name= POSIXCAP,
1032 -               .namelen= POSIXCAP_SIZE,         .exists= _CAP_EXISTS },
1033 -       { .name= POSIXMAC,
1034 -               .namelen= POSIXMAC_SIZE,         .exists= _MAC_EXISTS },
1035 -       { .name= NULL }
1036 -};
1037 -
1038 -/*
1039 - * Some checks to prevent people abusing EAs to get over quota:
1040 - * - Don't allow modifying user EAs on devices/symlinks;
1041 - * - Don't allow modifying user EAs if sticky bit set;
1042 - */
1043 -STATIC int
1044 -capable_user_xattr(
1045 -       struct inode    *inode)
1046 -{
1047 -       if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) &&
1048 -           !capable(CAP_SYS_ADMIN))
1049 -               return 0;
1050 -       if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
1051 -           (current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
1052 -               return 0;
1053 -       return 1;
1054 -}
1055 -
1056  STATIC int
1057  linvfs_setxattr(
1058         struct dentry   *dentry,
1059 @@ -615,59 +560,27 @@
1060         size_t          size,
1061         int             flags)
1062  {
1063 -       struct inode    *inode = dentry->d_inode;
1064 -       vnode_t         *vp = LINVFS_GET_VP(inode);
1065 -       char            *p = (char *)name;
1066 +       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
1067 +       char            *attr = (char *)name;
1068 +       attrnames_t     *namesp;
1069         int             xflags = 0;
1070         int             error;
1071  
1072 -       if (strncmp(name, xfs_namespaces[SYSTEM_NAMES].name,
1073 -                       xfs_namespaces[SYSTEM_NAMES].namelen) == 0) {
1074 -               error = -EINVAL;
1075 -               if (flags & XATTR_CREATE)
1076 -                        return error;
1077 -               error = -EOPNOTSUPP;
1078 -               p += xfs_namespaces[SYSTEM_NAMES].namelen;
1079 -               if (strcmp(p, POSIXACL_ACCESS) == 0)
1080 -                       error = xfs_acl_vset(vp, (void *) data, size,
1081 -                                               _ACL_TYPE_ACCESS);
1082 -               else if (strcmp(p, POSIXACL_DEFAULT) == 0)
1083 -                       error = xfs_acl_vset(vp, (void *) data, size,
1084 -                                               _ACL_TYPE_DEFAULT);
1085 -               else if (strcmp(p, POSIXCAP) == 0)
1086 -                       error = xfs_cap_vset(vp, (void *) data, size);
1087 -               if (!error)
1088 -                       error = vn_revalidate(vp);
1089 +       namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
1090 +       if (!namesp)
1091 +               return -EOPNOTSUPP;
1092 +       attr += namesp->attr_namelen;
1093 +       error = namesp->attr_capable(vp, NULL);
1094 +       if (error)
1095                 return error;
1096 -       }
1097 -
1098 -       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1099 -               return -EPERM;
1100  
1101         /* Convert Linux syscall to XFS internal ATTR flags */
1102         if (flags & XATTR_CREATE)
1103                 xflags |= ATTR_CREATE;
1104         if (flags & XATTR_REPLACE)
1105                 xflags |= ATTR_REPLACE;
1106 -
1107 -       if (strncmp(name, xfs_namespaces[ROOT_NAMES].name,
1108 -                       xfs_namespaces[ROOT_NAMES].namelen) == 0) {
1109 -               if (!capable(CAP_SYS_ADMIN))
1110 -                       return -EPERM;
1111 -               xflags |= ATTR_ROOT;
1112 -               p += xfs_namespaces[ROOT_NAMES].namelen;
1113 -               VOP_ATTR_SET(vp, p, (void *) data, size, xflags, NULL, error);
1114 -               return -error;
1115 -       }
1116 -       if (strncmp(name, xfs_namespaces[USER_NAMES].name,
1117 -                       xfs_namespaces[USER_NAMES].namelen) == 0) {
1118 -               if (!capable_user_xattr(inode))
1119 -                       return -EPERM;
1120 -               p += xfs_namespaces[USER_NAMES].namelen;
1121 -               VOP_ATTR_SET(vp, p, (void *) data, size, xflags, NULL, error);
1122 -               return -error;
1123 -       }
1124 -       return -EOPNOTSUPP;
1125 +       xflags |= namesp->attr_flag;
1126 +       return namesp->attr_set(vp, attr, (void *)data, size, xflags);
1127  }
1128  
1129  STATIC ssize_t
1130 @@ -677,53 +590,27 @@
1131         void            *data,
1132         size_t          size)
1133  {
1134 -       struct inode    *inode = dentry->d_inode;
1135 -       vnode_t         *vp = LINVFS_GET_VP(inode);
1136 -       char            *p = (char *)name;
1137 +       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
1138 +       char            *attr = (char *)name;
1139 +       attrnames_t     *namesp;
1140         int             xflags = 0;
1141         ssize_t         error;
1142  
1143 -       if (strncmp(name, xfs_namespaces[SYSTEM_NAMES].name,
1144 -                       xfs_namespaces[SYSTEM_NAMES].namelen) == 0) {
1145 -               error = -EOPNOTSUPP;
1146 -               p += xfs_namespaces[SYSTEM_NAMES].namelen;
1147 -               if (strcmp(p, POSIXACL_ACCESS) == 0)
1148 -                       error = xfs_acl_vget(vp, data, size, _ACL_TYPE_ACCESS);
1149 -               else if (strcmp(p, POSIXACL_DEFAULT) == 0)
1150 -                       error = xfs_acl_vget(vp, data, size, _ACL_TYPE_DEFAULT);
1151 -               else if (strcmp(p, POSIXCAP) == 0)
1152 -                       error = xfs_cap_vget(vp, data, size);
1153 +       namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
1154 +       if (!namesp)
1155 +               return -EOPNOTSUPP;
1156 +       attr += namesp->attr_namelen;
1157 +       error = namesp->attr_capable(vp, NULL);
1158 +       if (error)
1159                 return error;
1160 -       }
1161  
1162         /* Convert Linux syscall to XFS internal ATTR flags */
1163         if (!size) {
1164                 xflags |= ATTR_KERNOVAL;
1165                 data = NULL;
1166         }
1167 -
1168 -       if (strncmp(name, xfs_namespaces[ROOT_NAMES].name,
1169 -                       xfs_namespaces[ROOT_NAMES].namelen) == 0) {
1170 -               if (!capable(CAP_SYS_ADMIN))
1171 -                       return -EPERM;
1172 -               xflags |= ATTR_ROOT;
1173 -               p += xfs_namespaces[ROOT_NAMES].namelen;
1174 -               VOP_ATTR_GET(vp, p, data, (int *)&size, xflags, NULL, error);
1175 -               if (!error)
1176 -                       error = -size;
1177 -               return -error;
1178 -       }
1179 -       if (strncmp(name, xfs_namespaces[USER_NAMES].name,
1180 -                       xfs_namespaces[USER_NAMES].namelen) == 0) {
1181 -               p += xfs_namespaces[USER_NAMES].namelen;
1182 -               if (!capable_user_xattr(inode))
1183 -                       return -EPERM;
1184 -               VOP_ATTR_GET(vp, p, data, (int *)&size, xflags, NULL, error);
1185 -               if (!error)
1186 -                       error = -size;
1187 -               return -error;
1188 -       }
1189 -       return -EOPNOTSUPP;
1190 +       xflags |= namesp->attr_flag;
1191 +       return namesp->attr_get(vp, attr, (void *)data, size, xflags);
1192  }
1193  
1194  STATIC ssize_t
1195 @@ -732,40 +619,18 @@
1196         char                    *data,
1197         size_t                  size)
1198  {
1199 -       attrlist_cursor_kern_t  cursor;
1200 -       xattr_namespace_t       *sys;
1201         vnode_t                 *vp = LINVFS_GET_VP(dentry->d_inode);
1202 -       char                    *k = data;
1203 -       int                     xflags = ATTR_KERNAMELS;
1204 -       int                     result = 0;
1205 -       ssize_t                 error;
1206 +       int                     error, xflags = ATTR_KERNAMELS;
1207 +       ssize_t                 result;
1208  
1209         if (!size)
1210                 xflags |= ATTR_KERNOVAL;
1211         if (capable(CAP_SYS_ADMIN))
1212                 xflags |= ATTR_KERNFULLS;
1213  
1214 -       memset(&cursor, 0, sizeof(cursor));
1215 -       VOP_ATTR_LIST(vp, data, size, xflags, &cursor, NULL, error);
1216 -       if (error > 0)
1217 -               return -error;
1218 -       result += -error;
1219 -
1220 -       k += result;            /* advance start of our buffer */
1221 -       for (sys = &sys_namespace_array[0]; sys->name != NULL; sys++) {
1222 -               if (sys->exists == NULL || !sys->exists(vp))
1223 -                       continue;
1224 -               result += xfs_namespaces[SYSTEM_NAMES].namelen;
1225 -               result += sys->namelen + 1;
1226 -               if (size) {
1227 -                       if (result > size)
1228 -                               return -ERANGE;
1229 -                       strcpy(k, xfs_namespaces[SYSTEM_NAMES].name);
1230 -                       k += xfs_namespaces[SYSTEM_NAMES].namelen;
1231 -                       strcpy(k, sys->name);
1232 -                       k += sys->namelen + 1;
1233 -               }
1234 -       }
1235 +       error = attr_generic_list(vp, data, size, xflags, &result);
1236 +       if (error < 0)
1237 +               return error;
1238         return result;
1239  }
1240  
1241 @@ -774,51 +639,25 @@
1242         struct dentry   *dentry,
1243         const char      *name)
1244  {
1245 -       struct inode    *inode = dentry->d_inode;
1246 -       vnode_t         *vp = LINVFS_GET_VP(inode);
1247 -       char            *p = (char *)name;
1248 +       vnode_t         *vp = LINVFS_GET_VP(dentry->d_inode);
1249 +       char            *attr = (char *)name;
1250 +       attrnames_t     *namesp;
1251         int             xflags = 0;
1252         int             error;
1253  
1254 -       if (strncmp(name, xfs_namespaces[SYSTEM_NAMES].name,
1255 -                       xfs_namespaces[SYSTEM_NAMES].namelen) == 0) {
1256 -               error = -EOPNOTSUPP;
1257 -               p += xfs_namespaces[SYSTEM_NAMES].namelen;
1258 -               if (strcmp(p, POSIXACL_ACCESS) == 0)
1259 -                       error = xfs_acl_vremove(vp, _ACL_TYPE_ACCESS);
1260 -               else if (strcmp(p, POSIXACL_DEFAULT) == 0)
1261 -                       error = xfs_acl_vremove(vp, _ACL_TYPE_DEFAULT);
1262 -               else if (strcmp(p, POSIXCAP) == 0)
1263 -                       error = xfs_cap_vremove(vp);
1264 +       namesp = attr_lookup_namespace(attr, attr_namespaces, ATTR_NAMECOUNT);
1265 +       if (!namesp)
1266 +               return -EOPNOTSUPP;
1267 +       attr += namesp->attr_namelen;
1268 +       error = namesp->attr_capable(vp, NULL);
1269 +       if (error)
1270                 return error;
1271 -       }
1272 -
1273 -        if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
1274 -               return -EPERM;
1275 -
1276 -       if (strncmp(name, xfs_namespaces[ROOT_NAMES].name,
1277 -                       xfs_namespaces[ROOT_NAMES].namelen) == 0) {
1278 -               if (!capable(CAP_SYS_ADMIN))
1279 -                       return -EPERM;
1280 -               xflags |= ATTR_ROOT;
1281 -               p += xfs_namespaces[ROOT_NAMES].namelen;
1282 -               VOP_ATTR_REMOVE(vp, p, xflags, NULL, error);
1283 -               return -error;
1284 -       }
1285 -       if (strncmp(name, xfs_namespaces[USER_NAMES].name,
1286 -                       xfs_namespaces[USER_NAMES].namelen) == 0) {
1287 -               p += xfs_namespaces[USER_NAMES].namelen;
1288 -               if (!capable_user_xattr(inode))
1289 -                       return -EPERM;
1290 -               VOP_ATTR_REMOVE(vp, p, xflags, NULL, error);
1291 -               return -error;
1292 -       }
1293 -       return -EOPNOTSUPP;
1294 +       xflags |= namesp->attr_flag;
1295 +       return namesp->attr_remove(vp, attr, xflags);
1296  }
1297  
1298  
1299 -struct inode_operations linvfs_file_inode_operations =
1300 -{
1301 +struct inode_operations linvfs_file_inode_operations = {
1302         .permission             = linvfs_permission,
1303         .truncate               = linvfs_truncate,
1304         .getattr                = linvfs_getattr,
1305 @@ -829,8 +668,7 @@
1306         .removexattr            = linvfs_removexattr,
1307  };
1308  
1309 -struct inode_operations linvfs_dir_inode_operations =
1310 -{
1311 +struct inode_operations linvfs_dir_inode_operations = {
1312         .create                 = linvfs_create,
1313         .lookup                 = linvfs_lookup,
1314         .link                   = linvfs_link,
1315 @@ -849,8 +687,7 @@
1316         .removexattr            = linvfs_removexattr,
1317  };
1318  
1319 -struct inode_operations linvfs_symlink_inode_operations =
1320 -{
1321 +struct inode_operations linvfs_symlink_inode_operations = {
1322         .readlink               = linvfs_readlink,
1323         .follow_link            = linvfs_follow_link,
1324         .permission             = linvfs_permission,
1325 diff -urN linux.org/fs/xfs/linux/xfs_iops.h linux/fs/xfs/linux/xfs_iops.h
1326 --- linux.org/fs/xfs/linux/xfs_iops.h   2003-12-31 05:47:32.000000000 +0100
1327 +++ linux/fs/xfs/linux/xfs_iops.h       2004-01-02 04:21:43.000000000 +0100
1328 @@ -1,5 +1,5 @@
1329  /*
1330 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
1331 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
1332   *
1333   * This program is free software; you can redistribute it and/or modify it
1334   * under the terms of version 2 of the GNU General Public License as
1335 @@ -32,30 +32,6 @@
1336  #ifndef __XFS_IOPS_H__
1337  #define __XFS_IOPS_H__
1338  
1339 -/*
1340 - * Extended system attributes.
1341 - * So far only POSIX ACLs are supported, but this will need to
1342 - * grow in time (capabilities, mandatory access control, etc).
1343 - */
1344 -#define XFS_SYSTEM_NAMESPACE   SYSTEM_POSIXACL
1345 -
1346 -/*
1347 - * Define a table of the namespaces XFS supports
1348 - */
1349 -typedef int (*xattr_exists_t)(vnode_t *);
1350 -
1351 -typedef struct xattr_namespace {
1352 -       char            *name;
1353 -       unsigned int    namelen;
1354 -       xattr_exists_t  exists;
1355 -} xattr_namespace_t;
1356 -
1357 -#define SYSTEM_NAMES   0
1358 -#define ROOT_NAMES     1
1359 -#define USER_NAMES     2
1360 -extern struct xattr_namespace *xfs_namespaces;
1361 -
1362 -
1363  extern struct inode_operations linvfs_file_inode_operations;
1364  extern struct inode_operations linvfs_dir_inode_operations;
1365  extern struct inode_operations linvfs_symlink_inode_operations;
1366 @@ -69,4 +45,7 @@
1367  extern int linvfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
1368  extern void linvfs_unwritten_done(struct buffer_head *, int);
1369  
1370 +extern int xfs_ioctl(struct bhv_desc *, struct inode *, struct file *,
1371 +                        int, unsigned int, unsigned long);
1372 +
1373  #endif /* __XFS_IOPS_H__ */
1374 diff -urN linux.org/fs/xfs/linux/xfs_linux.h linux/fs/xfs/linux/xfs_linux.h
1375 --- linux.org/fs/xfs/linux/xfs_linux.h  2003-12-31 05:46:20.000000000 +0100
1376 +++ linux/fs/xfs/linux/xfs_linux.h      2004-01-02 04:21:43.000000000 +0100
1377 @@ -47,6 +47,7 @@
1378  #include <linux/seq_file.h>
1379  #include <linux/init.h>
1380  #include <linux/proc_fs.h>
1381 +#include <linux/version.h>
1382  
1383  #include <asm/page.h>
1384  #include <asm/div64.h>
1385 @@ -69,9 +70,11 @@
1386  
1387  #include <pagebuf/page_buf.h>
1388  
1389 -#ifndef STATIC
1390 -#define STATIC static
1391 -#endif
1392 +/*
1393 + * Feature macros (disable/enable)
1394 + */
1395 +#undef  HAVE_REFCACHE  /* reference cache not needed for NFS in 2.6 */
1396 +#define HAVE_SENDFILE  /* sendfile(2) exists in 2.6, but not in 2.4 */
1397  
1398  /*
1399   * State flag for unwritten extent buffers.
1400 @@ -100,6 +103,11 @@
1401  #define xfs_inherit_nodump     xfs_params.inherit_nodump.val
1402  #define xfs_inherit_noatime    xfs_params.inherit_noatim.val
1403  
1404 +#define current_cpu()          smp_processor_id()
1405 +#define current_pid()          (current->pid)
1406 +#define current_fsuid(cred)    (current->fsuid)
1407 +#define current_fsgid(cred)    (current->fsgid)
1408 +
1409  #define NBPP           PAGE_SIZE
1410  #define DPPSHFT                (PAGE_SHIFT - 9)
1411  #define NDPP           (1 << (PAGE_SHIFT - 9))
1412 @@ -200,6 +208,11 @@
1413  #define howmany(x, y)  (((x)+((y)-1))/(y))
1414  #define roundup(x, y)  ((((x)+((y)-1))/(y))*(y))
1415  
1416 +static inline void xfs_stack_trace(void)
1417 +{
1418 +       dump_stack();
1419 +}
1420 +
1421  /* Move the kernel do_div definition off to one side */
1422  
1423  #if defined __i386__
1424 diff -urN linux.org/fs/xfs/linux/xfs_lrw.c linux/fs/xfs/linux/xfs_lrw.c
1425 --- linux.org/fs/xfs/linux/xfs_lrw.c    2003-12-31 05:46:18.000000000 +0100
1426 +++ linux/fs/xfs/linux/xfs_lrw.c        2004-01-02 04:21:43.000000000 +0100
1427 @@ -71,10 +71,76 @@
1428  #include "xfs_inode_item.h"
1429  #include "xfs_buf_item.h"
1430  #include "xfs_utils.h"
1431 +#include "xfs_iomap.h"
1432  
1433  #include <linux/capability.h>
1434  
1435  
1436 +#if defined(XFS_RW_TRACE)
1437 +void
1438 +xfs_rw_enter_trace(
1439 +       int                     tag,
1440 +       xfs_iocore_t            *io,
1441 +       const struct iovec      *iovp,
1442 +       size_t                  segs,
1443 +       loff_t                  offset,
1444 +       int                     ioflags)
1445 +{
1446 +       xfs_inode_t     *ip = XFS_IO_INODE(io);
1447 +
1448 +       if (ip->i_rwtrace == NULL)
1449 +               return;
1450 +       ktrace_enter(ip->i_rwtrace,
1451 +               (void *)(unsigned long)tag,
1452 +               (void *)ip,
1453 +               (void *)((unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff)),
1454 +               (void *)((unsigned long)(ip->i_d.di_size & 0xffffffff)),
1455 +               (void *)(__psint_t)iovp,
1456 +               (void *)((unsigned long)segs),
1457 +               (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
1458 +               (void *)((unsigned long)(offset & 0xffffffff)),
1459 +               (void *)((unsigned long)ioflags),
1460 +               (void *)((unsigned long)((io->io_new_size >> 32) & 0xffffffff)),
1461 +               (void *)((unsigned long)(io->io_new_size & 0xffffffff)),
1462 +               (void *)NULL,
1463 +               (void *)NULL,
1464 +               (void *)NULL,
1465 +               (void *)NULL,
1466 +               (void *)NULL);
1467 +}
1468 +
1469 +void
1470 +xfs_inval_cached_trace(
1471 +       xfs_iocore_t    *io,
1472 +       xfs_off_t       offset,
1473 +       xfs_off_t       len,
1474 +       xfs_off_t       first,
1475 +       xfs_off_t       last)
1476 +{
1477 +       xfs_inode_t     *ip = XFS_IO_INODE(io);
1478 +
1479 +       if (ip->i_rwtrace == NULL)
1480 +               return;
1481 +       ktrace_enter(ip->i_rwtrace,
1482 +               (void *)(__psint_t)XFS_INVAL_CACHED,
1483 +               (void *)ip,
1484 +               (void *)((unsigned long)((offset >> 32) & 0xffffffff)),
1485 +               (void *)((unsigned long)(offset & 0xffffffff)),
1486 +               (void *)((unsigned long)((len >> 32) & 0xffffffff)),
1487 +               (void *)((unsigned long)(len & 0xffffffff)),
1488 +               (void *)((unsigned long)((first >> 32) & 0xffffffff)),
1489 +               (void *)((unsigned long)(first & 0xffffffff)),
1490 +               (void *)((unsigned long)((last >> 32) & 0xffffffff)),
1491 +               (void *)((unsigned long)(last & 0xffffffff)),
1492 +               (void *)NULL,
1493 +               (void *)NULL,
1494 +               (void *)NULL,
1495 +               (void *)NULL,
1496 +               (void *)NULL,
1497 +               (void *)NULL);
1498 +}
1499 +#endif
1500 +
1501  /*
1502   *     xfs_iozero
1503   *
1504 @@ -142,6 +208,59 @@
1505         return (-status);
1506  }
1507  
1508 +/*
1509 + * xfs_inval_cached_pages
1510 + * 
1511 + * This routine is responsible for keeping direct I/O and buffered I/O
1512 + * somewhat coherent.  From here we make sure that we're at least
1513 + * temporarily holding the inode I/O lock exclusively and then call
1514 + * the page cache to flush and invalidate any cached pages.  If there
1515 + * are no cached pages this routine will be very quick.
1516 + */
1517 +void
1518 +xfs_inval_cached_pages(
1519 +       vnode_t         *vp,
1520 +       xfs_iocore_t    *io,
1521 +       xfs_off_t       offset,
1522 +       int             write,
1523 +       int             relock)
1524 +{
1525 +       xfs_mount_t     *mp;
1526 +
1527 +       if (!VN_CACHED(vp)) {
1528 +               return;
1529 +       }
1530 +
1531 +       mp = io->io_mount;
1532 +
1533 +       /*
1534 +        * We need to get the I/O lock exclusively in order
1535 +        * to safely invalidate pages and mappings.
1536 +        */
1537 +       if (relock) {
1538 +               XFS_IUNLOCK(mp, io, XFS_IOLOCK_SHARED);
1539 +               XFS_ILOCK(mp, io, XFS_IOLOCK_EXCL);
1540 +       }
1541 +
1542 +       /* Writing beyond EOF creates a hole that must be zeroed */
1543 +       if (write && (offset > XFS_SIZE(mp, io))) {
1544 +               xfs_fsize_t     isize;
1545 +
1546 +               XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
1547 +               isize = XFS_SIZE(mp, io);
1548 +               if (offset > isize) {
1549 +                       xfs_zero_eof(vp, io, offset, isize, offset);
1550 +               }
1551 +               XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
1552 +       }
1553 +
1554 +       xfs_inval_cached_trace(io, offset, -1, ctooff(offtoct(offset)), -1);
1555 +       VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(offset)), -1, FI_REMAPF_LOCKED);
1556 +       if (relock) {
1557 +               XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
1558 +       }
1559 +}
1560 +
1561  ssize_t                        /* bytes read, or (-)  error */
1562  xfs_read(
1563         bhv_desc_t              *bdp,
1564 @@ -211,7 +330,8 @@
1565          * does not really happen here, but is scheduled 
1566          * later?
1567          */
1568 -       xfs_ilock(ip, XFS_IOLOCK_SHARED);
1569 +       if (!(ioflags & IO_ISLOCKED))
1570 +               xfs_ilock(ip, XFS_IOLOCK_SHARED);
1571  
1572         if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
1573             !(ioflags & IO_INVIS)) {
1574 @@ -221,13 +341,15 @@
1575                 error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp), *offset, size,
1576                                       FILP_DELAY_FLAG(file), &locktype);
1577                 if (error) {
1578 -                       xfs_iunlock(ip, XFS_IOLOCK_SHARED);
1579 +                       if (!(ioflags & IO_ISLOCKED))
1580 +                               xfs_iunlock(ip, XFS_IOLOCK_SHARED);
1581                         return -error;
1582                 }
1583         }
1584  
1585         ret = __generic_file_aio_read(iocb, iovp, segs, offset);
1586 -       xfs_iunlock(ip, XFS_IOLOCK_SHARED);
1587 +       if (!(ioflags & IO_ISLOCKED))
1588 +               xfs_iunlock(ip, XFS_IOLOCK_SHARED);
1589  
1590         if (ret > 0)
1591                 XFS_STATS_ADD(xs_read_bytes, ret);
1592 @@ -272,7 +394,8 @@
1593         if (XFS_FORCED_SHUTDOWN(ip->i_mount))
1594                 return -EIO;
1595  
1596 -       xfs_ilock(ip, XFS_IOLOCK_SHARED);
1597 +       if (!(ioflags & IO_ISLOCKED))
1598 +               xfs_ilock(ip, XFS_IOLOCK_SHARED);
1599  
1600         if (DM_EVENT_ENABLED(vp->v_vfsp, ip, DM_EVENT_READ) &&
1601             (!(ioflags & IO_INVIS))) {
1602 @@ -282,12 +405,14 @@
1603                 error = XFS_SEND_DATA(mp, DM_EVENT_READ, BHV_TO_VNODE(bdp), *offset, count,
1604                                       FILP_DELAY_FLAG(filp), &locktype);
1605                 if (error) {
1606 -                       xfs_iunlock(ip, XFS_IOLOCK_SHARED);
1607 +                       if (!(ioflags & IO_ISLOCKED))
1608 +                               xfs_iunlock(ip, XFS_IOLOCK_SHARED);
1609                         return -error;
1610                 }
1611         }
1612         ret = generic_file_sendfile(filp, offset, count, actor, target);
1613 -       xfs_iunlock(ip, XFS_IOLOCK_SHARED);
1614 +       if (!(ioflags & IO_ISLOCKED))
1615 +               xfs_iunlock(ip, XFS_IOLOCK_SHARED);
1616  
1617         XFS_STATS_ADD(xs_read_bytes, ret);
1618         xfs_ichgtime(ip, XFS_ICHGTIME_ACC);
1619 @@ -584,6 +709,9 @@
1620                 locktype = VRWLOCK_WRITE;
1621         }
1622  
1623 +       if (ioflags & IO_ISLOCKED)
1624 +               iolock = 0;
1625 +
1626         xfs_ilock(xip, XFS_ILOCK_EXCL|iolock);
1627  
1628         isize = xip->i_d.di_size;
1629 @@ -616,7 +744,7 @@
1630                                       *offset, size,
1631                                       FILP_DELAY_FLAG(file), &locktype);
1632                 if (error) {
1633 -                       xfs_iunlock(xip, iolock);
1634 +                       if (iolock) xfs_iunlock(xip, iolock);
1635                         return -error;
1636                 }
1637                 xfs_ilock(xip, XFS_ILOCK_EXCL);
1638 @@ -684,9 +812,13 @@
1639  
1640  retry:
1641         if (ioflags & IO_ISDIRECT) {
1642 -               xfs_inval_cached_pages(vp, &xip->i_iocore, *offset, 1, 1);
1643 +               xfs_inval_cached_pages(vp, io, *offset, 1, 1);
1644 +               xfs_rw_enter_trace(XFS_DIOWR_ENTER,
1645 +                               io, iovp, segs, *offset, ioflags);
1646 +       } else {
1647 +               xfs_rw_enter_trace(XFS_WRITE_ENTER,
1648 +                               io, iovp, segs, *offset, ioflags);
1649         }
1650 -
1651         ret = generic_file_aio_write_nolock(iocb, iovp, segs, offset);
1652  
1653         if ((ret == -ENOSPC) &&
1654 @@ -702,7 +834,6 @@
1655                 xfs_rwlock(bdp, locktype);
1656                 *offset = xip->i_d.di_size;
1657                 goto retry;
1658 -
1659         }
1660  
1661         if (*offset > xip->i_d.di_size) {
1662 @@ -806,7 +937,9 @@
1663                 }
1664         } /* (ioflags & O_SYNC) */
1665  
1666 -       xfs_rwunlock(bdp, locktype);
1667 +       if (iolock)
1668 +               xfs_rwunlock(bdp, locktype);
1669 +
1670         return(ret);
1671  }
1672  
1673 @@ -846,8 +979,8 @@
1674         xfs_off_t       offset,
1675         ssize_t         count,
1676         int             flags,
1677 -       page_buf_bmap_t *pbmapp,
1678 -       int             *npbmaps)
1679 +       xfs_iomap_t     *iomapp,
1680 +       int             *niomaps)
1681  {
1682         xfs_inode_t     *ip = XFS_BHVTOI(bdp);
1683         xfs_iocore_t    *io = &ip->i_iocore;
1684 @@ -856,7 +989,7 @@
1685         ASSERT(((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) != 0) ==
1686                ((ip->i_iocore.io_flags & XFS_IOCORE_RT) != 0));
1687  
1688 -       return xfs_iomap(io, offset, count, flags, pbmapp, npbmaps);
1689 +       return xfs_iomap(io, offset, count, flags, iomapp, niomaps);
1690  }
1691  
1692  /*
1693 diff -urN linux.org/fs/xfs/linux/xfs_lrw.h linux/fs/xfs/linux/xfs_lrw.h
1694 --- linux.org/fs/xfs/linux/xfs_lrw.h    2003-12-31 05:46:25.000000000 +0100
1695 +++ linux/fs/xfs/linux/xfs_lrw.h        2004-01-02 04:21:43.000000000 +0100
1696 @@ -39,21 +39,59 @@
1697  struct xfs_inode;
1698  struct xfs_bmbt_irec;
1699  struct page_buf_s;
1700 -struct page_buf_bmap_s;
1701 +struct xfs_iomap;
1702  
1703 +#if defined(XFS_RW_TRACE)
1704 +/*
1705 + * Defines for the trace mechanisms in xfs_lrw.c.
1706 + */
1707 +#define        XFS_RW_KTRACE_SIZE      64
1708 +#define        XFS_STRAT_KTRACE_SIZE   64
1709 +#define        XFS_STRAT_GTRACE_SIZE   512
1710 +
1711 +#define        XFS_READ_ENTER          1
1712 +#define        XFS_WRITE_ENTER         2
1713  #define XFS_IOMAP_READ_ENTER   3
1714 +#define        XFS_IOMAP_WRITE_ENTER   4
1715 +#define        XFS_IOMAP_READ_MAP      5
1716 +#define        XFS_IOMAP_WRITE_MAP     6
1717 +#define        XFS_IOMAP_WRITE_NOSPACE 7
1718 +#define        XFS_ITRUNC_START        8
1719 +#define        XFS_ITRUNC_FINISH1      9
1720 +#define        XFS_ITRUNC_FINISH2      10
1721 +#define        XFS_CTRUNC1             11
1722 +#define        XFS_CTRUNC2             12
1723 +#define        XFS_CTRUNC3             13
1724 +#define        XFS_CTRUNC4             14
1725 +#define        XFS_CTRUNC5             15
1726 +#define        XFS_CTRUNC6             16
1727 +#define        XFS_BUNMAPI             17
1728 +#define        XFS_INVAL_CACHED        18
1729 +#define        XFS_DIORD_ENTER         19
1730 +#define        XFS_DIOWR_ENTER         20
1731 +extern void xfs_rw_enter_trace(int, struct xfs_iocore *,
1732 +                       const struct iovec *, size_t, loff_t, int);
1733 +extern void xfs_inval_cached_trace(struct xfs_iocore *,
1734 +                       xfs_off_t, xfs_off_t, xfs_off_t, xfs_off_t);
1735 +#else
1736 +#define xfs_rw_enter_trace(tag, io, iovec, segs, offset, ioflags)
1737 +#define xfs_inval_cached_trace(io, offset, len, first, last)
1738 +#endif
1739 +
1740  /*
1741   * Maximum count of bmaps used by read and write paths.
1742   */
1743  #define        XFS_MAX_RW_NBMAPS       4
1744  
1745  extern int xfs_bmap(struct bhv_desc *, xfs_off_t, ssize_t, int,
1746 -                       struct page_buf_bmap_s *, int *);
1747 +                       struct xfs_iomap *, int *);
1748  extern int xfsbdstrat(struct xfs_mount *, struct page_buf_s *);
1749  extern int xfs_bdstrat_cb(struct page_buf_s *);
1750  
1751  extern int xfs_zero_eof(struct vnode *, struct xfs_iocore *, xfs_off_t,
1752                                 xfs_fsize_t, xfs_fsize_t);
1753 +extern void xfs_inval_cached_pages(struct vnode        *, struct xfs_iocore *,
1754 +                               xfs_off_t, int, int);
1755  extern ssize_t xfs_read(struct bhv_desc *, struct kiocb *,
1756                                 const struct iovec *, unsigned int,
1757                                 loff_t *, int, struct cred *);
1758 @@ -64,16 +102,6 @@
1759                                 loff_t *, int, size_t, read_actor_t,
1760                                 void *, struct cred *);
1761  
1762 -extern int xfs_iomap(struct xfs_iocore *, xfs_off_t, ssize_t, int,
1763 -                               struct page_buf_bmap_s *, int *);
1764 -extern int xfs_iomap_write_direct(struct xfs_inode *, loff_t, size_t,
1765 -                               int, struct xfs_bmbt_irec *, int *, int);
1766 -extern int xfs_iomap_write_delay(struct xfs_inode *, loff_t, size_t,
1767 -                               int, struct xfs_bmbt_irec *, int *);
1768 -extern int xfs_iomap_write_allocate(struct xfs_inode *,
1769 -                               struct xfs_bmbt_irec *, int *);
1770 -extern int xfs_iomap_write_unwritten(struct xfs_inode *, loff_t, size_t);
1771 -
1772  extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
1773  
1774  #define XFS_FSB_TO_DB_IO(io,fsb) \
1775 diff -urN linux.org/fs/xfs/linux/xfs_super.c linux/fs/xfs/linux/xfs_super.c
1776 --- linux.org/fs/xfs/linux/xfs_super.c  2003-12-31 05:48:23.000000000 +0100
1777 +++ linux/fs/xfs/linux/xfs_super.c      2004-01-02 04:21:43.000000000 +0100
1778 @@ -120,7 +120,7 @@
1779          */
1780  
1781  #if BITS_PER_LONG == 32
1782 -# if defined(HAVE_SECTOR_T)
1783 +# if defined(CONFIG_LBD)
1784         ASSERT(sizeof(sector_t) == 8);
1785         pagefactor = PAGE_CACHE_SIZE;
1786         bitshift = BITS_PER_LONG;
1787 @@ -241,6 +241,36 @@
1788         }
1789  }
1790  
1791 +struct inode *
1792 +xfs_get_inode(
1793 +       bhv_desc_t      *bdp,
1794 +       xfs_ino_t       ino,
1795 +       int             flags)
1796 +{
1797 +       struct vfs      *vfsp = bhvtovfs(bdp);
1798 +
1799 +       if (flags & IGET_NOALLOC)
1800 +               return ilookup(vfsp->vfs_super, ino);
1801 +       return iget_locked(vfsp->vfs_super, ino);
1802 +}
1803 +
1804 +void
1805 +xfs_flush_inode(
1806 +       xfs_inode_t     *ip)
1807 +{
1808 +       struct inode    *inode = LINVFS_GET_IP(XFS_ITOV(ip));
1809 +
1810 +       filemap_fdatawrite(inode->i_mapping);
1811 +}
1812 +
1813 +void
1814 +xfs_flush_device(
1815 +       xfs_inode_t     *ip)
1816 +{
1817 +       sync_blockdev(XFS_ITOV(ip)->v_vfsp->vfs_super->s_bdev);
1818 +       xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
1819 +}
1820 +
1821  int
1822  xfs_blkdev_get(
1823         xfs_mount_t             *mp,
1824 @@ -860,15 +890,16 @@
1825  {
1826         int                     error;
1827         struct sysinfo          si;
1828 -       static char             message[] __initdata =
1829 -               KERN_INFO "SGI XFS " XFS_VERSION_STRING " with "
1830 -               XFS_BUILD_OPTIONS " enabled\n";
1831 +       static char             message[] __initdata = KERN_INFO \
1832 +               XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled\n";
1833  
1834         printk(message);
1835  
1836         si_meminfo(&si);
1837         xfs_physmem = si.totalram;
1838  
1839 +       ktrace_init(64);
1840 +
1841         error = init_inodecache();
1842         if (error < 0)
1843                 goto undo_inodecache;
1844 @@ -907,12 +938,12 @@
1845         vfs_exitdmapi();
1846         pagebuf_terminate();
1847         destroy_inodecache();
1848 +       ktrace_uninit();
1849  }
1850  
1851  module_init(init_xfs_fs);
1852  module_exit(exit_xfs_fs);
1853  
1854  MODULE_AUTHOR("Silicon Graphics, Inc.");
1855 -MODULE_DESCRIPTION(
1856 -       "SGI XFS " XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
1857 +MODULE_DESCRIPTION(XFS_VERSION_STRING " with " XFS_BUILD_OPTIONS " enabled");
1858  MODULE_LICENSE("GPL");
1859 diff -urN linux.org/fs/xfs/linux/xfs_super.h linux/fs/xfs/linux/xfs_super.h
1860 --- linux.org/fs/xfs/linux/xfs_super.h  2003-12-31 05:46:52.000000000 +0100
1861 +++ linux/fs/xfs/linux/xfs_super.h      2004-01-02 04:21:43.000000000 +0100
1862 @@ -76,10 +76,10 @@
1863  # define XFS_BIGFS_STRING
1864  #endif
1865  
1866 -#ifdef CONFIG_XFS_VNODE_TRACING
1867 -# define XFS_VNTRACE_STRING    "VN-trace, "
1868 +#ifdef CONFIG_XFS_TRACE
1869 +# define XFS_TRACE_STRING      "tracing, "
1870  #else
1871 -# define XFS_VNTRACE_STRING
1872 +# define XFS_TRACE_STRING
1873  #endif
1874  
1875  #ifdef XFSDEBUG
1876 @@ -91,7 +91,7 @@
1877  #define XFS_BUILD_OPTIONS      XFS_ACL_STRING \
1878                                 XFS_REALTIME_STRING \
1879                                 XFS_BIGFS_STRING \
1880 -                               XFS_VNTRACE_STRING \
1881 +                               XFS_TRACE_STRING \
1882                                 XFS_DBG_STRING /* DBG must be last */
1883  
1884  #define LINVFS_GET_VFS(s) \
1885 @@ -99,14 +99,19 @@
1886  #define LINVFS_SET_VFS(s, vfsp) \
1887         ((s)->s_fs_info = vfsp)
1888  
1889 +struct xfs_inode;
1890  struct xfs_mount;
1891  struct pb_target;
1892  struct block_device;
1893  
1894  extern __uint64_t xfs_max_file_offset(unsigned int);
1895  
1896 +extern struct inode *xfs_get_inode(bhv_desc_t *, xfs_ino_t, int);
1897  extern void xfs_initialize_vnode(bhv_desc_t *, vnode_t *, bhv_desc_t *, int);
1898  
1899 +extern void xfs_flush_inode(struct xfs_inode *);
1900 +extern void xfs_flush_device(struct xfs_inode *);
1901 +
1902  extern int  xfs_blkdev_get(struct xfs_mount *, const char *,
1903                                 struct block_device **);
1904  extern void xfs_blkdev_put(struct block_device *);
1905 diff -urN linux.org/fs/xfs/linux/xfs_sysctl.c linux/fs/xfs/linux/xfs_sysctl.c
1906 --- linux.org/fs/xfs/linux/xfs_sysctl.c 2003-12-31 05:48:56.000000000 +0100
1907 +++ linux/fs/xfs/linux/xfs_sysctl.c     2004-01-02 04:21:44.000000000 +0100
1908 @@ -51,7 +51,7 @@
1909         int             c, ret, *valp = ctl->data;
1910         __uint32_t      vn_active;
1911  
1912 -       ret = proc_doulongvec_minmax(ctl, write, filp, buffer, lenp);
1913 +       ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp);
1914  
1915         if (!ret && write && *valp) {
1916                 printk("XFS Clearing xfsstats\n");
1917 diff -urN linux.org/fs/xfs/linux/xfs_version.h linux/fs/xfs/linux/xfs_version.h
1918 --- linux.org/fs/xfs/linux/xfs_version.h        2003-12-31 05:48:35.000000000 +0100
1919 +++ linux/fs/xfs/linux/xfs_version.h    2004-01-02 04:21:44.000000000 +0100
1920 @@ -39,6 +39,6 @@
1921  #ifndef __XFS_VERSION_H__
1922  #define __XFS_VERSION_H__
1923  
1924 -#define XFS_VERSION_STRING "for Linux"
1925 +#define XFS_VERSION_STRING "SGI-XFS CVS-2004-01-01_06:00_UTC"
1926  
1927  #endif /* __XFS_VERSION_H__ */
1928 diff -urN linux.org/fs/xfs/linux/xfs_vfs.c linux/fs/xfs/linux/xfs_vfs.c
1929 --- linux.org/fs/xfs/linux/xfs_vfs.c    2003-12-31 05:46:21.000000000 +0100
1930 +++ linux/fs/xfs/linux/xfs_vfs.c        2004-01-02 04:21:44.000000000 +0100
1931 @@ -134,7 +134,7 @@
1932  int
1933  vfs_statvfs(
1934         struct bhv_desc         *bdp,
1935 -       struct kstatfs          *sp,
1936 +       xfs_statfs_t            *sp,
1937         struct vnode            *vp)
1938  {
1939         struct bhv_desc         *next = bdp;
1940 @@ -201,6 +201,19 @@
1941         return ((*bhvtovfsops(next)->vfs_quotactl)(next, cmd, id, addr));
1942  }
1943  
1944 +struct inode *
1945 +vfs_get_inode(
1946 +       struct bhv_desc         *bdp,
1947 +       xfs_ino_t               ino,
1948 +       int                     fl)
1949 +{
1950 +       struct bhv_desc         *next = bdp;
1951 +
1952 +       while (! (bhvtovfsops(next))->vfs_get_inode)
1953 +               next = BHV_NEXTNULL(next);
1954 +       return ((*bhvtovfsops(next)->vfs_get_inode)(next, ino, fl));
1955 +}
1956 +
1957  void
1958  vfs_init_vnode(
1959         struct bhv_desc         *bdp,
1960 diff -urN linux.org/fs/xfs/linux/xfs_vfs.h linux/fs/xfs/linux/xfs_vfs.h
1961 --- linux.org/fs/xfs/linux/xfs_vfs.h    2003-12-31 05:46:23.000000000 +0100
1962 +++ linux/fs/xfs/linux/xfs_vfs.h        2004-01-02 04:21:44.000000000 +0100
1963 @@ -33,6 +33,7 @@
1964  #define __XFS_VFS_H__
1965  
1966  #include <linux/vfs.h>
1967 +#include "xfs_fs.h"
1968  
1969  struct fid;
1970  struct cred;
1971 @@ -42,10 +43,12 @@
1972  struct super_block;
1973  struct xfs_mount_args;
1974  
1975 +typedef struct kstatfs xfs_statfs_t;
1976 +
1977  typedef struct vfs {
1978         u_int                   vfs_flag;       /* flags */
1979 -       fsid_t                  vfs_fsid;       /* file system ID */
1980 -       fsid_t                  *vfs_altfsid;   /* An ID fixed for life of FS */
1981 +       xfs_fsid_t              vfs_fsid;       /* file system ID */
1982 +       xfs_fsid_t              *vfs_altfsid;   /* An ID fixed for life of FS */
1983         bhv_head_t              vfs_bh;         /* head of vfs behavior chain */
1984         struct super_block      *vfs_super;     /* Linux superblock structure */
1985         struct task_struct      *vfs_sync_task;
1986 @@ -92,6 +95,8 @@
1987  #define SYNC_REFCACHE          0x0040  /* prune some of the nfs ref cache */
1988  #define SYNC_REMOUNT           0x0080  /* remount readonly, no dummy LRs */
1989  
1990 +#define IGET_NOALLOC           0x0001  /* vfs_get_inode may return NULL */
1991 +
1992  typedef int    (*vfs_mount_t)(bhv_desc_t *,
1993                                 struct xfs_mount_args *, struct cred *);
1994  typedef int    (*vfs_parseargs_t)(bhv_desc_t *, char *,
1995 @@ -101,7 +106,7 @@
1996  typedef int    (*vfs_mntupdate_t)(bhv_desc_t *, int *,
1997                                 struct xfs_mount_args *);
1998  typedef int    (*vfs_root_t)(bhv_desc_t *, struct vnode **);
1999 -typedef int    (*vfs_statvfs_t)(bhv_desc_t *, struct kstatfs *, struct vnode *);
2000 +typedef int    (*vfs_statvfs_t)(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
2001  typedef int    (*vfs_sync_t)(bhv_desc_t *, int, struct cred *);
2002  typedef int    (*vfs_vget_t)(bhv_desc_t *, struct vnode **, struct fid *);
2003  typedef int    (*vfs_dmapiops_t)(bhv_desc_t *, caddr_t);
2004 @@ -109,6 +114,7 @@
2005  typedef void   (*vfs_init_vnode_t)(bhv_desc_t *,
2006                                 struct vnode *, bhv_desc_t *, int);
2007  typedef void   (*vfs_force_shutdown_t)(bhv_desc_t *, int, char *, int);
2008 +typedef        struct inode * (*vfs_get_inode_t)(bhv_desc_t *, xfs_ino_t, int);
2009  
2010  typedef struct vfsops {
2011         bhv_position_t          vf_position;    /* behavior chain position */
2012 @@ -123,6 +129,7 @@
2013         vfs_vget_t              vfs_vget;       /* get vnode from fid */
2014         vfs_dmapiops_t          vfs_dmapiops;   /* data migration */
2015         vfs_quotactl_t          vfs_quotactl;   /* disk quota */
2016 +       vfs_get_inode_t         vfs_get_inode;  /* bhv specific iget */
2017         vfs_init_vnode_t        vfs_init_vnode; /* initialize a new vnode */
2018         vfs_force_shutdown_t    vfs_force_shutdown;     /* crash and burn */
2019  } vfsops_t;
2020 @@ -142,6 +149,7 @@
2021  #define VFS_VGET(v, vpp,fidp, rv)      ((rv) = vfs_vget(VHEAD(v), vpp,fidp))
2022  #define VFS_DMAPIOPS(v, p, rv)         ((rv) = vfs_dmapiops(VHEAD(v), p))
2023  #define VFS_QUOTACTL(v, c,id,p, rv)    ((rv) = vfs_quotactl(VHEAD(v), c,id,p))
2024 +#define VFS_GET_INODE(v, ino, fl)      ( vfs_get_inode(VHEAD(v), ino,fl) )
2025  #define VFS_INIT_VNODE(v, vp,b,ul)     ( vfs_init_vnode(VHEAD(v), vp,b,ul) )
2026  #define VFS_FORCE_SHUTDOWN(v, fl,f,l)  ( vfs_force_shutdown(VHEAD(v), fl,f,l) )
2027  
2028 @@ -159,6 +167,7 @@
2029  #define PVFS_VGET(b, vpp,fidp, rv)     ((rv) = vfs_vget(b, vpp,fidp))
2030  #define PVFS_DMAPIOPS(b, p, rv)                ((rv) = vfs_dmapiops(b, p))
2031  #define PVFS_QUOTACTL(b, c,id,p, rv)   ((rv) = vfs_quotactl(b, c,id,p))
2032 +#define PVFS_GET_INODE(b, ino,fl)      ( vfs_get_inode(b, ino,fl) )
2033  #define PVFS_INIT_VNODE(b, vp,b2,ul)   ( vfs_init_vnode(b, vp,b2,ul) )
2034  #define PVFS_FORCE_SHUTDOWN(b, fl,f,l) ( vfs_force_shutdown(b, fl,f,l) )
2035  
2036 @@ -168,11 +177,12 @@
2037  extern int vfs_unmount(bhv_desc_t *, int, struct cred *);
2038  extern int vfs_mntupdate(bhv_desc_t *, int *, struct xfs_mount_args *);
2039  extern int vfs_root(bhv_desc_t *, struct vnode **);
2040 -extern int vfs_statvfs(bhv_desc_t *, struct kstatfs *, struct vnode *);
2041 +extern int vfs_statvfs(bhv_desc_t *, xfs_statfs_t *, struct vnode *);
2042  extern int vfs_sync(bhv_desc_t *, int, struct cred *);
2043  extern int vfs_vget(bhv_desc_t *, struct vnode **, struct fid *);
2044  extern int vfs_dmapiops(bhv_desc_t *, caddr_t);
2045  extern int vfs_quotactl(bhv_desc_t *, int, int, caddr_t);
2046 +extern struct inode *vfs_get_inode(bhv_desc_t *, xfs_ino_t, int);
2047  extern void vfs_init_vnode(bhv_desc_t *, struct vnode *, bhv_desc_t *, int);
2048  extern void vfs_force_shutdown(bhv_desc_t *, int, char *, int);
2049  
2050 diff -urN linux.org/fs/xfs/linux/xfs_vnode.c linux/fs/xfs/linux/xfs_vnode.c
2051 --- linux.org/fs/xfs/linux/xfs_vnode.c  2003-12-31 05:46:55.000000000 +0100
2052 +++ linux/fs/xfs/linux/xfs_vnode.c      2004-01-02 04:21:44.000000000 +0100
2053 @@ -98,7 +98,7 @@
2054         vp->v_type = VNON;
2055         vp->v_fbhv = NULL;
2056  
2057 -#ifdef CONFIG_XFS_VNODE_TRACING
2058 +#ifdef XFS_VNODE_TRACE
2059         ktrace_free(vp->v_trace);
2060         vp->v_trace = NULL;
2061  #endif
2062 @@ -154,9 +154,10 @@
2063         /* Initialize the first behavior and the behavior chain head. */
2064         vn_bhv_head_init(VN_BHV_HEAD(vp), "vnode");
2065  
2066 -#ifdef CONFIG_XFS_VNODE_TRACING
2067 +#ifdef XFS_VNODE_TRACE
2068         vp->v_trace = ktrace_alloc(VNODE_TRACE_SIZE, KM_SLEEP);
2069 -#endif /* CONFIG_XFS_VNODE_TRACING */
2070 +       printk("Allocated VNODE_TRACE at 0x%p\n", vp->v_trace);
2071 +#endif /* XFS_VNODE_TRACE */
2072  
2073         vn_trace_exit(vp, "vn_initialize", (inst_t *)__return_address);
2074         return vp;
2075 @@ -177,7 +178,7 @@
2076         if (inode->i_state & I_FREEING)
2077                 return NULL;
2078  
2079 -       inode = ilookup(vmap->v_vfsp->vfs_super, vmap->v_ino);
2080 +       inode = VFS_GET_INODE(vmap->v_vfsp, vmap->v_ino, IGET_NOALLOC);
2081         if (!inode)     /* Inode not present */
2082                 return NULL;
2083  
2084 @@ -392,7 +393,7 @@
2085  }
2086  
2087  
2088 -#ifdef CONFIG_XFS_VNODE_TRACING
2089 +#ifdef XFS_VNODE_TRACE
2090  
2091  #define KTRACE_ENTER(vp, vk, s, line, ra)                      \
2092         ktrace_enter(   (vp)->v_trace,                          \
2093 @@ -439,4 +440,4 @@
2094  {
2095         KTRACE_ENTER(vp, VNODE_KTRACE_RELE, file, line, ra);
2096  }
2097 -#endif /* CONFIG_XFS_VNODE_TRACING */
2098 +#endif /* XFS_VNODE_TRACE */
2099 diff -urN linux.org/fs/xfs/linux/xfs_vnode.h linux/fs/xfs/linux/xfs_vnode.h
2100 --- linux.org/fs/xfs/linux/xfs_vnode.h  2003-12-31 05:48:46.000000000 +0100
2101 +++ linux/fs/xfs/linux/xfs_vnode.h      2004-01-02 04:21:44.000000000 +0100
2102 @@ -62,7 +62,7 @@
2103  struct uio;
2104  struct file;
2105  struct vattr;
2106 -struct page_buf_bmap_s;
2107 +struct xfs_iomap;
2108  struct attrlist_cursor_kern;
2109  
2110  /*
2111 @@ -87,7 +87,7 @@
2112         vn_bhv_head_t   v_bh;                   /* behavior head */
2113         spinlock_t      v_lock;                 /* VN_LOCK/VN_UNLOCK */
2114         struct inode    v_inode;                /* Linux inode */
2115 -#ifdef CONFIG_XFS_VNODE_TRACING
2116 +#ifdef XFS_VNODE_TRACE
2117         struct ktrace   *v_trace;               /* trace header structure    */
2118  #endif
2119  } vnode_t;
2120 @@ -225,8 +225,10 @@
2121  typedef int    (*vop_release_t)(bhv_desc_t *);
2122  typedef int    (*vop_rwlock_t)(bhv_desc_t *, vrwlock_t);
2123  typedef void   (*vop_rwunlock_t)(bhv_desc_t *, vrwlock_t);
2124 +typedef        int     (*vop_frlock_t)(bhv_desc_t *, int, struct file_lock *,int,
2125 +                               xfs_off_t, struct cred *);
2126  typedef int    (*vop_bmap_t)(bhv_desc_t *, xfs_off_t, ssize_t, int,
2127 -                               struct page_buf_bmap_s *, int *);
2128 +                               struct xfs_iomap *, int *);
2129  typedef int    (*vop_reclaim_t)(bhv_desc_t *);
2130  typedef int    (*vop_attr_get_t)(bhv_desc_t *, char *, char *, int *, int,
2131                                 struct cred *);
2132 @@ -269,6 +271,7 @@
2133         vop_fid2_t              vop_fid2;
2134         vop_rwlock_t            vop_rwlock;
2135         vop_rwunlock_t          vop_rwunlock;
2136 +       vop_frlock_t            vop_frlock;
2137         vop_bmap_t              vop_bmap;
2138         vop_reclaim_t           vop_reclaim;
2139         vop_attr_get_t          vop_attr_get;
2140 @@ -381,6 +384,7 @@
2141   */
2142  #define IO_ISDIRECT    0x00004         /* bypass page cache */
2143  #define IO_INVIS       0x00020         /* don't update inode timestamps */
2144 +#define IO_ISLOCKED    0x00800         /* don't do inode locking */
2145  
2146  /*
2147   * Flags for VOP_IFLUSH call
2148 @@ -545,21 +549,17 @@
2149  extern vnode_t *vn_hold(struct vnode *);
2150  extern void    vn_rele(struct vnode *);
2151  
2152 -#if defined(CONFIG_XFS_VNODE_TRACING)
2153 -
2154 +#if defined(XFS_VNODE_TRACE)
2155  #define VN_HOLD(vp)            \
2156 -       ((void)vn_hold(vp), \
2157 +       ((void)vn_hold(vp),     \
2158           vn_trace_hold(vp, __FILE__, __LINE__, (inst_t *)__return_address))
2159  #define VN_RELE(vp)            \
2160           (vn_trace_rele(vp, __FILE__, __LINE__, (inst_t *)__return_address), \
2161            iput(LINVFS_GET_IP(vp)))
2162 -
2163 -#else  /* ! (defined(CONFIG_XFS_VNODE_TRACING)) */
2164 -
2165 +#else
2166  #define VN_HOLD(vp)            ((void)vn_hold(vp))
2167  #define VN_RELE(vp)            (iput(LINVFS_GET_IP(vp)))
2168 -
2169 -#endif /* ! (defined(CONFIG_XFS_VNODE_TRACING)) */
2170 +#endif
2171  
2172  /*
2173   * Vname handling macros.
2174 @@ -591,6 +591,13 @@
2175  }
2176  
2177  /*
2178 + * Update modify/access/change times on the vnode
2179 + */
2180 +#define VN_MTIMESET(vp, tvp)   (LINVFS_GET_IP(vp)->i_mtime = *(tvp))
2181 +#define VN_ATIMESET(vp, tvp)   (LINVFS_GET_IP(vp)->i_atime = *(tvp))
2182 +#define VN_CTIMESET(vp, tvp)   (LINVFS_GET_IP(vp)->i_ctime = *(tvp))
2183 +
2184 +/*
2185   * Some useful predicates.
2186   */
2187  #define VN_MAPPED(vp)  \
2188 @@ -617,13 +624,12 @@
2189  #define FSYNC_INVAL    0x2     /* flush and invalidate cached data */
2190  #define FSYNC_DATA     0x4     /* synchronous fsync of data only */
2191  
2192 -#if (defined(CONFIG_XFS_VNODE_TRACING))
2193 -
2194 -#define        VNODE_TRACE_SIZE        16              /* number of trace entries */
2195 -
2196  /*
2197 - * Tracing entries.
2198 + * Tracking vnode activity.
2199   */
2200 +#if defined(XFS_VNODE_TRACE)
2201 +
2202 +#define        VNODE_TRACE_SIZE        16              /* number of trace entries */
2203  #define        VNODE_KTRACE_ENTRY      1
2204  #define        VNODE_KTRACE_EXIT       2
2205  #define        VNODE_KTRACE_HOLD       3
2206 @@ -635,18 +641,16 @@
2207  extern void vn_trace_hold(struct vnode *, char *, int, inst_t *);
2208  extern void vn_trace_ref(struct vnode *, char *, int, inst_t *);
2209  extern void vn_trace_rele(struct vnode *, char *, int, inst_t *);
2210 +
2211  #define        VN_TRACE(vp)            \
2212         vn_trace_ref(vp, __FILE__, __LINE__, (inst_t *)__return_address)
2213 -
2214 -#else  /* ! (defined(CONFIG_XFS_VNODE_TRACING)) */
2215 -
2216 +#else
2217  #define        vn_trace_entry(a,b,c)
2218  #define        vn_trace_exit(a,b,c)
2219  #define        vn_trace_hold(a,b,c,d)
2220  #define        vn_trace_ref(a,b,c,d)
2221  #define        vn_trace_rele(a,b,c,d)
2222  #define        VN_TRACE(vp)
2223 -
2224 -#endif /* ! (defined(CONFIG_XFS_VNODE_TRACING)) */
2225 +#endif
2226  
2227  #endif /* __XFS_VNODE_H__ */
2228 diff -urN linux.org/fs/xfs/Makefile linux/fs/xfs/Makefile
2229 --- linux.org/fs/xfs/Makefile   2003-12-31 05:47:58.000000000 +0100
2230 +++ linux/fs/xfs/Makefile       2004-01-02 04:21:42.000000000 +0100
2231 @@ -34,13 +34,45 @@
2232  
2233  ifeq ($(CONFIG_XFS_DEBUG),y)
2234         EXTRA_CFLAGS += -g -DSTATIC="" -DDEBUG -DXFSDEBUG
2235 +       EXTRA_CFLAGS += -DPAGEBUF_LOCK_TRACKING
2236  endif
2237 -ifeq ($(CONFIG_PAGEBUF_DEBUG),y)
2238 +ifeq ($(CONFIG_XFS_TRACE),y)
2239 +       EXTRA_CFLAGS += -DXFS_ALLOC_TRACE
2240 +       EXTRA_CFLAGS += -DXFS_ATTR_TRACE
2241 +       EXTRA_CFLAGS += -DXFS_BLI_TRACE
2242 +       EXTRA_CFLAGS += -DXFS_BMAP_TRACE
2243 +       EXTRA_CFLAGS += -DXFS_BMBT_TRACE
2244 +       EXTRA_CFLAGS += -DXFS_DIR_TRACE
2245 +       EXTRA_CFLAGS += -DXFS_DIR2_TRACE
2246 +       EXTRA_CFLAGS += -DXFS_DQUOT_TRACE
2247 +       EXTRA_CFLAGS += -DXFS_ILOCK_TRACE
2248 +       EXTRA_CFLAGS += -DXFS_LOG_TRACE
2249 +       EXTRA_CFLAGS += -DXFS_RW_TRACE
2250         EXTRA_CFLAGS += -DPAGEBUF_TRACE
2251 +       # EXTRA_CFLAGS += -DXFS_VNODE_TRACE
2252  endif
2253  
2254  obj-$(CONFIG_XFS_FS)           += xfs.o
2255  
2256 +
2257 +
2258 +
2259 +
2260 +
2261 +
2262 +
2263 +
2264 +
2265 +
2266 +
2267 +
2268 +
2269 +
2270 +
2271 +
2272 +ifneq ($(CONFIG_XFS_DMAPI),y)
2273 +xfs-y                          += xfs_dmops.o
2274 +endif
2275  
2276  xfs-$(CONFIG_XFS_QUOTA)                += $(addprefix quota/, \
2277                                    xfs_dquot.o \
2278 @@ -49,9 +81,10 @@
2279                                    xfs_qm_syscalls.o \
2280                                    xfs_qm_bhv.o \
2281                                    xfs_qm.o)
2282 -
2283  ifeq ($(CONFIG_XFS_QUOTA),y)
2284  xfs-$(CONFIG_PROC_FS)          += quota/xfs_qm_stats.o
2285 +else
2286 +xfs-y                          += xfs_qmops.o
2287  endif
2288  
2289  xfs-$(CONFIG_XFS_RT)           += xfs_rtalloc.o
2290 @@ -79,7 +112,6 @@
2291                                    xfs_dir2_leaf.o \
2292                                    xfs_dir2_node.o \
2293                                    xfs_dir2_sf.o \
2294 -                                  xfs_dir2_trace.o \
2295                                    xfs_dir_leaf.o \
2296                                    xfs_error.o \
2297                                    xfs_extfree_item.o \
2298 @@ -108,10 +140,10 @@
2299                                    xfs_vnodeops.o \
2300                                    xfs_rw.o
2301  
2302 +xfs-$(CONFIG_XFS_TRACE)                += xfs_dir2_trace.o
2303 +
2304  # Objects in pagebuf/
2305 -xfs-y                          += $(addprefix pagebuf/, \
2306 -                                  page_buf.o \
2307 -                                  page_buf_locking.o)
2308 +xfs-y                          += pagebuf/page_buf.o
2309  
2310  # Objects in linux/
2311  xfs-y                          += $(addprefix linux/, \
2312 @@ -131,15 +163,12 @@
2313  # Objects in support/
2314  xfs-y                          += $(addprefix support/, \
2315                                    debug.o \
2316 -                                  ktrace.o \
2317                                    move.o \
2318                                    mrlock.o \
2319                                    qsort.o \
2320                                    uuid.o)
2321  
2322 -# Quota and DMAPI stubs
2323 -xfs-y                          += xfs_dmops.o \
2324 -                                  xfs_qmops.o
2325 +xfs-$(CONFIG_XFS_TRACE)                += support/ktrace.o
2326  
2327  # If both xfs and kdb modules are built in then xfsidbg is built in.  If xfs is
2328  # a module and kdb modules are being compiled then xfsidbg must be a module, to
2329 diff -urN linux.org/fs/xfs/pagebuf/page_buf.c linux/fs/xfs/pagebuf/page_buf.c
2330 --- linux.org/fs/xfs/pagebuf/page_buf.c 2003-12-31 05:46:24.000000000 +0100
2331 +++ linux/fs/xfs/pagebuf/page_buf.c     2004-01-02 04:21:44.000000000 +0100
2332 @@ -58,11 +58,13 @@
2333  #include <linux/proc_fs.h>
2334  #include <linux/workqueue.h>
2335  #include <linux/suspend.h>
2336 +#include <linux/percpu.h>
2337  
2338 +#include <support/ktrace.h>
2339  #include <support/debug.h>
2340  #include <support/kmem.h>
2341  
2342 -#include "page_buf_internal.h"
2343 +#include "page_buf.h"
2344  
2345  #define BBSHIFT                9
2346  #define BN_ALIGN_MASK  ((1 << (PAGE_CACHE_SHIFT - BBSHIFT)) - 1)
2347 @@ -72,50 +74,7 @@
2348  #endif
2349  
2350  /*
2351 - * Debug code
2352 - */
2353 -
2354 -#ifdef PAGEBUF_TRACE
2355 -static spinlock_t              pb_trace_lock = SPIN_LOCK_UNLOCKED;
2356 -struct pagebuf_trace_buf       pb_trace;
2357 -EXPORT_SYMBOL(pb_trace);
2358 -EXPORT_SYMBOL(pb_trace_func);
2359 -#define CIRC_INC(i)    (((i) + 1) & (PB_TRACE_BUFSIZE - 1))
2360 -
2361 -void
2362 -pb_trace_func(
2363 -       page_buf_t      *pb,
2364 -       int             event,
2365 -       void            *misc,
2366 -       void            *ra)
2367 -{
2368 -       int             j;
2369 -       unsigned long   flags;
2370 -
2371 -       if (!pb_params.debug.val) return;
2372 -
2373 -       if (ra == NULL) ra = (void *)__builtin_return_address(0);
2374 -
2375 -       spin_lock_irqsave(&pb_trace_lock, flags);
2376 -       j = pb_trace.start;
2377 -       pb_trace.start = CIRC_INC(j);
2378 -       spin_unlock_irqrestore(&pb_trace_lock, flags);
2379 -
2380 -       pb_trace.buf[j].pb = (unsigned long) pb;
2381 -       pb_trace.buf[j].event = event;
2382 -       pb_trace.buf[j].flags = pb->pb_flags;
2383 -       pb_trace.buf[j].hold = pb->pb_hold.counter;
2384 -       pb_trace.buf[j].lock_value = pb->pb_sema.count.counter;
2385 -       pb_trace.buf[j].task = (void *)current;
2386 -       pb_trace.buf[j].misc = misc;
2387 -       pb_trace.buf[j].ra = ra;
2388 -       pb_trace.buf[j].offset = pb->pb_file_offset;
2389 -       pb_trace.buf[j].size = pb->pb_buffer_length;
2390 -}
2391 -#endif /* PAGEBUF_TRACE */
2392 -
2393 -/*
2394 - *     File wide globals
2395 + * File wide globals
2396   */
2397  
2398  STATIC kmem_cache_t *pagebuf_cache;
2399 @@ -129,7 +88,20 @@
2400   * /proc/sys/vm/pagebuf
2401   */
2402  
2403 -pagebuf_param_t pb_params = {
2404 +typedef struct pb_sysctl_val {
2405 +       int     min;
2406 +       int     val;
2407 +       int     max;
2408 +} pb_sysctl_val_t;
2409 +
2410 +struct {
2411 +       pb_sysctl_val_t flush_interval; /* interval between runs of the
2412 +                                        * delwri flush daemon.  */
2413 +       pb_sysctl_val_t age_buffer;     /* time for buffer to age before
2414 +                                        * we flush it.  */
2415 +       pb_sysctl_val_t stats_clear;    /* clear the pagebuf stats */
2416 +       pb_sysctl_val_t debug;          /* debug tracing on or off */
2417 +} pb_params = {
2418                           /*    MIN     DFLT    MAX     */
2419         .flush_interval = {     HZ/2,   HZ,     30*HZ   },
2420         .age_buffer     = {     1*HZ,   15*HZ,  300*HZ  },
2421 @@ -137,12 +109,79 @@
2422         .debug          = {     0,      0,      1       },
2423  };
2424  
2425 +enum {
2426 +       PB_FLUSH_INT = 1,
2427 +       PB_FLUSH_AGE = 2,
2428 +       PB_STATS_CLEAR = 3,
2429 +       PB_DEBUG = 4,
2430 +};
2431 +
2432  /*
2433   * Pagebuf statistics variables
2434   */
2435  
2436 +struct pbstats {
2437 +       u_int32_t       pb_get;
2438 +       u_int32_t       pb_create;
2439 +       u_int32_t       pb_get_locked;
2440 +       u_int32_t       pb_get_locked_waited;
2441 +       u_int32_t       pb_busy_locked;
2442 +       u_int32_t       pb_miss_locked;
2443 +       u_int32_t       pb_page_retries;
2444 +       u_int32_t       pb_page_found;
2445 +       u_int32_t       pb_get_read;
2446 +} pbstats;
2447  DEFINE_PER_CPU(struct pbstats, pbstats);
2448  
2449 +/* We don't disable preempt, not too worried about poking the
2450 + * wrong cpu's stat for now */
2451 +#define PB_STATS_INC(count)    (__get_cpu_var(pbstats).count++)
2452 +
2453 +/*
2454 + * Pagebuf debugging
2455 + */
2456 +
2457 +#ifdef PAGEBUF_TRACE
2458 +void
2459 +pagebuf_trace(
2460 +       page_buf_t      *pb,
2461 +       char            *id,
2462 +       void            *data,
2463 +       void            *ra)
2464 +{
2465 +       if (!pb_params.debug.val)
2466 +               return;
2467 +       ktrace_enter(pagebuf_trace_buf,
2468 +               pb, id,
2469 +               (void *)(unsigned long)pb->pb_flags,
2470 +               (void *)(unsigned long)pb->pb_hold.counter,
2471 +               (void *)(unsigned long)pb->pb_sema.count.counter,
2472 +               (void *)current,
2473 +               data, ra,
2474 +               (void *)(unsigned long)((pb->pb_file_offset>>32) & 0xffffffff),
2475 +               (void *)(unsigned long)(pb->pb_file_offset & 0xffffffff),
2476 +               (void *)(unsigned long)pb->pb_buffer_length,
2477 +               NULL, NULL, NULL, NULL, NULL);
2478 +}
2479 +ktrace_t *pagebuf_trace_buf;
2480 +EXPORT_SYMBOL(pagebuf_trace_buf);
2481 +#define PAGEBUF_TRACE_SIZE     4096
2482 +#define PB_TRACE(pb, id, data) \
2483 +       pagebuf_trace(pb, id, (void *)data, (void *)__builtin_return_address(0))
2484 +#else
2485 +#define PB_TRACE(pb, id, data) do { } while (0)
2486 +#endif
2487 +
2488 +#ifdef PAGEBUF_LOCK_TRACKING
2489 +# define PB_SET_OWNER(pb)      ((pb)->pb_last_holder = current->pid)
2490 +# define PB_CLEAR_OWNER(pb)    ((pb)->pb_last_holder = -1)
2491 +# define PB_GET_OWNER(pb)      ((pb)->pb_last_holder)
2492 +#else
2493 +# define PB_SET_OWNER(pb)      do { } while (0)
2494 +# define PB_CLEAR_OWNER(pb)    do { } while (0)
2495 +# define PB_GET_OWNER(pb)      do { } while (0)
2496 +#endif
2497 +
2498  /*
2499   * Pagebuf allocation / freeing.
2500   */
2501 @@ -198,11 +237,11 @@
2502         void            *vm_addr;
2503         struct a_list   *next;
2504  } a_list_t;
2505 +
2506  STATIC a_list_t                *as_free_head;
2507  STATIC int             as_list_len;
2508  STATIC spinlock_t      as_lock = SPIN_LOCK_UNLOCKED;
2509  
2510 -
2511  /*
2512   * Try to batch vunmaps because they are costly.
2513   */
2514 @@ -247,16 +286,6 @@
2515  }
2516  
2517  /*
2518 - *     Locking model:
2519 - *
2520 - *     Buffers associated with inodes for which buffer locking
2521 - *     is not enabled are not protected by semaphores, and are
2522 - *     assumed to be exclusively owned by the caller.  There is
2523 - *     spinlock in the buffer, for use by the caller when concurrent
2524 - *     access is possible.
2525 - */
2526 -
2527 -/*
2528   *     Internal pagebuf object manipulation
2529   */
2530  
2531 @@ -294,7 +323,7 @@
2532         init_waitqueue_head(&pb->pb_waiters);
2533  
2534         PB_STATS_INC(pb_create);
2535 -       PB_TRACE(pb, PB_TRACE_REC(get), target);
2536 +       PB_TRACE(pb, "initialize", target);
2537  }
2538  
2539  /*
2540 @@ -343,9 +372,6 @@
2541                         page_cache_release(page);
2542                 }
2543         }
2544 -
2545 -       if (pb->pb_pages != pb->pb_page_array)
2546 -               kfree(pb->pb_pages);
2547  }
2548  
2549  /*
2550 @@ -361,7 +387,7 @@
2551  {
2552         page_buf_flags_t        pb_flags = pb->pb_flags;
2553  
2554 -       PB_TRACE(pb, PB_TRACE_REC(free_obj), 0);
2555 +       PB_TRACE(pb, "free_object", 0);
2556         pb->pb_flags |= PBF_FREED;
2557  
2558         if (hash) {
2559 @@ -384,20 +410,17 @@
2560                 if (pb->pb_flags & _PBF_MEM_ALLOCATED) {
2561                         if (pb->pb_pages) {
2562                                 /* release the pages in the address list */
2563 -                               if (pb->pb_pages[0] &&
2564 -                                   PageSlab(pb->pb_pages[0])) {
2565 -                                       /*
2566 -                                        * This came from the slab
2567 -                                        * allocator free it as such
2568 -                                        */
2569 +                               if ((pb->pb_pages[0]) &&
2570 +                                   (pb->pb_flags & _PBF_MEM_SLAB)) {
2571                                         kfree(pb->pb_addr);
2572                                 } else {
2573                                         _pagebuf_freepages(pb);
2574                                 }
2575 -
2576 +                               if (pb->pb_pages != pb->pb_page_array)
2577 +                                       kfree(pb->pb_pages);
2578                                 pb->pb_pages = NULL;
2579                         }
2580 -                       pb->pb_flags &= ~_PBF_MEM_ALLOCATED;
2581 +                       pb->pb_flags &= ~(_PBF_MEM_ALLOCATED|_PBF_MEM_SLAB);
2582                 }
2583         }
2584  
2585 @@ -572,7 +595,7 @@
2586                 }
2587         }
2588  
2589 -       PB_TRACE(pb, PB_TRACE_REC(look_pg), good_pages);
2590 +       PB_TRACE(pb, "lookup_pages", (long)good_pages);
2591  
2592         return rval;
2593  }
2594 @@ -663,7 +686,7 @@
2595         if (not_locked) {
2596                 if (!(flags & PBF_TRYLOCK)) {
2597                         /* wait for buffer ownership */
2598 -                       PB_TRACE(pb, PB_TRACE_REC(get_lk), 0);
2599 +                       PB_TRACE(pb, "get_lock", 0);
2600                         pagebuf_lock(pb);
2601                         PB_STATS_INC(pb_get_locked_waited);
2602                 } else {
2603 @@ -689,8 +712,9 @@
2604                                 _PBF_LOCKABLE | \
2605                                 _PBF_ALL_PAGES_MAPPED | \
2606                                 _PBF_ADDR_ALLOCATED | \
2607 -                               _PBF_MEM_ALLOCATED;
2608 -       PB_TRACE(pb, PB_TRACE_REC(got_lk), 0);
2609 +                               _PBF_MEM_ALLOCATED | \
2610 +                               _PBF_MEM_SLAB;
2611 +       PB_TRACE(pb, "got_lock", 0);
2612         PB_STATS_INC(pb_get_locked);
2613         return (pb);
2614  }
2615 @@ -765,10 +789,11 @@
2616  
2617         if (flags & PBF_READ) {
2618                 if (PBF_NOT_DONE(pb)) {
2619 -                       PB_TRACE(pb, PB_TRACE_REC(get_read), flags);
2620 +                       PB_TRACE(pb, "get_read", (unsigned long)flags);
2621                         PB_STATS_INC(pb_get_read);
2622                         pagebuf_iostart(pb, flags);
2623                 } else if (flags & PBF_ASYNC) {
2624 +                       PB_TRACE(pb, "get_read_async", (unsigned long)flags);
2625                         /*
2626                          * Read ahead call which is already satisfied,
2627                          * drop the buffer
2628 @@ -778,12 +803,13 @@
2629                         pagebuf_rele(pb);
2630                         return NULL;
2631                 } else {
2632 +                       PB_TRACE(pb, "get_read_done", (unsigned long)flags);
2633                         /* We do not want read in the flags */
2634                         pb->pb_flags &= ~PBF_READ;
2635                 }
2636 +       } else {
2637 +               PB_TRACE(pb, "get_write", (unsigned long)flags);
2638         }
2639 -
2640 -       PB_TRACE(pb, PB_TRACE_REC(get_obj), flags);
2641         return (pb);
2642  }
2643  
2644 @@ -916,8 +942,8 @@
2645         page_buf_t              *pb;
2646         size_t                  tlen = 0;
2647  
2648 -       if (len > 0x20000)
2649 -               return(NULL);
2650 +       if (unlikely(len > 0x20000))
2651 +               return NULL;
2652  
2653         pb = pagebuf_allocate(flags);
2654         if (!pb)
2655 @@ -944,11 +970,11 @@
2656                 return NULL;
2657         }
2658         /* otherwise pagebuf_free just ignores it */
2659 -       pb->pb_flags |= _PBF_MEM_ALLOCATED;
2660 +       pb->pb_flags |= (_PBF_MEM_ALLOCATED | _PBF_MEM_SLAB);
2661         PB_CLEAR_OWNER(pb);
2662         up(&pb->pb_sema);       /* Return unlocked pagebuf */
2663  
2664 -       PB_TRACE(pb, PB_TRACE_REC(no_daddr), rmem);
2665 +       PB_TRACE(pb, "no_daddr", rmem);
2666  
2667         return pb;
2668  }
2669 @@ -967,7 +993,7 @@
2670         page_buf_t              *pb)
2671  {
2672         atomic_inc(&pb->pb_hold);
2673 -       PB_TRACE(pb, PB_TRACE_REC(hold), 0);
2674 +       PB_TRACE(pb, "hold", 0);
2675  }
2676  
2677  /*
2678 @@ -1002,7 +1028,7 @@
2679  {
2680         pb_hash_t               *h;
2681  
2682 -       PB_TRACE(pb, PB_TRACE_REC(rele), pb->pb_relse);
2683 +       PB_TRACE(pb, "rele", pb->pb_relse);
2684         if (pb->pb_flags & _PBF_LOCKABLE) {
2685                 h = pb_hash(pb);
2686                 spin_lock(&h->pb_hash_lock);
2687 @@ -1043,6 +1069,95 @@
2688  
2689  
2690  /*
2691 + *     Mutual exclusion on buffers.  Locking model:
2692 + *
2693 + *     Buffers associated with inodes for which buffer locking
2694 + *     is not enabled are not protected by semaphores, and are
2695 + *     assumed to be exclusively owned by the caller.  There is a
2696 + *     spinlock in the buffer, used by the caller when concurrent
2697 + *     access is possible.
2698 + */
2699 +
2700 +/*
2701 + *     pagebuf_cond_lock
2702 + *
2703 + *     pagebuf_cond_lock locks a buffer object, if it is not already locked.
2704 + *     Note that this in no way
2705 + *     locks the underlying pages, so it is only useful for synchronizing
2706 + *     concurrent use of page buffer objects, not for synchronizing independent
2707 + *     access to the underlying pages.
2708 + */
2709 +int
2710 +pagebuf_cond_lock(                     /* lock buffer, if not locked   */
2711 +                                       /* returns -EBUSY if locked)    */
2712 +       page_buf_t              *pb)
2713 +{
2714 +       int                     locked;
2715 +
2716 +       ASSERT(pb->pb_flags & _PBF_LOCKABLE);
2717 +       locked = down_trylock(&pb->pb_sema) == 0;
2718 +       if (locked) {
2719 +               PB_SET_OWNER(pb);
2720 +       }
2721 +       PB_TRACE(pb, "cond_lock", (long)locked);
2722 +       return(locked ? 0 : -EBUSY);
2723 +}
2724 +
2725 +/*
2726 + *     pagebuf_lock_value
2727 + *
2728 + *     Return lock value for a pagebuf
2729 + */
2730 +int
2731 +pagebuf_lock_value(
2732 +       page_buf_t              *pb)
2733 +{
2734 +       ASSERT(pb->pb_flags & _PBF_LOCKABLE);
2735 +       return(atomic_read(&pb->pb_sema.count));
2736 +}
2737 +
2738 +/*
2739 + *     pagebuf_lock
2740 + *
2741 + *     pagebuf_lock locks a buffer object.  Note that this in no way
2742 + *     locks the underlying pages, so it is only useful for synchronizing
2743 + *     concurrent use of page buffer objects, not for synchronizing independent
2744 + *     access to the underlying pages.
2745 + */
2746 +int
2747 +pagebuf_lock(
2748 +       page_buf_t              *pb)
2749 +{
2750 +       ASSERT(pb->pb_flags & _PBF_LOCKABLE);
2751 +
2752 +       PB_TRACE(pb, "lock", 0);
2753 +       if (atomic_read(&pb->pb_io_remaining))
2754 +               blk_run_queues();
2755 +       down(&pb->pb_sema);
2756 +       PB_SET_OWNER(pb);
2757 +       PB_TRACE(pb, "locked", 0);
2758 +       return 0;
2759 +}
2760 +
2761 +/*
2762 + *     pagebuf_unlock
2763 + *
2764 + *     pagebuf_unlock releases the lock on the buffer object created by
2765 + *     pagebuf_lock or pagebuf_cond_lock (not any
2766 + *     pinning of underlying pages created by pagebuf_pin).
2767 + */
2768 +void
2769 +pagebuf_unlock(                                /* unlock buffer                */
2770 +       page_buf_t              *pb)    /* buffer to unlock             */
2771 +{
2772 +       ASSERT(pb->pb_flags & _PBF_LOCKABLE);
2773 +       PB_CLEAR_OWNER(pb);
2774 +       up(&pb->pb_sema);
2775 +       PB_TRACE(pb, "unlock", 0);
2776 +}
2777 +
2778 +
2779 +/*
2780   *     Pinning Buffer Storage in Memory
2781   */
2782  
2783 @@ -1065,7 +1180,7 @@
2784         page_buf_t              *pb)
2785  {
2786         atomic_inc(&pb->pb_pin_count);
2787 -       PB_TRACE(pb, PB_TRACE_REC(pin), pb->pb_pin_count.counter);
2788 +       PB_TRACE(pb, "pin", (long)pb->pb_pin_count.counter);
2789  }
2790  
2791  /*
2792 @@ -1082,7 +1197,7 @@
2793         if (atomic_dec_and_test(&pb->pb_pin_count)) {
2794                 wake_up_all(&pb->pb_waiters);
2795         }
2796 -       PB_TRACE(pb, PB_TRACE_REC(unpin), pb->pb_pin_count.counter);
2797 +       PB_TRACE(pb, "unpin", (long)pb->pb_pin_count.counter);
2798  }
2799  
2800  int
2801 @@ -1161,7 +1276,7 @@
2802                 pb->pb_flags &= ~(PBF_PARTIAL | PBF_NONE);
2803         }
2804  
2805 -       PB_TRACE(pb, PB_TRACE_REC(done), pb->pb_iodone);
2806 +       PB_TRACE(pb, "iodone", pb->pb_iodone);
2807  
2808         if ((pb->pb_iodone) || (pb->pb_flags & PBF_ASYNC)) {
2809                 if (schedule) {
2810 @@ -1187,7 +1302,7 @@
2811         unsigned int            error)  /* error to store (0 if none)   */
2812  {
2813         pb->pb_error = error;
2814 -       PB_TRACE(pb, PB_TRACE_REC(ioerror), error);
2815 +       PB_TRACE(pb, "ioerror", (unsigned long)error);
2816  }
2817  
2818  /*
2819 @@ -1211,7 +1326,7 @@
2820  {
2821         int                     status = 0;
2822  
2823 -       PB_TRACE(pb, PB_TRACE_REC(iostart), flags);
2824 +       PB_TRACE(pb, "iostart", (unsigned long)flags);
2825  
2826         if (flags & PBF_DELWRI) {
2827                 pb->pb_flags &= ~(PBF_READ | PBF_WRITE | PBF_ASYNC);
2828 @@ -1444,7 +1554,7 @@
2829  pagebuf_iorequest(                     /* start real I/O               */
2830         page_buf_t              *pb)    /* buffer to convey to device   */
2831  {
2832 -       PB_TRACE(pb, PB_TRACE_REC(ioreq), 0);
2833 +       PB_TRACE(pb, "iorequest", 0);
2834  
2835         if (pb->pb_flags & PBF_DELWRI) {
2836                 pagebuf_delwri_queue(pb, 1);
2837 @@ -1480,11 +1590,11 @@
2838  pagebuf_iowait(
2839         page_buf_t              *pb)
2840  {
2841 -       PB_TRACE(pb, PB_TRACE_REC(iowait), 0);
2842 +       PB_TRACE(pb, "iowait", 0);
2843         if (atomic_read(&pb->pb_io_remaining))
2844                 blk_run_queues();
2845         down(&pb->pb_iodonesema);
2846 -       PB_TRACE(pb, PB_TRACE_REC(iowaited), (int)pb->pb_error);
2847 +       PB_TRACE(pb, "iowaited", (long)pb->pb_error);
2848         return pb->pb_error;
2849  }
2850  
2851 @@ -1575,7 +1685,7 @@
2852         page_buf_t              *pb,
2853         int                     unlock)
2854  {
2855 -       PB_TRACE(pb, PB_TRACE_REC(delwri_q), unlock);
2856 +       PB_TRACE(pb, "delwri_q", (long)unlock);
2857         spin_lock(&pbd_delwrite_lock);
2858         /* If already in the queue, dequeue and place at tail */
2859         if (!list_empty(&pb->pb_list)) {
2860 @@ -1598,7 +1708,7 @@
2861  pagebuf_delwri_dequeue(
2862         page_buf_t              *pb)
2863  {
2864 -       PB_TRACE(pb, PB_TRACE_REC(delwri_uq), 0);
2865 +       PB_TRACE(pb, "delwri_uq", 0);
2866         spin_lock(&pbd_delwrite_lock);
2867         list_del_init(&pb->pb_list);
2868         pb->pb_flags &= ~PBF_DELWRI;
2869 @@ -1665,7 +1775,7 @@
2870                 list_for_each_safe(curr, next, &pbd_delwrite_queue) {
2871                         pb = list_entry(curr, page_buf_t, pb_list);
2872  
2873 -                       PB_TRACE(pb, PB_TRACE_REC(walkq1), pagebuf_ispin(pb));
2874 +                       PB_TRACE(pb, "walkq1", (long)pagebuf_ispin(pb));
2875  
2876                         if ((pb->pb_flags & PBF_DELWRI) && !pagebuf_ispin(pb) &&
2877                             (((pb->pb_flags & _PBF_LOCKABLE) == 0) ||
2878 @@ -1738,7 +1848,7 @@
2879                         continue;
2880                 }
2881  
2882 -               PB_TRACE(pb, PB_TRACE_REC(walkq2), pagebuf_ispin(pb));
2883 +               PB_TRACE(pb, "walkq2", (long)pagebuf_ispin(pb));
2884                 if (pagebuf_ispin(pb)) {
2885                         pincount++;
2886                         continue;
2887 @@ -1839,7 +1949,7 @@
2888         int                     c, ret;
2889         int                     *valp = ctl->data;
2890  
2891 -       ret = proc_doulongvec_minmax(ctl, write, filp, buffer, lenp);
2892 +       ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp);
2893  
2894         if (!ret && write && *valp) {
2895                 printk("XFS Clearing pbstats\n");
2896 @@ -1960,11 +2070,7 @@
2897         }
2898  
2899  #ifdef PAGEBUF_TRACE
2900 -       pb_trace.buf = (pagebuf_trace_t *)kmalloc(
2901 -                       PB_TRACE_BUFSIZE * sizeof(pagebuf_trace_t), GFP_KERNEL);
2902 -       memset(pb_trace.buf, 0, PB_TRACE_BUFSIZE * sizeof(pagebuf_trace_t));
2903 -       pb_trace.start = 0;
2904 -       pb_trace.end = PB_TRACE_BUFSIZE - 1;
2905 +       pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
2906  #endif
2907  
2908         pagebuf_daemon_start();
2909 @@ -1996,3 +2102,6 @@
2910   *     Module management (for kernel debugger module)
2911   */
2912  EXPORT_SYMBOL(pagebuf_offset);
2913 +#ifdef DEBUG
2914 +EXPORT_SYMBOL(pbd_delwrite_queue);
2915 +#endif
2916 diff -urN linux.org/fs/xfs/pagebuf/page_buf.h linux/fs/xfs/pagebuf/page_buf.h
2917 --- linux.org/fs/xfs/pagebuf/page_buf.h 2003-12-31 05:47:38.000000000 +0100
2918 +++ linux/fs/xfs/pagebuf/page_buf.h     2004-01-02 04:21:44.000000000 +0100
2919 @@ -1,5 +1,5 @@
2920  /*
2921 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
2922 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
2923   *
2924   * This program is free software; you can redistribute it and/or modify it
2925   * under the terms of version 2 of the GNU General Public License as
2926 @@ -48,11 +48,6 @@
2927  #include <linux/uio.h>
2928  
2929  /*
2930 - * Turn this on to get pagebuf lock ownership
2931 -#define PAGEBUF_LOCK_TRACKING
2932 -*/
2933 -
2934 -/*
2935   *     Base types
2936   */
2937  
2938 @@ -61,8 +56,6 @@
2939  
2940  #define PAGE_BUF_DADDR_NULL ((page_buf_daddr_t) (-1LL))
2941  
2942 -typedef size_t page_buf_dsize_t;               /* size of buffer in blocks */
2943 -
2944  #define page_buf_ctob(pp)      ((pp) * PAGE_CACHE_SIZE)
2945  #define page_buf_btoc(dd)      (((dd) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT)
2946  #define page_buf_btoct(dd)     ((dd) >> PAGE_CACHE_SHIFT)
2947 @@ -74,29 +67,6 @@
2948         PBRW_ZERO = 3                   /* Zero target memory */
2949  } page_buf_rw_t;
2950  
2951 -typedef enum {                         /* pbm_flags values */
2952 -       PBMF_EOF =              0x01,   /* mapping contains EOF         */
2953 -       PBMF_HOLE =             0x02,   /* mapping covers a hole        */
2954 -       PBMF_DELAY =            0x04,   /* mapping covers delalloc region  */
2955 -       PBMF_UNWRITTEN =        0x20,   /* mapping covers allocated     */
2956 -                                       /* but uninitialized file data  */
2957 -       PBMF_NEW =              0x40    /* just allocated               */
2958 -} bmap_flags_t;
2959 -
2960 -typedef enum {
2961 -       /* base extent manipulation calls */
2962 -       BMAP_READ = (1 << 0),           /* read extents */
2963 -       BMAP_WRITE = (1 << 1),          /* create extents */
2964 -       BMAP_ALLOCATE = (1 << 2),       /* delayed allocate to real extents */
2965 -       BMAP_UNWRITTEN  = (1 << 3),     /* unwritten extents to real extents */
2966 -       /* modifiers */
2967 -       BMAP_IGNSTATE = (1 << 4),       /* ignore unwritten state on read */
2968 -       BMAP_DIRECT = (1 << 5),         /* direct instead of buffered write */
2969 -       BMAP_MMAP = (1 << 6),           /* allocate for mmap write */
2970 -       BMAP_SYNC = (1 << 7),           /* sync write */
2971 -       BMAP_TRYLOCK = (1 << 8),        /* non-blocking request */
2972 -       BMAP_DEVICE = (1 << 9),         /* we only want to know the device */
2973 -} bmapi_flags_t;
2974  
2975  typedef enum page_buf_flags_e {                /* pb_flags values */
2976         PBF_READ = (1 << 0),    /* buffer intended for reading from device */
2977 @@ -123,12 +93,13 @@
2978         _PBF_PRIVATE_BH = (1 << 17), /* do not use public buffer heads     */
2979         _PBF_ALL_PAGES_MAPPED = (1 << 18), /* all pages in range mapped    */
2980         _PBF_ADDR_ALLOCATED = (1 << 19), /* pb_addr space was allocated    */
2981 -       _PBF_MEM_ALLOCATED = (1 << 20), /* pb_mem+underlying pages alloc'd */
2982 +       _PBF_MEM_ALLOCATED = (1 << 20), /* underlying pages are allocated  */
2983 +       _PBF_MEM_SLAB = (1 << 21), /* underlying pages are slab allocated  */
2984  
2985 -       PBF_FORCEIO = (1 << 21),
2986 -       PBF_FLUSH = (1 << 22),  /* flush disk write cache                  */
2987 -       PBF_READ_AHEAD = (1 << 23),
2988 -       PBF_RUN_QUEUES = (1 << 24), /* run block device task queue         */
2989 +       PBF_FORCEIO = (1 << 22), /* ignore any cache state                 */
2990 +       PBF_FLUSH = (1 << 23),  /* flush disk write cache                  */
2991 +       PBF_READ_AHEAD = (1 << 24), /* asynchronous read-ahead             */
2992 +       PBF_RUN_QUEUES = (1 << 25), /* run block device task queue         */
2993  
2994  } page_buf_flags_t;
2995  
2996 @@ -146,36 +117,6 @@
2997  } pb_target_t;
2998  
2999  /*
3000 - *     page_buf_bmap_t:  File system I/O map
3001 - *
3002 - * The pbm_bn, pbm_offset and pbm_length fields are expressed in disk blocks.
3003 - * The pbm_length field specifies the size of the underlying backing store
3004 - * for the particular mapping.
3005 - *
3006 - * The pbm_bsize, pbm_size and pbm_delta fields are in bytes and indicate
3007 - * the size of the mapping, the number of bytes that are valid to access
3008 - * (read or write), and the offset into the mapping, given the offset
3009 - * supplied to the file I/O map routine.  pbm_delta is the offset of the
3010 - * desired data from the beginning of the mapping.
3011 - *
3012 - * When a request is made to read beyond the logical end of the object,
3013 - * pbm_size may be set to 0, but pbm_offset and pbm_length should be set to
3014 - * the actual amount of underlying storage that has been allocated, if any.
3015 - */
3016 -
3017 -typedef struct page_buf_bmap_s {
3018 -       page_buf_daddr_t pbm_bn;        /* block number in file system      */
3019 -       pb_target_t     *pbm_target;    /* device to do I/O to              */
3020 -       loff_t          pbm_offset;     /* byte offset of mapping in file   */
3021 -       size_t          pbm_delta;      /* offset of request into bmap      */
3022 -       size_t          pbm_bsize;      /* size of this mapping in bytes    */
3023 -       bmap_flags_t    pbm_flags;      /* options flags for mapping        */
3024 -} page_buf_bmap_t;
3025 -
3026 -typedef page_buf_bmap_t pb_bmap_t;
3027 -
3028 -
3029 -/*
3030   *     page_buf_t:  Buffer structure for page cache-based buffers
3031   *
3032   * This buffer structure is used by the page cache buffer management routines
3033 @@ -381,4 +322,19 @@
3034  extern int pagebuf_init(void);
3035  extern void pagebuf_terminate(void);
3036  
3037 +
3038 +#ifdef PAGEBUF_TRACE
3039 +extern ktrace_t *pagebuf_trace_buf;
3040 +extern void pagebuf_trace(
3041 +               page_buf_t *,           /* buffer being traced          */
3042 +               char *,                 /* description of operation     */
3043 +               void *,                 /* arbitrary diagnostic value   */
3044 +               void *);                /* return address               */
3045 +#else
3046 +# define pagebuf_trace(pb, id, ptr, ra)        do { } while (0)
3047 +#endif
3048 +
3049 +#define pagebuf_target_name(target)    \
3050 +       ({ char __b[BDEVNAME_SIZE]; bdevname((target)->pbr_bdev, __b); __b; })
3051 +
3052  #endif /* __PAGE_BUF_H__ */
3053 diff -urN linux.org/fs/xfs/pagebuf/page_buf_internal.h linux/fs/xfs/pagebuf/page_buf_internal.h
3054 --- linux.org/fs/xfs/pagebuf/page_buf_internal.h        2003-12-31 05:47:14.000000000 +0100
3055 +++ linux/fs/xfs/pagebuf/page_buf_internal.h    1970-01-01 01:00:00.000000000 +0100
3056 @@ -1,134 +0,0 @@
3057 -/*
3058 - * Copyright (c) 2002 Silicon Graphics, Inc.  All Rights Reserved.
3059 - *
3060 - * This program is free software; you can redistribute it and/or modify it
3061 - * under the terms of version 2 of the GNU General Public License as
3062 - * published by the Free Software Foundation.
3063 - *
3064 - * This program is distributed in the hope that it would be useful, but
3065 - * WITHOUT ANY WARRANTY; without even the implied warranty of
3066 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
3067 - *
3068 - * Further, this software is distributed without any warranty that it is
3069 - * free of the rightful claim of any third person regarding infringement
3070 - * or the like.  Any license provided herein, whether implied or
3071 - * otherwise, applies only to this software file.  Patent licenses, if
3072 - * any, provided herein do not apply to combinations of this program with
3073 - * other software, or any other product whatsoever.
3074 - *
3075 - * You should have received a copy of the GNU General Public License along
3076 - * with this program; if not, write the Free Software Foundation, Inc., 59
3077 - * Temple Place - Suite 330, Boston MA 02111-1307, USA.
3078 - *
3079 - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
3080 - * Mountain View, CA  94043, or:
3081 - *
3082 - * http://www.sgi.com
3083 - *
3084 - * For further information regarding this notice, see:
3085 - *
3086 - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
3087 - */
3088 -
3089 -/*
3090 - * Written by Steve Lord at SGI
3091 - */
3092 -
3093 -#ifndef __PAGE_BUF_PRIVATE_H__
3094 -#define __PAGE_BUF_PRIVATE_H__
3095 -
3096 -#include <linux/percpu.h>
3097 -#include "page_buf.h"
3098 -
3099 -#define _PAGE_BUF_INTERNAL_
3100 -#define PB_DEFINE_TRACES
3101 -#include "page_buf_trace.h"
3102 -
3103 -#ifdef PAGEBUF_LOCK_TRACKING
3104 -#define PB_SET_OWNER(pb)       (pb->pb_last_holder = current->pid)
3105 -#define PB_CLEAR_OWNER(pb)     (pb->pb_last_holder = -1)
3106 -#define PB_GET_OWNER(pb)       (pb->pb_last_holder)
3107 -#else
3108 -#define PB_SET_OWNER(pb)
3109 -#define PB_CLEAR_OWNER(pb)
3110 -#define PB_GET_OWNER(pb)
3111 -#endif /* PAGEBUF_LOCK_TRACKING */
3112 -
3113 -/* Tracing utilities for pagebuf */
3114 -typedef struct {
3115 -       int                     event;
3116 -       unsigned long           pb;
3117 -       page_buf_flags_t        flags;
3118 -       unsigned short          hold;
3119 -       unsigned short          lock_value;
3120 -       void                    *task;
3121 -       void                    *misc;
3122 -       void                    *ra;
3123 -       loff_t                  offset;
3124 -       size_t                  size;
3125 -} pagebuf_trace_t;
3126 -
3127 -struct pagebuf_trace_buf {
3128 -       pagebuf_trace_t         *buf;
3129 -       volatile int            start;
3130 -       volatile int            end;
3131 -};
3132 -
3133 -#define PB_TRACE_BUFSIZE       1024
3134 -#define CIRC_INC(i)     (((i) + 1) & (PB_TRACE_BUFSIZE - 1))
3135 -
3136 -/*
3137 - * Tunable pagebuf parameters
3138 - */
3139 -
3140 -typedef struct pb_sysctl_val {
3141 -       int min;
3142 -       int val;
3143 -       int max;
3144 -} pb_sysctl_val_t;
3145 -
3146 -typedef struct pagebuf_param {
3147 -       pb_sysctl_val_t flush_interval; /* interval between runs of the
3148 -                                        * delwri flush daemon.  */
3149 -       pb_sysctl_val_t age_buffer;     /* time for buffer to age before
3150 -                                        * we flush it.  */
3151 -       pb_sysctl_val_t stats_clear;    /* clear the pagebuf stats */
3152 -       pb_sysctl_val_t debug;          /* debug tracing on or off */
3153 -} pagebuf_param_t;
3154 -
3155 -enum {
3156 -       PB_FLUSH_INT = 1,
3157 -       PB_FLUSH_AGE = 2,
3158 -       PB_STATS_CLEAR = 3,
3159 -       PB_DEBUG = 4
3160 -};
3161 -
3162 -extern pagebuf_param_t pb_params;
3163 -
3164 -/*
3165 - * Pagebuf statistics
3166 - */
3167 -
3168 -struct pbstats {
3169 -       u_int32_t       pb_get;
3170 -       u_int32_t       pb_create;
3171 -       u_int32_t       pb_get_locked;
3172 -       u_int32_t       pb_get_locked_waited;
3173 -       u_int32_t       pb_busy_locked;
3174 -       u_int32_t       pb_miss_locked;
3175 -       u_int32_t       pb_page_retries;
3176 -       u_int32_t       pb_page_found;
3177 -       u_int32_t       pb_get_read;
3178 -};
3179 -
3180 -DECLARE_PER_CPU(struct pbstats, pbstats);
3181 -
3182 -/* We don't disable preempt, not too worried about poking the
3183 - * wrong cpu's stat for now */
3184 -#define PB_STATS_INC(count)    (__get_cpu_var(pbstats).count++)
3185 -
3186 -#ifndef STATIC
3187 -# define STATIC        static
3188 -#endif
3189 -
3190 -#endif /* __PAGE_BUF_PRIVATE_H__ */
3191 diff -urN linux.org/fs/xfs/pagebuf/page_buf_locking.c linux/fs/xfs/pagebuf/page_buf_locking.c
3192 --- linux.org/fs/xfs/pagebuf/page_buf_locking.c 2003-12-31 05:47:32.000000000 +0100
3193 +++ linux/fs/xfs/pagebuf/page_buf_locking.c     1970-01-01 01:00:00.000000000 +0100
3194 @@ -1,139 +0,0 @@
3195 -/*
3196 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
3197 - *
3198 - * This program is free software; you can redistribute it and/or modify it
3199 - * under the terms of version 2 of the GNU General Public License as
3200 - * published by the Free Software Foundation.
3201 - *
3202 - * This program is distributed in the hope that it would be useful, but
3203 - * WITHOUT ANY WARRANTY; without even the implied warranty of
3204 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
3205 - *
3206 - * Further, this software is distributed without any warranty that it is
3207 - * free of the rightful claim of any third person regarding infringement
3208 - * or the like.  Any license provided herein, whether implied or
3209 - * otherwise, applies only to this software file.  Patent licenses, if
3210 - * any, provided herein do not apply to combinations of this program with
3211 - * other software, or any other product whatsoever.
3212 - *
3213 - * You should have received a copy of the GNU General Public License along
3214 - * with this program; if not, write the Free Software Foundation, Inc., 59
3215 - * Temple Place - Suite 330, Boston MA 02111-1307, USA.
3216 - *
3217 - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
3218 - * Mountain View, CA  94043, or:
3219 - *
3220 - * http://www.sgi.com
3221 - *
3222 - * For further information regarding this notice, see:
3223 - *
3224 - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
3225 - */
3226 -
3227 -/*
3228 - *     page_buf_locking.c
3229 - *
3230 - *     The page_buf module provides an abstract buffer cache model on top of
3231 - *     the Linux page cache.  Cached metadata blocks for a file system are
3232 - *     hashed to the inode for the block device.  The page_buf module
3233 - *     assembles buffer (page_buf_t) objects on demand to aggregate such
3234 - *     cached pages for I/O.  The page_buf_locking module adds support for
3235 - *     locking such page buffers.
3236 - *
3237 - *      Written by Steve Lord at SGI
3238 - *
3239 - */
3240 -
3241 -#include <linux/stddef.h>
3242 -#include <linux/errno.h>
3243 -#include <linux/slab.h>
3244 -#include <linux/bitops.h>
3245 -#include <linux/string.h>
3246 -#include <linux/pagemap.h>
3247 -#include <linux/init.h>
3248 -#include <linux/major.h>
3249 -
3250 -#include <support/debug.h>
3251 -
3252 -#include "page_buf_internal.h"
3253 -
3254 -/*
3255 - *     pagebuf_cond_lock
3256 - *
3257 - *     pagebuf_cond_lock locks a buffer object, if it is not already locked.
3258 - *     Note that this in no way
3259 - *     locks the underlying pages, so it is only useful for synchronizing
3260 - *     concurrent use of page buffer objects, not for synchronizing independent
3261 - *     access to the underlying pages.
3262 - */
3263 -int
3264 -pagebuf_cond_lock(                     /* lock buffer, if not locked   */
3265 -                                       /* returns -EBUSY if locked)    */
3266 -       page_buf_t              *pb)
3267 -{
3268 -       int                     locked;
3269 -
3270 -       ASSERT(pb->pb_flags & _PBF_LOCKABLE);
3271 -
3272 -       locked = down_trylock(&pb->pb_sema) == 0;
3273 -       if (locked) {
3274 -               PB_SET_OWNER(pb);
3275 -       }
3276 -
3277 -       PB_TRACE(pb, PB_TRACE_REC(condlck), locked);
3278 -
3279 -       return(locked ? 0 : -EBUSY);
3280 -}
3281 -
3282 -/*
3283 - *     pagebuf_lock_value
3284 - *
3285 - *     Return lock value for a pagebuf
3286 - */
3287 -int
3288 -pagebuf_lock_value(
3289 -       page_buf_t              *pb)
3290 -{
3291 -       ASSERT(pb->pb_flags & _PBF_LOCKABLE);
3292 -       return(atomic_read(&pb->pb_sema.count));
3293 -}
3294 -
3295 -/*
3296 - *     pagebuf_lock
3297 - *
3298 - *     pagebuf_lock locks a buffer object.  Note that this in no way
3299 - *     locks the underlying pages, so it is only useful for synchronizing
3300 - *     concurrent use of page buffer objects, not for synchronizing independent
3301 - *     access to the underlying pages.
3302 - */
3303 -int
3304 -pagebuf_lock(
3305 -       page_buf_t              *pb)
3306 -{
3307 -       ASSERT(pb->pb_flags & _PBF_LOCKABLE);
3308 -
3309 -       PB_TRACE(pb, PB_TRACE_REC(lock), 0);
3310 -       if (atomic_read(&pb->pb_io_remaining))
3311 -               blk_run_queues();
3312 -       down(&pb->pb_sema);
3313 -       PB_SET_OWNER(pb);
3314 -       PB_TRACE(pb, PB_TRACE_REC(locked), 0);
3315 -       return 0;
3316 -}
3317 -
3318 -/*
3319 - *     pagebuf_unlock
3320 - *
3321 - *     pagebuf_unlock releases the lock on the buffer object created by
3322 - *     pagebuf_lock or pagebuf_cond_lock (not any
3323 - *     pinning of underlying pages created by pagebuf_pin).
3324 - */
3325 -void
3326 -pagebuf_unlock(                                /* unlock buffer                */
3327 -       page_buf_t              *pb)    /* buffer to unlock             */
3328 -{
3329 -       ASSERT(pb->pb_flags & _PBF_LOCKABLE);
3330 -       PB_CLEAR_OWNER(pb);
3331 -       up(&pb->pb_sema);
3332 -       PB_TRACE(pb, PB_TRACE_REC(unlock), 0);
3333 -}
3334 diff -urN linux.org/fs/xfs/pagebuf/page_buf_trace.h linux/fs/xfs/pagebuf/page_buf_trace.h
3335 --- linux.org/fs/xfs/pagebuf/page_buf_trace.h   2003-12-31 05:47:37.000000000 +0100
3336 +++ linux/fs/xfs/pagebuf/page_buf_trace.h       1970-01-01 01:00:00.000000000 +0100
3337 @@ -1,95 +0,0 @@
3338 -/*
3339 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
3340 - *
3341 - * This program is free software; you can redistribute it and/or modify it
3342 - * under the terms of version 2 of the GNU General Public License as
3343 - * published by the Free Software Foundation.
3344 - *
3345 - * This program is distributed in the hope that it would be useful, but
3346 - * WITHOUT ANY WARRANTY; without even the implied warranty of
3347 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
3348 - *
3349 - * Further, this software is distributed without any warranty that it is
3350 - * free of the rightful claim of any third person regarding infringement
3351 - * or the like.  Any license provided herein, whether implied or
3352 - * otherwise, applies only to this software file.  Patent licenses, if
3353 - * any, provided herein do not apply to combinations of this program with
3354 - * other software, or any other product whatsoever.
3355 - *
3356 - * You should have received a copy of the GNU General Public License along
3357 - * with this program; if not, write the Free Software Foundation, Inc., 59
3358 - * Temple Place - Suite 330, Boston MA 02111-1307, USA.
3359 - *
3360 - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
3361 - * Mountain View, CA  94043, or:
3362 - *
3363 - * http://www.sgi.com
3364 - *
3365 - * For further information regarding this notice, see:
3366 - *
3367 - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
3368 - */
3369 -
3370 -#ifndef __PAGEBUF_TRACE__
3371 -#define __PAGEBUF_TRACE__
3372 -
3373 -#ifdef PB_DEFINE_TRACES
3374 -#define PB_TRACE_START typedef enum {
3375 -#define PB_TRACE_REC(x)        pb_trace_point_##x
3376 -#define PB_TRACE_END   } pb_trace_var_t;
3377 -#else
3378 -#define PB_TRACE_START static char     *event_names[] = {
3379 -#define PB_TRACE_REC(x)        #x
3380 -#define PB_TRACE_END   };
3381 -#endif
3382 -
3383 -PB_TRACE_START
3384 -PB_TRACE_REC(get),
3385 -PB_TRACE_REC(get_obj),
3386 -PB_TRACE_REC(free_obj),
3387 -PB_TRACE_REC(look_pg),
3388 -PB_TRACE_REC(get_read),
3389 -PB_TRACE_REC(no_daddr),
3390 -PB_TRACE_REC(hold),
3391 -PB_TRACE_REC(rele),
3392 -PB_TRACE_REC(done),
3393 -PB_TRACE_REC(ioerror),
3394 -PB_TRACE_REC(iostart),
3395 -PB_TRACE_REC(end_io),
3396 -PB_TRACE_REC(do_io),
3397 -PB_TRACE_REC(ioreq),
3398 -PB_TRACE_REC(iowait),
3399 -PB_TRACE_REC(iowaited),
3400 -PB_TRACE_REC(free_lk),
3401 -PB_TRACE_REC(freed_l),
3402 -PB_TRACE_REC(cmp),
3403 -PB_TRACE_REC(get_lk),
3404 -PB_TRACE_REC(got_lk),
3405 -PB_TRACE_REC(skip),
3406 -PB_TRACE_REC(lock),
3407 -PB_TRACE_REC(locked),
3408 -PB_TRACE_REC(unlock),
3409 -PB_TRACE_REC(avl_ret),
3410 -PB_TRACE_REC(condlck),
3411 -PB_TRACE_REC(avl_ins),
3412 -PB_TRACE_REC(walkq1),
3413 -PB_TRACE_REC(walkq2),
3414 -PB_TRACE_REC(walkq3),
3415 -PB_TRACE_REC(delwri_q),
3416 -PB_TRACE_REC(delwri_uq),
3417 -PB_TRACE_REC(pin),
3418 -PB_TRACE_REC(unpin),
3419 -PB_TRACE_REC(file_write),
3420 -PB_TRACE_REC(external),
3421 -PB_TRACE_END
3422 -
3423 -extern void pb_trace_func(page_buf_t *, int, void *, void *);
3424 -#ifdef PAGEBUF_TRACE
3425 -# define PB_TRACE(pb, event, misc)             \
3426 -       pb_trace_func(pb, event, (void *) misc, \
3427 -                       (void *)__builtin_return_address(0))
3428 -#else
3429 -# define PB_TRACE(pb, event, misc)     do { } while (0)
3430 -#endif
3431 -
3432 -#endif /* __PAGEBUF_TRACE__ */
3433 diff -urN linux.org/fs/xfs/quota/xfs_dquot.c linux/fs/xfs/quota/xfs_dquot.c
3434 --- linux.org/fs/xfs/quota/xfs_dquot.c  2003-12-31 05:47:13.000000000 +0100
3435 +++ linux/fs/xfs/quota/xfs_dquot.c      2004-01-02 04:21:44.000000000 +0100
3436 @@ -124,7 +124,7 @@
3437                 initnsema(&dqp->q_flock, 1, "fdq");
3438                 sv_init(&dqp->q_pinwait, SV_DEFAULT, "pdq");
3439  
3440 -#ifdef DQUOT_TRACING
3441 +#ifdef XFS_DQUOT_TRACE
3442                 dqp->q_trace = ktrace_alloc(DQUOT_TRACE_SIZE, KM_SLEEP);
3443                 xfs_dqtrace_entry(dqp, "DQINIT");
3444  #endif
3445 @@ -148,7 +148,7 @@
3446                  dqp->q_hash = 0;
3447                  ASSERT(dqp->dq_flnext == dqp->dq_flprev);
3448  
3449 -#ifdef DQUOT_TRACING
3450 +#ifdef XFS_DQUOT_TRACE
3451                  ASSERT(dqp->q_trace);
3452                  xfs_dqtrace_entry(dqp, "DQRECLAIMED_INIT");
3453  #endif
3454 @@ -173,7 +173,7 @@
3455         freesema(&dqp->q_flock);
3456         sv_destroy(&dqp->q_pinwait);
3457  
3458 -#ifdef DQUOT_TRACING
3459 +#ifdef XFS_DQUOT_TRACE
3460         if (dqp->q_trace)
3461              ktrace_free(dqp->q_trace);
3462         dqp->q_trace = NULL;
3463 @@ -201,20 +201,20 @@
3464  }
3465  
3466  
3467 -#ifdef DQUOT_TRACING
3468 +#ifdef XFS_DQUOT_TRACE
3469  /*
3470   * Dquot tracing for debugging.
3471   */
3472  /* ARGSUSED */
3473  void
3474 -xfs_dqtrace_entry__(
3475 -       xfs_dquot_t *dqp,
3476 -       char *func,
3477 -       void *retaddr,
3478 -       xfs_inode_t *ip)
3479 +__xfs_dqtrace_entry(
3480 +       xfs_dquot_t     *dqp,
3481 +       char            *func,
3482 +       void            *retaddr,
3483 +       xfs_inode_t     *ip)
3484  {
3485 -       xfs_dquot_t *udqp = NULL;
3486 -       int ino;
3487 +       xfs_dquot_t     *udqp = NULL;
3488 +       xfs_ino_t       ino = 0;
3489  
3490         ASSERT(dqp->q_trace);
3491         if (ip) {
3492 @@ -227,13 +227,19 @@
3493                      (void *)(__psint_t)dqp->q_nrefs,
3494                      (void *)(__psint_t)dqp->dq_flags,
3495                      (void *)(__psint_t)dqp->q_res_bcount,
3496 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT),
3497 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_icount, ARCH_CONVERT),
3498 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_hardlimit, ARCH_CONVERT),
3499 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT),
3500 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_hardlimit, ARCH_CONVERT),
3501 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT),
3502 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_id, ARCH_CONVERT), /* 11 */
3503 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_bcount,
3504 +                                               ARCH_CONVERT),
3505 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_icount,
3506 +                                               ARCH_CONVERT),
3507 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_hardlimit,
3508 +                                               ARCH_CONVERT),
3509 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_softlimit,
3510 +                                               ARCH_CONVERT),
3511 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_hardlimit,
3512 +                                               ARCH_CONVERT),
3513 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_softlimit,
3514 +                                               ARCH_CONVERT),
3515 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_id, ARCH_CONVERT),
3516                      (void *)(__psint_t)current_pid(),
3517                      (void *)(__psint_t)ino,
3518                      (void *)(__psint_t)retaddr,
3519 @@ -751,7 +757,6 @@
3520         }
3521  
3522         *O_dqpp = dqp;
3523 -       ASSERT(! XFS_DQ_IS_LOCKED(dqp));
3524         return (0);
3525  
3526   error0:
3527 @@ -1000,7 +1005,6 @@
3528         /*
3529          * Dquot lock comes after hashlock in the lock ordering
3530          */
3531 -       ASSERT(! XFS_DQ_IS_LOCKED(dqp));
3532         if (ip) {
3533                 xfs_ilock(ip, XFS_ILOCK_EXCL);
3534                 if (! XFS_IS_DQTYPE_ON(mp, type)) {
3535 @@ -1504,7 +1508,7 @@
3536          */
3537         ASSERT(XFS_DQ_IS_ON_FREELIST(dqp));
3538  
3539 -       dqp->q_mount = NULL;;
3540 +       dqp->q_mount = NULL;
3541         dqp->q_hash = NULL;
3542         dqp->dq_flags = XFS_DQ_INACTIVE;
3543         memset(&dqp->q_core, 0, sizeof(dqp->q_core));
3544 diff -urN linux.org/fs/xfs/quota/xfs_dquot.h linux/fs/xfs/quota/xfs_dquot.h
3545 --- linux.org/fs/xfs/quota/xfs_dquot.h  2003-12-31 05:48:42.000000000 +0100
3546 +++ linux/fs/xfs/quota/xfs_dquot.h      2004-01-02 04:21:44.000000000 +0100
3547 @@ -99,7 +99,7 @@
3548         sema_t           q_flock;       /* flush lock */
3549         uint             q_pincount;    /* pin count for this dquot */
3550         sv_t             q_pinwait;     /* sync var for pinning */
3551 -#ifdef DQUOT_TRACING
3552 +#ifdef XFS_DQUOT_TRACE
3553         struct ktrace   *q_trace;       /* trace header structure */
3554  #endif
3555  } xfs_dquot_t;
3556 @@ -175,23 +175,25 @@
3557  #define XFS_IS_THIS_QUOTA_OFF(d) (! (XFS_QM_ISUDQ(d) ? \
3558                                      (XFS_IS_UQUOTA_ON((d)->q_mount)) : \
3559                                      (XFS_IS_GQUOTA_ON((d)->q_mount))))
3560 -#ifdef DQUOT_TRACING
3561 +
3562 +#ifdef XFS_DQUOT_TRACE
3563  /*
3564   * Dquot Tracing stuff.
3565   */
3566  #define DQUOT_TRACE_SIZE       64
3567  #define DQUOT_KTRACE_ENTRY     1
3568  
3569 +extern void            __xfs_dqtrace_entry(xfs_dquot_t *dqp, char *func,
3570 +                                           void *, xfs_inode_t *);
3571  #define xfs_dqtrace_entry_ino(a,b,ip) \
3572 -xfs_dqtrace_entry__((a), (b), (void*)__return_address, (ip))
3573 +               __xfs_dqtrace_entry((a), (b), (void*)__return_address, (ip))
3574  #define xfs_dqtrace_entry(a,b) \
3575 -xfs_dqtrace_entry__((a), (b), (void*)__return_address, NULL)
3576 -extern void            xfs_dqtrace_entry__(xfs_dquot_t *dqp, char *func,
3577 -                                           void *, xfs_inode_t *);
3578 +               __xfs_dqtrace_entry((a), (b), (void*)__return_address, NULL)
3579  #else
3580  #define xfs_dqtrace_entry(a,b)
3581  #define xfs_dqtrace_entry_ino(a,b,ip)
3582  #endif
3583 +
3584  #ifdef QUOTADEBUG
3585  extern void            xfs_qm_dqprint(xfs_dquot_t *);
3586  #else
3587 diff -urN linux.org/fs/xfs/quota/xfs_qm.c linux/fs/xfs/quota/xfs_qm.c
3588 --- linux.org/fs/xfs/quota/xfs_qm.c     2003-12-31 05:46:24.000000000 +0100
3589 +++ linux/fs/xfs/quota/xfs_qm.c 2004-01-02 04:21:44.000000000 +0100
3590 @@ -82,6 +82,7 @@
3591  
3592  kmem_zone_t    *qm_dqzone;
3593  kmem_zone_t    *qm_dqtrxzone;
3594 +kmem_shaker_t  xfs_qm_shaker;
3595  
3596  STATIC void    xfs_qm_list_init(xfs_dqlist_t *, char *, int);
3597  STATIC void    xfs_qm_list_destroy(xfs_dqlist_t *);
3598 @@ -112,8 +113,6 @@
3599  #define XQM_LIST_PRINT(l, NXT, title) do { } while (0)
3600  #endif
3601  
3602 -struct shrinker *xfs_qm_shrinker;
3603 -
3604  /*
3605   * Initialize the XQM structure.
3606   * Note that there is not one quota manager per file system.
3607 @@ -163,7 +162,7 @@
3608         } else
3609                 xqm->qm_dqzone = qm_dqzone;
3610  
3611 -       xfs_qm_shrinker = set_shrinker(DEFAULT_SEEKS, xfs_qm_shake);
3612 +       xfs_qm_shaker = kmem_shake_register(xfs_qm_shake);
3613  
3614         /*
3615          * The t_dqinfo portion of transactions.
3616 @@ -195,8 +194,7 @@
3617  
3618         ASSERT(xqm != NULL);
3619         ASSERT(xqm->qm_nrefs == 0);
3620 -
3621 -       remove_shrinker(xfs_qm_shrinker);
3622 +       kmem_shake_deregister(xfs_qm_shaker);
3623         hsize = xqm->qm_dqhashmask + 1;
3624         for (i = 0; i < hsize; i++) {
3625                 xfs_qm_list_destroy(&(xqm->qm_usr_dqhtable[i]));
3626 @@ -806,7 +804,6 @@
3627         ASSERT(XFS_DQ_IS_LOCKED(dqp));
3628         if (! dolock) {
3629                 xfs_dqunlock(dqp);
3630 -               ASSERT(!udqhint || !XFS_DQ_IS_LOCKED(udqhint));
3631                 goto done;
3632         }
3633         if (! udqhint)
3634 @@ -814,7 +811,6 @@
3635  
3636         ASSERT(udqhint);
3637         ASSERT(dolock);
3638 -       ASSERT(! XFS_DQ_IS_LOCKED(udqhint));
3639         ASSERT(XFS_DQ_IS_LOCKED(dqp));
3640         if (! xfs_qm_dqlock_nowait(udqhint)) {
3641                 xfs_dqunlock(dqp);
3642 @@ -826,14 +822,10 @@
3643         if (udqhint) {
3644                 if (dolock)
3645                         ASSERT(XFS_DQ_IS_LOCKED(udqhint));
3646 -               else
3647 -                       ASSERT(! XFS_DQ_IS_LOCKED(udqhint));
3648         }
3649         if (! error) {
3650                 if (dolock)
3651                         ASSERT(XFS_DQ_IS_LOCKED(dqp));
3652 -               else
3653 -                       ASSERT(! XFS_DQ_IS_LOCKED(dqp));
3654         }
3655  #endif
3656         return (error);
3657 @@ -860,9 +852,6 @@
3658         if (locked) {
3659                 ASSERT(XFS_DQ_IS_LOCKED(udq));
3660                 ASSERT(XFS_DQ_IS_LOCKED(gdq));
3661 -       } else {
3662 -               ASSERT(! XFS_DQ_IS_LOCKED(udq));
3663 -               ASSERT(! XFS_DQ_IS_LOCKED(gdq));
3664         }
3665  #endif
3666         if (! locked)
3667 @@ -890,15 +879,12 @@
3668                  */
3669                 xfs_qm_dqrele(tmp);
3670  
3671 -               ASSERT(! XFS_DQ_IS_LOCKED(udq));
3672 -               ASSERT(! XFS_DQ_IS_LOCKED(gdq));
3673                 xfs_dqlock(udq);
3674                 xfs_dqlock(gdq);
3675  
3676         } else {
3677                 ASSERT(XFS_DQ_IS_LOCKED(udq));
3678                 if (! locked) {
3679 -                       ASSERT(! XFS_DQ_IS_LOCKED(gdq));
3680                         xfs_dqlock(gdq);
3681                 }
3682         }
3683 @@ -1006,14 +992,10 @@
3684                 if (ip->i_udquot) {
3685                         if (flags & XFS_QMOPT_DQLOCK)
3686                                 ASSERT(XFS_DQ_IS_LOCKED(ip->i_udquot));
3687 -                       else
3688 -                               ASSERT(! XFS_DQ_IS_LOCKED(ip->i_udquot));
3689                 }
3690                 if (ip->i_gdquot) {
3691                         if (flags & XFS_QMOPT_DQLOCK)
3692                                 ASSERT(XFS_DQ_IS_LOCKED(ip->i_gdquot));
3693 -                       else
3694 -                               ASSERT(! XFS_DQ_IS_LOCKED(ip->i_gdquot));
3695                 }
3696                 if (XFS_IS_UQUOTA_ON(mp))
3697                         ASSERT(ip->i_udquot);
3698 @@ -1756,7 +1738,10 @@
3699         xfs_trans_t     *tp,            /* transaction pointer - NULL */
3700         xfs_ino_t       ino,            /* inode number to get data for */
3701         void            *buffer,        /* not used */
3702 +       int             ubsize,         /* not used */
3703 +       void            *private_data,  /* not used */
3704         xfs_daddr_t     bno,            /* starting block of inode cluster */
3705 +       int             *ubused,        /* not used */
3706         void            *dip,           /* on-disk inode pointer (not used) */
3707         int             *res)           /* result code value */
3708  {
3709 @@ -1920,7 +1905,7 @@
3710                  * adjusting the corresponding dquot counters in core.
3711                  */
3712                 if ((error = xfs_bulkstat(mp, NULL, &lastino, &count,
3713 -                                    xfs_qm_dqusage_adjust,
3714 +                                    xfs_qm_dqusage_adjust, NULL,
3715                                      structsz, NULL,
3716                                      BULKSTAT_FG_IGET|BULKSTAT_FG_VFSLOCKED,
3717                                      &done)))
3718 @@ -2091,7 +2076,7 @@
3719                         xfs_dqunlock(dqp);
3720                         xfs_qm_freelist_unlock(xfs_Gqm);
3721                         if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
3722 -                               goto out;
3723 +                               return (nreclaimed);
3724                         XQM_STATS_INC(xqmstats.xs_qm_dqwants);
3725                         goto tryagain;
3726                 }
3727 @@ -2166,7 +2151,7 @@
3728                         XFS_DQ_HASH_UNLOCK(hash);
3729                         xfs_qm_freelist_unlock(xfs_Gqm);
3730                         if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
3731 -                               goto out;
3732 +                               return (nreclaimed);
3733                         goto tryagain;
3734                 }
3735                 xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING");
3736 @@ -2191,14 +2176,12 @@
3737                 dqp = nextdqp;
3738         }
3739         xfs_qm_freelist_unlock(xfs_Gqm);
3740 - out:
3741 -       return nreclaimed;
3742 +       return (nreclaimed);
3743  }
3744  
3745  
3746  /*
3747 - * The shake manager routine called by shaked() when memory is
3748 - * running low.
3749 + * The kmem_shake interface is invoked when memory is running low.
3750   */
3751  /* ARGSUSED */
3752  STATIC int
3753 @@ -2206,10 +2189,10 @@
3754  {
3755         int     ndqused, nfree, n;
3756  
3757 -       if (!(gfp_mask & __GFP_WAIT))
3758 -               return 0;
3759 +       if (!kmem_shake_allow(gfp_mask))
3760 +               return (0);
3761         if (!xfs_Gqm)
3762 -               return 0;
3763 +               return (0);
3764  
3765         nfree = xfs_Gqm->qm_dqfreelist.qh_nelems; /* free dquots */
3766         /* incore dquots in all f/s's */
3767 @@ -2218,7 +2201,7 @@
3768         ASSERT(ndqused >= 0);
3769  
3770         if (nfree <= ndqused && nfree < ndquot)
3771 -               return 0;
3772 +               return (0);
3773  
3774         ndqused *= xfs_Gqm->qm_dqfree_ratio;    /* target # of free dquots */
3775         n = nfree - ndqused - ndquot;           /* # over target */
3776 diff -urN linux.org/fs/xfs/quota/xfs_qm_syscalls.c linux/fs/xfs/quota/xfs_qm_syscalls.c
3777 --- linux.org/fs/xfs/quota/xfs_qm_syscalls.c    2003-12-31 05:47:47.000000000 +0100
3778 +++ linux/fs/xfs/quota/xfs_qm_syscalls.c        2004-01-02 04:21:44.000000000 +0100
3779 @@ -1301,7 +1301,10 @@
3780         xfs_trans_t     *tp,            /* transaction pointer */
3781         xfs_ino_t       ino,            /* inode number to get data for */
3782         void            *buffer,        /* not used */
3783 +       int             ubsize,         /* not used */
3784 +       void            *private_data,  /* not used */
3785         xfs_daddr_t     bno,            /* starting block of inode cluster */
3786 +       int             *ubused,        /* not used */
3787         void            *dip,           /* not used */
3788         int             *res)           /* bulkstat result code */
3789  {
3790 @@ -1403,7 +1406,7 @@
3791                  * adjusting the corresponding dquot counters
3792                  */
3793                 if ((error = xfs_bulkstat(mp, NULL, &lastino, &count,
3794 -                                xfs_qm_internalqcheck_adjust,
3795 +                                xfs_qm_internalqcheck_adjust, NULL,
3796                                  0, NULL, BULKSTAT_FG_IGET, &done))) {
3797                         break;
3798                 }
3799 diff -urN linux.org/fs/xfs/quota/xfs_trans_dquot.c linux/fs/xfs/quota/xfs_trans_dquot.c
3800 --- linux.org/fs/xfs/quota/xfs_trans_dquot.c    2003-12-31 05:46:41.000000000 +0100
3801 +++ linux/fs/xfs/quota/xfs_trans_dquot.c        2004-01-02 04:21:44.000000000 +0100
3802 @@ -835,13 +835,6 @@
3803         ASSERT(ip->i_ino != mp->m_sb.sb_uquotino);
3804         ASSERT(ip->i_ino != mp->m_sb.sb_gquotino);
3805  
3806 -#ifdef QUOTADEBUG
3807 -       if (ip->i_udquot)
3808 -               ASSERT(! XFS_DQ_IS_LOCKED(ip->i_udquot));
3809 -       if (ip->i_gdquot)
3810 -               ASSERT(! XFS_DQ_IS_LOCKED(ip->i_gdquot));
3811 -#endif
3812 -
3813         ASSERT(XFS_ISLOCKED_INODE_EXCL(ip));
3814         ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount));
3815         ASSERT((type & ~XFS_QMOPT_FORCE_RES) == XFS_TRANS_DQ_RES_RTBLKS ||
3816 diff -urN linux.org/fs/xfs/support/debug.h linux/fs/xfs/support/debug.h
3817 --- linux.org/fs/xfs/support/debug.h    2003-12-31 05:48:49.000000000 +0100
3818 +++ linux/fs/xfs/support/debug.h        2004-01-02 04:21:44.000000000 +0100
3819 @@ -44,6 +44,10 @@
3820  extern void icmn_err(int, char *, va_list);
3821  extern void cmn_err(int, char *, ...);
3822  
3823 +#ifndef STATIC
3824 +# define STATIC static
3825 +#endif
3826 +
3827  #ifdef DEBUG
3828  # ifdef lint
3829  #  define ASSERT(EX)   ((void)0) /* avoid "constant in conditional" babble */
3830 diff -urN linux.org/fs/xfs/support/kmem.h linux/fs/xfs/support/kmem.h
3831 --- linux.org/fs/xfs/support/kmem.h     2003-12-31 05:48:56.000000000 +0100
3832 +++ linux/fs/xfs/support/kmem.h 2004-01-02 04:21:44.000000000 +0100
3833 @@ -165,4 +165,25 @@
3834         kmem_cache_free(zone, ptr);
3835  }
3836  
3837 +typedef struct shrinker *kmem_shaker_t;
3838 +typedef int (*kmem_shake_func_t)(int, unsigned int);
3839 +
3840 +static __inline kmem_shaker_t
3841 +kmem_shake_register(kmem_shake_func_t sfunc)
3842 +{
3843 +       return set_shrinker(DEFAULT_SEEKS, sfunc);
3844 +}
3845 +
3846 +static __inline void
3847 +kmem_shake_deregister(kmem_shaker_t shrinker)
3848 +{
3849 +       remove_shrinker(shrinker);
3850 +}
3851 +
3852 +static __inline int
3853 +kmem_shake_allow(unsigned int gfp_mask)
3854 +{
3855 +       return (gfp_mask & __GFP_WAIT);
3856 +}
3857 +
3858  #endif /* __XFS_SUPPORT_KMEM_H__ */
3859 diff -urN linux.org/fs/xfs/support/ktrace.c linux/fs/xfs/support/ktrace.c
3860 --- linux.org/fs/xfs/support/ktrace.c   2003-12-31 05:47:09.000000000 +0100
3861 +++ linux/fs/xfs/support/ktrace.c       2004-01-02 04:21:44.000000000 +0100
3862 @@ -1,5 +1,5 @@
3863  /*
3864 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
3865 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
3866   *
3867   * This program is free software; you can redistribute it and/or modify it
3868   * under the terms of version 2 of the GNU General Public License as
3869 @@ -40,8 +40,6 @@
3870  #include "debug.h"
3871  #include "ktrace.h"
3872  
3873 -#if    (defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
3874 -
3875  static kmem_zone_t *ktrace_hdr_zone;
3876  static kmem_zone_t *ktrace_ent_zone;
3877  static int          ktrace_zentries;
3878 @@ -121,7 +119,6 @@
3879         ktp->kt_nentries = nentries;
3880         ktp->kt_index    = 0;
3881         ktp->kt_rollover = 0;
3882 -
3883         return ktp;
3884  }
3885  
3886 @@ -182,6 +179,7 @@
3887         void            *val15)
3888  {
3889         static lock_t   wrap_lock = SPIN_LOCK_UNLOCKED;
3890 +       unsigned long   flags;
3891         int             index;
3892         ktrace_entry_t  *ktep;
3893  
3894 @@ -190,11 +188,11 @@
3895         /*
3896          * Grab an entry by pushing the index up to the next one.
3897          */
3898 -       spin_lock(&wrap_lock);
3899 +       spin_lock_irqsave(&wrap_lock, flags);
3900         index = ktp->kt_index;
3901         if (++ktp->kt_index == ktp->kt_nentries)
3902                 ktp->kt_index = 0;
3903 -       spin_unlock(&wrap_lock);
3904 +       spin_unlock_irqrestore(&wrap_lock, flags);
3905  
3906         if (!ktp->kt_rollover && index == ktp->kt_nentries - 1)
3907                 ktp->kt_rollover = 1;
3908 @@ -235,7 +233,6 @@
3909         return (ktp->kt_rollover ? ktp->kt_nentries : ktp->kt_index);
3910  }
3911  
3912 -
3913  /*
3914   * ktrace_first()
3915   *
3916 @@ -276,7 +273,7 @@
3917         }
3918         return ktep;
3919  }
3920 -
3921 +EXPORT_SYMBOL(ktrace_first);
3922  
3923  /*
3924   * ktrace_next()
3925 @@ -311,11 +308,7 @@
3926  
3927         return ktep;
3928  }
3929 -
3930 -#if    (defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
3931 -EXPORT_SYMBOL(ktrace_first);
3932  EXPORT_SYMBOL(ktrace_next);
3933 -#endif
3934  
3935  /*
3936   * ktrace_skip()
3937 @@ -323,7 +316,6 @@
3938   * Skip the next "count" entries and return the entry after that.
3939   * Return NULL if this causes us to iterate past the beginning again.
3940   */
3941 -
3942  ktrace_entry_t *
3943  ktrace_skip(
3944         ktrace_t        *ktp,
3945 @@ -362,18 +354,3 @@
3946         }
3947         return ktep;
3948  }
3949 -
3950 -#else
3951 -
3952 -ktrace_t *
3953 -ktrace_alloc(int nentries, int sleep)
3954 -{
3955 -       /*
3956 -        * KM_SLEEP callers don't expect failure.
3957 -        */
3958 -       if (sleep & KM_SLEEP)
3959 -               panic("ktrace_alloc: NULL memory on KM_SLEEP request!");
3960 -
3961 -       return NULL;
3962 -}
3963 -#endif
3964 diff -urN linux.org/fs/xfs/support/ktrace.h linux/fs/xfs/support/ktrace.h
3965 --- linux.org/fs/xfs/support/ktrace.h   2003-12-31 05:47:26.000000000 +0100
3966 +++ linux/fs/xfs/support/ktrace.h       2004-01-02 04:21:44.000000000 +0100
3967 @@ -1,5 +1,5 @@
3968  /*
3969 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
3970 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
3971   *
3972   * This program is free software; you can redistribute it and/or modify it
3973   * under the terms of version 2 of the GNU General Public License as
3974 @@ -32,6 +32,7 @@
3975  #ifndef __XFS_SUPPORT_KTRACE_H__
3976  #define __XFS_SUPPORT_KTRACE_H__
3977  
3978 +#include <support/spin.h>
3979  
3980  /*
3981   * Trace buffer entry structure.
3982 @@ -59,16 +60,13 @@
3983         int             ks_index;       /* current index */
3984  } ktrace_snap_t;
3985  
3986 -/*
3987 - * Exported interfaces.
3988 - */
3989 -extern ktrace_t *ktrace_alloc(int, int);
3990  
3991 -#if    (defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
3992 +#ifdef CONFIG_XFS_TRACE
3993  
3994  extern void ktrace_init(int zentries);
3995  extern void ktrace_uninit(void);
3996  
3997 +extern ktrace_t *ktrace_alloc(int, int);
3998  extern void ktrace_free(ktrace_t *);
3999  
4000  extern void ktrace_enter(
4001 @@ -96,10 +94,8 @@
4002  extern ktrace_entry_t   *ktrace_skip(ktrace_t *, int, ktrace_snap_t *);
4003  
4004  #else
4005 +#define ktrace_init(x) do { } while (0)
4006 +#define ktrace_uninit()        do { } while (0)
4007 +#endif /* CONFIG_XFS_TRACE */
4008  
4009 -#define        ktrace_free(ktp)
4010 -#define        ktrace_enter(ktp,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15)
4011 -
4012 -#endif
4013 -
4014 -#endif /* __XFS_SUPPORT_KTRACE_H__ */
4015 +#endif /* __XFS_SUPPORT_KTRACE_H__ */
4016 diff -urN linux.org/fs/xfs/support/qsort.c linux/fs/xfs/support/qsort.c
4017 --- linux.org/fs/xfs/support/qsort.c    2003-12-31 05:48:26.000000000 +0100
4018 +++ linux/fs/xfs/support/qsort.c        2004-01-02 04:21:44.000000000 +0100
4019 @@ -1,243 +1,155 @@
4020 -/* Copyright (C) 1991, 1992, 1996, 1997, 1999 Free Software Foundation, Inc.
4021 -   This file is part of the GNU C Library.
4022 -   Written by Douglas C. Schmidt (schmidt@ics.uci.edu).
4023 -
4024 -   The GNU C Library is free software; you can redistribute it and/or
4025 -   modify it under the terms of the GNU Lesser General Public
4026 -   License as published by the Free Software Foundation; either
4027 -   version 2.1 of the License, or (at your option) any later version.
4028 -
4029 -   The GNU C Library is distributed in the hope that it will be useful,
4030 -   but WITHOUT ANY WARRANTY; without even the implied warranty of
4031 -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4032 -   Lesser General Public License for more details.
4033 -
4034 -   You should have received a copy of the GNU Lesser General Public
4035 -   License along with the GNU C Library; if not, write to the Free
4036 -   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4037 -   02111-1307 USA.  */
4038 -
4039 -/* If you consider tuning this algorithm, you should consult first:
4040 -   Engineering a sort function; Jon Bentley and M. Douglas McIlroy;
4041 -   Software - Practice and Experience; Vol. 23 (11), 1249-1265, 1993.  */
4042 +/*
4043 + * Copyright (c) 1992, 1993
4044 + *     The Regents of the University of California.  All rights reserved.
4045 + *
4046 + * Redistribution and use in source and binary forms, with or without
4047 + * modification, are permitted provided that the following conditions
4048 + * are met:
4049 + * 1. Redistributions of source code must retain the above copyright
4050 + *    notice, this list of conditions and the following disclaimer.
4051 + * 2. Redistributions in binary form must reproduce the above copyright
4052 + *    notice, this list of conditions and the following disclaimer in the
4053 + *    documentation and/or other materials provided with the distribution.
4054 + * 3. Neither the name of the University nor the names of its contributors
4055 + *    may be used to endorse or promote products derived from this software
4056 + *    without specific prior written permission.
4057 + *
4058 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4059 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4060 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4061 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4062 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4063 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4064 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4065 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4066 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4067 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4068 + * SUCH DAMAGE.
4069 + */
4070  
4071  #include <linux/kernel.h>
4072  #include <linux/string.h>
4073  
4074 -/* Byte-wise swap two items of size SIZE. */
4075 -#define SWAP(a, b, size)                                                     \
4076 -  do                                                                         \
4077 -    {                                                                        \
4078 -      register size_t __size = (size);                                       \
4079 -      register char *__a = (a), *__b = (b);                                  \
4080 -      do                                                                     \
4081 -       {                                                                     \
4082 -         char __tmp = *__a;                                                  \
4083 -         *__a++ = *__b;                                                      \
4084 -         *__b++ = __tmp;                                                     \
4085 -       } while (--__size > 0);                                               \
4086 -    } while (0)
4087 -
4088 -/* Discontinue quicksort algorithm when partition gets below this size.
4089 -   This particular magic number was chosen to work best on a Sun 4/260. */
4090 -#define MAX_THRESH 4
4091 -
4092 -/* Stack node declarations used to store unfulfilled partition obligations. */
4093 -typedef struct
4094 -  {
4095 -    char *lo;
4096 -    char *hi;
4097 -  } stack_node;
4098 -
4099 -/* The next 4 #defines implement a very fast in-line stack abstraction. */
4100 -/* The stack needs log (total_elements) entries (we could even subtract
4101 -   log(MAX_THRESH)).  Since total_elements has type size_t, we get as
4102 -   upper bound for log (total_elements):
4103 -   bits per byte (CHAR_BIT) * sizeof(size_t).  */
4104 -#define STACK_SIZE     (8 * sizeof(unsigned long int))
4105 -#define PUSH(low, high)        ((void) ((top->lo = (low)), (top->hi = (high)), ++top))
4106 -#define        POP(low, high)  ((void) (--top, (low = top->lo), (high = top->hi)))
4107 -#define        STACK_NOT_EMPTY (stack < top)
4108 -
4109 -
4110 -/* Order size using quicksort.  This implementation incorporates
4111 -   four optimizations discussed in Sedgewick:
4112 -
4113 -   1. Non-recursive, using an explicit stack of pointer that store the
4114 -      next array partition to sort.  To save time, this maximum amount
4115 -      of space required to store an array of SIZE_MAX is allocated on the
4116 -      stack.  Assuming a 32-bit (64 bit) integer for size_t, this needs
4117 -      only 32 * sizeof(stack_node) == 256 bytes (for 64 bit: 1024 bytes).
4118 -      Pretty cheap, actually.
4119 -
4120 -   2. Chose the pivot element using a median-of-three decision tree.
4121 -      This reduces the probability of selecting a bad pivot value and
4122 -      eliminates certain extraneous comparisons.
4123 -
4124 -   3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving
4125 -      insertion sort to order the MAX_THRESH items within each partition.
4126 -      This is a big win, since insertion sort is faster for small, mostly
4127 -      sorted array segments.
4128 -
4129 -   4. The larger of the two sub-partitions is always pushed onto the
4130 -      stack first, with the algorithm then concentrating on the
4131 -      smaller partition.  This *guarantees* no more than log (total_elems)
4132 -      stack size is needed (actually O(1) in this case)!  */
4133 +/*
4134 + * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
4135 + */
4136 +#define swapcode(TYPE, parmi, parmj, n) {              \
4137 +       long i = (n) / sizeof (TYPE);                   \
4138 +       register TYPE *pi = (TYPE *) (parmi);           \
4139 +       register TYPE *pj = (TYPE *) (parmj);           \
4140 +       do {                                            \
4141 +               register TYPE   t = *pi;                \
4142 +               *pi++ = *pj;                            \
4143 +               *pj++ = t;                              \
4144 +        } while (--i > 0);                             \
4145 +}
4146  
4147 -void
4148 -qsort (void *const pbase, size_t total_elems, size_t size,
4149 -       int (*cmp)(const void *, const void *))
4150 +#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
4151 +       es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
4152 +
4153 +static __inline void
4154 +swapfunc(char *a, char *b, int n, int swaptype)
4155  {
4156 -  register char *base_ptr = (char *) pbase;
4157 +       if (swaptype <= 1) 
4158 +               swapcode(long, a, b, n)
4159 +       else
4160 +               swapcode(char, a, b, n)
4161 +}
4162  
4163 -  const size_t max_thresh = MAX_THRESH * size;
4164 +#define swap(a, b)                                     \
4165 +       if (swaptype == 0) {                            \
4166 +               long t = *(long *)(a);                  \
4167 +               *(long *)(a) = *(long *)(b);            \
4168 +               *(long *)(b) = t;                       \
4169 +       } else                                          \
4170 +               swapfunc(a, b, es, swaptype)
4171  
4172 -  if (total_elems == 0)
4173 -    /* Avoid lossage with unsigned arithmetic below.  */
4174 -    return;
4175 -
4176 -  if (total_elems > MAX_THRESH)
4177 -    {
4178 -      char *lo = base_ptr;
4179 -      char *hi = &lo[size * (total_elems - 1)];
4180 -      stack_node stack[STACK_SIZE];
4181 -      stack_node *top = stack + 1;
4182 -
4183 -      while (STACK_NOT_EMPTY)
4184 -       {
4185 -         char *left_ptr;
4186 -         char *right_ptr;
4187 -
4188 -         /* Select median value from among LO, MID, and HI. Rearrange
4189 -            LO and HI so the three values are sorted. This lowers the
4190 -            probability of picking a pathological pivot value and
4191 -            skips a comparison for both the LEFT_PTR and RIGHT_PTR in
4192 -            the while loops. */
4193 -
4194 -         char *mid = lo + size * ((hi - lo) / size >> 1);
4195 -
4196 -         if ((*cmp) ((void *) mid, (void *) lo) < 0)
4197 -           SWAP (mid, lo, size);
4198 -         if ((*cmp) ((void *) hi, (void *) mid) < 0)
4199 -           SWAP (mid, hi, size);
4200 -         else
4201 -           goto jump_over;
4202 -         if ((*cmp) ((void *) mid, (void *) lo) < 0)
4203 -           SWAP (mid, lo, size);
4204 -       jump_over:;
4205 -
4206 -         left_ptr  = lo + size;
4207 -         right_ptr = hi - size;
4208 -
4209 -         /* Here's the famous ``collapse the walls'' section of quicksort.
4210 -            Gotta like those tight inner loops!  They are the main reason
4211 -            that this algorithm runs much faster than others. */
4212 -         do
4213 -           {
4214 -             while ((*cmp) ((void *) left_ptr, (void *) mid) < 0)
4215 -               left_ptr += size;
4216 -
4217 -             while ((*cmp) ((void *) mid, (void *) right_ptr) < 0)
4218 -               right_ptr -= size;
4219 -
4220 -             if (left_ptr < right_ptr)
4221 -               {
4222 -                 SWAP (left_ptr, right_ptr, size);
4223 -                 if (mid == left_ptr)
4224 -                   mid = right_ptr;
4225 -                 else if (mid == right_ptr)
4226 -                   mid = left_ptr;
4227 -                 left_ptr += size;
4228 -                 right_ptr -= size;
4229 -               }
4230 -             else if (left_ptr == right_ptr)
4231 -               {
4232 -                 left_ptr += size;
4233 -                 right_ptr -= size;
4234 -                 break;
4235 +#define vecswap(a, b, n)       if ((n) > 0) swapfunc(a, b, n, swaptype)
4236 +
4237 +static __inline char *
4238 +med3(char *a, char *b, char *c, int (*cmp)(const void *, const void *))
4239 +{
4240 +       return cmp(a, b) < 0 ?
4241 +              (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
4242 +              :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
4243 +}
4244 +
4245 +void
4246 +qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *))
4247 +{
4248 +       char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
4249 +       int d, r, swaptype, swap_cnt;
4250 +       register char *a = aa;
4251 +
4252 +loop:  SWAPINIT(a, es);
4253 +       swap_cnt = 0;
4254 +       if (n < 7) {
4255 +               for (pm = (char *)a + es; pm < (char *) a + n * es; pm += es)
4256 +                       for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
4257 +                            pl -= es)
4258 +                               swap(pl, pl - es);
4259 +               return;
4260 +       }
4261 +       pm = (char *)a + (n / 2) * es;
4262 +       if (n > 7) {
4263 +               pl = (char *)a;
4264 +               pn = (char *)a + (n - 1) * es;
4265 +               if (n > 40) {
4266 +                       d = (n / 8) * es;
4267 +                       pl = med3(pl, pl + d, pl + 2 * d, cmp);
4268 +                       pm = med3(pm - d, pm, pm + d, cmp);
4269 +                       pn = med3(pn - 2 * d, pn - d, pn, cmp);
4270                 }
4271 -           }
4272 -         while (left_ptr <= right_ptr);
4273 +               pm = med3(pl, pm, pn, cmp);
4274 +       }
4275 +       swap(a, pm);
4276 +       pa = pb = (char *)a + es;
4277  
4278 -         /* Set up pointers for next iteration.  First determine whether
4279 -            left and right partitions are below the threshold size.  If so,
4280 -            ignore one or both.  Otherwise, push the larger partition's
4281 -            bounds on the stack and continue sorting the smaller one. */
4282 -
4283 -         if ((size_t) (right_ptr - lo) <= max_thresh)
4284 -           {
4285 -             if ((size_t) (hi - left_ptr) <= max_thresh)
4286 -               /* Ignore both small partitions. */
4287 -               POP (lo, hi);
4288 -             else
4289 -               /* Ignore small left partition. */
4290 -               lo = left_ptr;
4291 -           }
4292 -         else if ((size_t) (hi - left_ptr) <= max_thresh)
4293 -           /* Ignore small right partition. */
4294 -           hi = right_ptr;
4295 -         else if ((right_ptr - lo) > (hi - left_ptr))
4296 -           {
4297 -             /* Push larger left partition indices. */
4298 -             PUSH (lo, right_ptr);
4299 -             lo = left_ptr;
4300 -           }
4301 -         else
4302 -           {
4303 -             /* Push larger right partition indices. */
4304 -             PUSH (left_ptr, hi);
4305 -             hi = right_ptr;
4306 -           }
4307 +       pc = pd = (char *)a + (n - 1) * es;
4308 +       for (;;) {
4309 +               while (pb <= pc && (r = cmp(pb, a)) <= 0) {
4310 +                       if (r == 0) {
4311 +                               swap_cnt = 1;
4312 +                               swap(pa, pb);
4313 +                               pa += es;
4314 +                       }
4315 +                       pb += es;
4316 +               }
4317 +               while (pb <= pc && (r = cmp(pc, a)) >= 0) {
4318 +                       if (r == 0) {
4319 +                               swap_cnt = 1;
4320 +                               swap(pc, pd);
4321 +                               pd -= es;
4322 +                       }
4323 +                       pc -= es;
4324 +               }
4325 +               if (pb > pc)
4326 +                       break;
4327 +               swap(pb, pc);
4328 +               swap_cnt = 1;
4329 +               pb += es;
4330 +               pc -= es;
4331 +       }
4332 +       if (swap_cnt == 0) {  /* Switch to insertion sort */
4333 +               for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
4334 +                       for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; 
4335 +                            pl -= es)
4336 +                               swap(pl, pl - es);
4337 +               return;
4338         }
4339 -    }
4340  
4341 -  /* Once the BASE_PTR array is partially sorted by quicksort the rest
4342 -     is completely sorted using insertion sort, since this is efficient
4343 -     for partitions below MAX_THRESH size. BASE_PTR points to the beginning
4344 -     of the array to sort, and END_PTR points at the very last element in
4345 -     the array (*not* one beyond it!). */
4346 -  {
4347 -    char *const end_ptr = &base_ptr[size * (total_elems - 1)];
4348 -    char *tmp_ptr = base_ptr;
4349 -    char *const thresh = min_t(char *const, end_ptr, base_ptr + max_thresh);
4350 -    register char *run_ptr;
4351 -
4352 -    /* Find smallest element in first threshold and place it at the
4353 -       array's beginning.  This is the smallest array element,
4354 -       and the operation speeds up insertion sort's inner loop. */
4355 -
4356 -    for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size)
4357 -      if ((*cmp) ((void *) run_ptr, (void *) tmp_ptr) < 0)
4358 -       tmp_ptr = run_ptr;
4359 -
4360 -    if (tmp_ptr != base_ptr)
4361 -      SWAP (tmp_ptr, base_ptr, size);
4362 -
4363 -    /* Insertion sort, running from left-hand-side up to right-hand-side.  */
4364 -
4365 -    run_ptr = base_ptr + size;
4366 -    while ((run_ptr += size) <= end_ptr)
4367 -      {
4368 -       tmp_ptr = run_ptr - size;
4369 -       while ((*cmp) ((void *) run_ptr, (void *) tmp_ptr) < 0)
4370 -         tmp_ptr -= size;
4371 -
4372 -       tmp_ptr += size;
4373 -       if (tmp_ptr != run_ptr)
4374 -         {
4375 -           char *trav;
4376 -
4377 -           trav = run_ptr + size;
4378 -           while (--trav >= run_ptr)
4379 -             {
4380 -               char c = *trav;
4381 -               char *hi, *lo;
4382 -
4383 -               for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo)
4384 -                 *hi = *lo;
4385 -               *hi = c;
4386 -             }
4387 -         }
4388 -      }
4389 -  }
4390 +       pn = (char *)a + n * es;
4391 +       r = min(pa - (char *)a, pb - pa);
4392 +       vecswap(a, pb - r, r);
4393 +       r = min((long)(pd - pc), (long)(pn - pd - es));
4394 +       vecswap(pb, pn - r, r);
4395 +       if ((r = pb - pa) > es)
4396 +               qsort(a, r / es, es, cmp);
4397 +       if ((r = pd - pc) > es) { 
4398 +               /* Iterate rather than recurse to save stack space */
4399 +               a = pn - r;
4400 +               n = r / es;
4401 +               goto loop;
4402 +       }
4403 +/*             qsort(pn - r, r / es, es, cmp);*/
4404  }
4405 diff -urN linux.org/fs/xfs/xfs_acl.h linux/fs/xfs/xfs_acl.h
4406 --- linux.org/fs/xfs/xfs_acl.h  2003-12-31 05:47:08.000000000 +0100
4407 +++ linux/fs/xfs/xfs_acl.h      2004-01-02 04:21:42.000000000 +0100
4408 @@ -1,5 +1,5 @@
4409  /*
4410 - * Copyright (c) 2001-2002 Silicon Graphics, Inc.  All Rights Reserved.
4411 + * Copyright (c) 2001-2003 Silicon Graphics, Inc.  All Rights Reserved.
4412   *
4413   * This program is free software; you can redistribute it and/or modify it
4414   * under the terms of version 2 of the GNU General Public License as
4415 @@ -102,6 +102,8 @@
4416  #define xfs_acl_vset(v,p,sz,t) (-EOPNOTSUPP)
4417  #define xfs_acl_vget(v,p,sz,t) (-EOPNOTSUPP)
4418  #define xfs_acl_vremove(v,t)   (-EOPNOTSUPP)
4419 +#define xfs_acl_vhasacl_access(v)      (0)
4420 +#define xfs_acl_vhasacl_default(v)     (0)
4421  #define _ACL_DECL(a)           ((void)0)
4422  #define _ACL_ALLOC(a)          (1)     /* successfully allocate nothing */
4423  #define _ACL_FREE(a)           ((void)0)
4424 diff -urN linux.org/fs/xfs/xfs_alloc.c linux/fs/xfs/xfs_alloc.c
4425 --- linux.org/fs/xfs/xfs_alloc.c        2003-12-31 05:46:44.000000000 +0100
4426 +++ linux/fs/xfs/xfs_alloc.c    2004-01-02 04:21:42.000000000 +0100
4427 @@ -54,13 +54,6 @@
4428  #include "xfs_error.h"
4429  
4430  
4431 -#if defined(DEBUG)
4432 -/*
4433 - * Allocation tracing.
4434 - */
4435 -ktrace_t       *xfs_alloc_trace_buf;
4436 -#endif
4437 -
4438  #define XFS_ABSDIFF(a,b)       (((a) <= (b)) ? ((b) - (a)) : ((a) - (b)))
4439  
4440  #define        XFSA_FIXUP_BNO_OK       1
4441 @@ -73,6 +66,8 @@
4442                     xfs_extlen_t len);
4443  
4444  #if defined(XFS_ALLOC_TRACE)
4445 +ktrace_t *xfs_alloc_trace_buf;
4446 +
4447  #define        TRACE_ALLOC(s,a)        \
4448         xfs_alloc_trace_alloc(fname, s, a, __LINE__)
4449  #define        TRACE_FREE(s,a,b,x,f)   \
4450 @@ -85,8 +80,6 @@
4451         xfs_alloc_trace_busy(fname, s, mp, ag, -1, -1, sl, tp, XFS_ALLOC_KTRACE_UNBUSY, __LINE__)
4452  #define        TRACE_BUSYSEARCH(fname,s,ag,agb,l,sl,tp)        \
4453         xfs_alloc_trace_busy(fname, s, mp, ag, agb, l, sl, tp, XFS_ALLOC_KTRACE_BUSYSEARCH, __LINE__)
4454 -
4455 -
4456  #else
4457  #define        TRACE_ALLOC(s,a)
4458  #define        TRACE_FREE(s,a,b,x,f)
4459 diff -urN linux.org/fs/xfs/xfs_alloc.h linux/fs/xfs/xfs_alloc.h
4460 --- linux.org/fs/xfs/xfs_alloc.h        2003-12-31 05:46:56.000000000 +0100
4461 +++ linux/fs/xfs/xfs_alloc.h    2004-01-02 04:21:42.000000000 +0100
4462 @@ -95,6 +95,13 @@
4463  
4464  #ifdef __KERNEL__
4465  
4466 +#if defined(XFS_ALLOC_TRACE)
4467 +/*
4468 + * Allocation tracing buffer size.
4469 + */
4470 +#define        XFS_ALLOC_TRACE_SIZE    4096
4471 +extern ktrace_t *xfs_alloc_trace_buf;
4472 +
4473  /*
4474   * Types for alloc tracing.
4475   */
4476 @@ -104,26 +111,9 @@
4477  #define        XFS_ALLOC_KTRACE_BUSY   4
4478  #define        XFS_ALLOC_KTRACE_UNBUSY 5
4479  #define        XFS_ALLOC_KTRACE_BUSYSEARCH     6
4480 -
4481 -
4482 -/*
4483 - * Allocation tracing buffer size.
4484 - */
4485 -#define        XFS_ALLOC_TRACE_SIZE    4096
4486 -
4487 -#ifdef XFS_ALL_TRACE
4488 -#define        XFS_ALLOC_TRACE
4489 -#endif
4490 -
4491 -#if !defined(DEBUG)
4492 -#undef XFS_ALLOC_TRACE
4493  #endif
4494  
4495  /*
4496 - * Prototypes for visible xfs_alloc.c routines
4497 - */
4498 -
4499 -/*
4500   * Compute and fill in value of m_ag_maxlevels.
4501   */
4502  void
4503 diff -urN linux.org/fs/xfs/xfs_arch.h linux/fs/xfs/xfs_arch.h
4504 --- linux.org/fs/xfs/xfs_arch.h 2003-12-31 05:48:14.000000000 +0100
4505 +++ linux/fs/xfs/xfs_arch.h     2004-01-02 04:21:42.000000000 +0100
4506 @@ -53,16 +53,18 @@
4507  
4508  #define ARCH_NOCONVERT 1
4509  #if __BYTE_ORDER == __LITTLE_ENDIAN
4510 -#define ARCH_CONVERT   0
4511 +# define ARCH_CONVERT  0
4512  #else
4513 -#define ARCH_CONVERT   ARCH_NOCONVERT
4514 +# define ARCH_CONVERT  ARCH_NOCONVERT
4515  #endif
4516  
4517  /* generic swapping macros */
4518  
4519 +#ifndef HAVE_SWABMACROS
4520  #define INT_SWAP16(type,var) ((typeof(type))(__swab16((__u16)(var))))
4521  #define INT_SWAP32(type,var) ((typeof(type))(__swab32((__u32)(var))))
4522  #define INT_SWAP64(type,var) ((typeof(type))(__swab64((__u64)(var))))
4523 +#endif
4524  
4525  #define INT_SWAP(type, var) \
4526      ((sizeof(type) == 8) ? INT_SWAP64(type,var) : \
4527 diff -urN linux.org/fs/xfs/xfs_attr.c linux/fs/xfs/xfs_attr.c
4528 --- linux.org/fs/xfs/xfs_attr.c 2003-12-31 05:47:38.000000000 +0100
4529 +++ linux/fs/xfs/xfs_attr.c     2004-01-02 04:21:42.000000000 +0100
4530 @@ -1,5 +1,5 @@
4531  /*
4532 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4533 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
4534   *
4535   * This program is free software; you can redistribute it and/or modify it
4536   * under the terms of version 2 of the GNU General Public License as
4537 @@ -63,6 +63,7 @@
4538  #include "xfs_quota.h"
4539  #include "xfs_rw.h"
4540  #include "xfs_trans_space.h"
4541 +#include "xfs_acl.h"
4542  
4543  /*
4544   * xfs_attr.c
4545 @@ -2234,7 +2235,8 @@
4546                 (__psunsigned_t)context->count,
4547                 (__psunsigned_t)context->firstu,
4548                 (__psunsigned_t)
4549 -                       (context->count > 0)
4550 +                       ((context->count > 0) &&
4551 +                       !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
4552                                 ? (ATTR_ENTRY(context->alist,
4553                                               context->count-1)->a_valuelen)
4554                                 : 0,
4555 @@ -2262,7 +2264,8 @@
4556                 (__psunsigned_t)context->count,
4557                 (__psunsigned_t)context->firstu,
4558                 (__psunsigned_t)
4559 -                       (context->count > 0)
4560 +                       ((context->count > 0) &&
4561 +                       !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
4562                                 ? (ATTR_ENTRY(context->alist,
4563                                               context->count-1)->a_valuelen)
4564                                 : 0,
4565 @@ -2290,7 +2293,8 @@
4566                 (__psunsigned_t)context->count,
4567                 (__psunsigned_t)context->firstu,
4568                 (__psunsigned_t)
4569 -                       (context->count > 0)
4570 +                       ((context->count > 0) &&
4571 +                       !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
4572                                 ? (ATTR_ENTRY(context->alist,
4573                                               context->count-1)->a_valuelen)
4574                                 : 0,
4575 @@ -2318,7 +2322,8 @@
4576                 (__psunsigned_t)context->count,
4577                 (__psunsigned_t)context->firstu,
4578                 (__psunsigned_t)
4579 -                       (context->count > 0)
4580 +                       ((context->count > 0) &&
4581 +                       !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
4582                                 ? (ATTR_ENTRY(context->alist,
4583                                               context->count-1)->a_valuelen)
4584                                 : 0,
4585 @@ -2353,3 +2358,307 @@
4586                                          (void *)a14, (void *)a15);
4587  }
4588  #endif /* XFS_ATTR_TRACE */
4589 +
4590 +
4591 +/*========================================================================
4592 + * System (pseudo) namespace attribute interface routines.
4593 + *========================================================================*/
4594 +
4595 +STATIC int
4596 +posix_acl_access_set(
4597 +       vnode_t *vp, char *name, void *data, size_t size, int xflags)
4598 +{
4599 +       return xfs_acl_vset(vp, data, size, _ACL_TYPE_ACCESS);
4600 +}
4601 +
4602 +STATIC int
4603 +posix_acl_access_remove(
4604 +       struct vnode *vp, char *name, int xflags)
4605 +{
4606 +       return xfs_acl_vremove(vp, _ACL_TYPE_ACCESS);
4607 +}
4608 +
4609 +STATIC int
4610 +posix_acl_access_get(
4611 +       vnode_t *vp, char *name, void *data, size_t size, int xflags)
4612 +{
4613 +       return xfs_acl_vget(vp, data, size, _ACL_TYPE_ACCESS);
4614 +}
4615 +
4616 +STATIC int
4617 +posix_acl_access_exists(
4618 +       vnode_t *vp)
4619 +{
4620 +       return xfs_acl_vhasacl_access(vp);
4621 +}
4622 +
4623 +STATIC int
4624 +posix_acl_default_set(
4625 +       vnode_t *vp, char *name, void *data, size_t size, int xflags)
4626 +{
4627 +       return xfs_acl_vset(vp, data, size, _ACL_TYPE_DEFAULT);
4628 +}
4629 +
4630 +STATIC int
4631 +posix_acl_default_get(
4632 +       vnode_t *vp, char *name, void *data, size_t size, int xflags)
4633 +{
4634 +       return xfs_acl_vget(vp, data, size, _ACL_TYPE_DEFAULT);
4635 +}
4636 +
4637 +STATIC int
4638 +posix_acl_default_remove(
4639 +       struct vnode *vp, char *name, int xflags)
4640 +{
4641 +       return xfs_acl_vremove(vp, _ACL_TYPE_DEFAULT);
4642 +}
4643 +
4644 +STATIC int
4645 +posix_acl_default_exists(
4646 +       vnode_t *vp)
4647 +{
4648 +       return xfs_acl_vhasacl_default(vp);
4649 +}
4650 +
4651 +struct attrnames posix_acl_access = {
4652 +       .attr_name      = "posix_acl_access",
4653 +       .attr_namelen   = sizeof("posix_acl_access") - 1,
4654 +       .attr_get       = posix_acl_access_get,
4655 +       .attr_set       = posix_acl_access_set,
4656 +       .attr_remove    = posix_acl_access_remove,
4657 +       .attr_exists    = posix_acl_access_exists,
4658 +};
4659 +
4660 +struct attrnames posix_acl_default = {
4661 +       .attr_name      = "posix_acl_default",
4662 +       .attr_namelen   = sizeof("posix_acl_default") - 1,
4663 +       .attr_get       = posix_acl_default_get,
4664 +       .attr_set       = posix_acl_default_set,
4665 +       .attr_remove    = posix_acl_default_remove,
4666 +       .attr_exists    = posix_acl_default_exists,
4667 +};
4668 +
4669 +struct attrnames *attr_system_names[] =
4670 +       { &posix_acl_access, &posix_acl_default };
4671 +
4672 +
4673 +/*========================================================================
4674 + * Namespace-prefix-style attribute name interface routines.
4675 + *========================================================================*/
4676 +
4677 +STATIC int
4678 +attr_generic_set(
4679 +       struct vnode *vp, char *name, void *data, size_t size, int xflags)
4680 +{
4681 +       int     error;
4682 +
4683 +       VOP_ATTR_SET(vp, name, data, size, xflags, NULL, error);
4684 +       return -error;
4685 +}
4686 +
4687 +STATIC int
4688 +attr_generic_get(
4689 +       struct vnode *vp, char *name, void *data, size_t size, int xflags)
4690 +{
4691 +       int     error, asize = size;
4692 +
4693 +       VOP_ATTR_GET(vp, name, data, &asize, xflags, NULL, error);
4694 +       if (!error)
4695 +               return asize;
4696 +       return -error;
4697 +}
4698 +
4699 +STATIC int
4700 +attr_generic_remove(
4701 +       struct vnode *vp, char *name, int xflags)
4702 +{
4703 +       int     error;
4704 +
4705 +       VOP_ATTR_REMOVE(vp, name, xflags, NULL, error);
4706 +       return -error;
4707 +}
4708 +
4709 +STATIC int
4710 +attr_generic_listadd(
4711 +       attrnames_t             *prefix,
4712 +       attrnames_t             *namesp,
4713 +       void                    *data,
4714 +       size_t                  size,
4715 +       ssize_t                 *result)
4716 +{
4717 +       char                    *p = data + *result;
4718 +
4719 +       *result += prefix->attr_namelen;
4720 +       *result += namesp->attr_namelen + 1;
4721 +       if (!size)
4722 +               return 0;
4723 +       if (*result > size)
4724 +               return -ERANGE;
4725 +       strcpy(p, prefix->attr_name);
4726 +       p += prefix->attr_namelen;
4727 +       strcpy(p, namesp->attr_name);
4728 +       p += namesp->attr_namelen + 1;
4729 +       return 0;
4730 +}
4731 +
4732 +STATIC int
4733 +attr_system_list(
4734 +       struct vnode            *vp,
4735 +       void                    *data,
4736 +       size_t                  size,
4737 +       ssize_t                 *result)
4738 +{
4739 +       attrnames_t             *namesp;
4740 +       int                     i, error = 0;
4741 +
4742 +       for (i = 0; i < ATTR_SYSCOUNT; i++) {
4743 +               namesp = attr_system_names[i];
4744 +               if (!namesp->attr_exists || !namesp->attr_exists(vp))
4745 +                       continue;
4746 +               error = attr_generic_listadd(&attr_system, namesp,
4747 +                                               data, size, result);
4748 +               if (error)
4749 +                       break;
4750 +       }
4751 +       return error;
4752 +}
4753 +
4754 +int
4755 +attr_generic_list(
4756 +       struct vnode *vp, void *data, size_t size, int xflags, ssize_t *result)
4757 +{
4758 +       attrlist_cursor_kern_t  cursor = { 0 };
4759 +       int                     error;
4760 +
4761 +       VOP_ATTR_LIST(vp, data, size, xflags, &cursor, NULL, error);
4762 +       if (error > 0)
4763 +               return -error;
4764 +       *result = -error;
4765 +       return attr_system_list(vp, data, size, result);
4766 +}
4767 +
4768 +attrnames_t *
4769 +attr_lookup_namespace(
4770 +       char                    *name,
4771 +       struct attrnames        **names,
4772 +       int                     nnames)
4773 +{
4774 +       int                     i;
4775 +
4776 +       for (i = 0; i < nnames; i++)
4777 +               if (!strncmp(name, names[i]->attr_name, names[i]->attr_namelen))
4778 +                       return names[i];
4779 +       return NULL;
4780 +}
4781 +
4782 +/*
4783 + * Some checks to prevent people abusing EAs to get over quota:
4784 + * - Don't allow modifying user EAs on devices/symlinks;
4785 + * - Don't allow modifying user EAs if sticky bit set;
4786 + */
4787 +STATIC int
4788 +attr_user_capable(
4789 +       struct vnode    *vp,
4790 +       cred_t          *cred)
4791 +{
4792 +       struct inode    *inode = LINVFS_GET_IP(vp);
4793 +
4794 +       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
4795 +               return -EPERM;
4796 +       if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) &&
4797 +           !capable(CAP_SYS_ADMIN))
4798 +               return -EPERM;
4799 +       if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
4800 +           (current_fsuid(cred) != inode->i_uid) && !capable(CAP_FOWNER))
4801 +               return -EPERM;
4802 +       return 0;
4803 +}
4804 +
4805 +STATIC int
4806 +attr_trusted_capable(
4807 +       struct vnode    *vp,
4808 +       cred_t          *cred)
4809 +{
4810 +       struct inode    *inode = LINVFS_GET_IP(vp);
4811 +
4812 +       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
4813 +               return -EPERM;
4814 +       if (!capable(CAP_SYS_ADMIN))
4815 +               return -EPERM;
4816 +       return 0;
4817 +}
4818 +
4819 +STATIC int
4820 +attr_system_set(
4821 +       struct vnode *vp, char *name, void *data, size_t size, int xflags)
4822 +{
4823 +       attrnames_t     *namesp;
4824 +       int             error;
4825 +
4826 +       if (xflags & ATTR_CREATE)
4827 +               return -EINVAL;
4828 +
4829 +       namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
4830 +       if (!namesp)
4831 +               return -EOPNOTSUPP;
4832 +       error = namesp->attr_set(vp, name, data, size, xflags);
4833 +       if (!error)
4834 +               error = vn_revalidate(vp);
4835 +       return error;
4836 +}
4837 +
4838 +STATIC int
4839 +attr_system_get(
4840 +       struct vnode *vp, char *name, void *data, size_t size, int xflags)
4841 +{
4842 +       attrnames_t     *namesp;
4843 +
4844 +       namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
4845 +       if (!namesp)
4846 +               return -EOPNOTSUPP;
4847 +       return namesp->attr_get(vp, name, data, size, xflags);
4848 +}
4849 +
4850 +STATIC int
4851 +attr_system_remove(
4852 +       struct vnode *vp, char *name, int xflags)
4853 +{
4854 +       attrnames_t     *namesp;
4855 +
4856 +       namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
4857 +       if (!namesp)
4858 +               return -EOPNOTSUPP;
4859 +       return namesp->attr_remove(vp, name, xflags);
4860 +}
4861 +
4862 +struct attrnames attr_system = {
4863 +       .attr_name      = "system.",
4864 +       .attr_namelen   = sizeof("system.") - 1,
4865 +       .attr_flag      = ATTR_SYSTEM,
4866 +       .attr_get       = attr_system_get,
4867 +       .attr_set       = attr_system_set,
4868 +       .attr_remove    = attr_system_remove,
4869 +       .attr_capable   = (attrcapable_t)fs_noerr,
4870 +};
4871 +
4872 +struct attrnames attr_trusted = {
4873 +       .attr_name      = "trusted.",
4874 +       .attr_namelen   = sizeof("trusted.") - 1,
4875 +       .attr_flag      = ATTR_ROOT,
4876 +       .attr_get       = attr_generic_get,
4877 +       .attr_set       = attr_generic_set,
4878 +       .attr_remove    = attr_generic_remove,
4879 +       .attr_capable   = attr_trusted_capable,
4880 +};
4881 +
4882 +struct attrnames attr_user = {
4883 +       .attr_name      = "user.",
4884 +       .attr_namelen   = sizeof("user.") - 1,
4885 +       .attr_get       = attr_generic_get,
4886 +       .attr_set       = attr_generic_set,
4887 +       .attr_remove    = attr_generic_remove,
4888 +       .attr_capable   = attr_user_capable,
4889 +};
4890 +
4891 +struct attrnames *attr_namespaces[] =
4892 +       { &attr_system, &attr_trusted, &attr_user };
4893 diff -urN linux.org/fs/xfs/xfs_attr.h linux/fs/xfs/xfs_attr.h
4894 --- linux.org/fs/xfs/xfs_attr.h 2003-12-31 05:46:42.000000000 +0100
4895 +++ linux/fs/xfs/xfs_attr.h     2004-01-02 04:21:42.000000000 +0100
4896 @@ -1,5 +1,5 @@
4897  /*
4898 - * Copyright (c) 2000, 2002 Silicon Graphics, Inc.  All Rights Reserved.
4899 + * Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
4900   *
4901   * This program is free software; you can redistribute it and/or modify it
4902   * under the terms of version 2 of the GNU General Public License as
4903 @@ -45,22 +45,50 @@
4904   * as possible so as to fit into the literal area of the inode.
4905   */
4906  
4907 -#ifdef XFS_ALL_TRACE
4908 -#define        XFS_ATTR_TRACE
4909 -#endif
4910 -
4911 -#if !defined(DEBUG)
4912 -#undef XFS_ATTR_TRACE
4913 -#endif
4914 -
4915 -
4916  /*========================================================================
4917   * External interfaces
4918   *========================================================================*/
4919  
4920 -#define ATTR_ROOT      0x0002  /* use attrs in root namespace, not user */
4921 +struct cred;
4922 +struct vnode;
4923 +
4924 +typedef int (*attrset_t)(struct vnode *, char *, void *, size_t, int);
4925 +typedef int (*attrget_t)(struct vnode *, char *, void *, size_t, int);
4926 +typedef int (*attrremove_t)(struct vnode *, char *, int);
4927 +typedef int (*attrexists_t)(struct vnode *);
4928 +typedef int (*attrcapable_t)(struct vnode *, struct cred *);
4929 +
4930 +typedef struct attrnames {
4931 +       char *          attr_name;
4932 +       unsigned int    attr_namelen;
4933 +       unsigned int    attr_flag;
4934 +       attrget_t       attr_get;
4935 +       attrset_t       attr_set;
4936 +       attrremove_t    attr_remove;
4937 +       attrexists_t    attr_exists;
4938 +       attrcapable_t   attr_capable;
4939 +} attrnames_t;
4940 +
4941 +#define ATTR_NAMECOUNT 3
4942 +extern struct attrnames attr_user;
4943 +extern struct attrnames attr_system;
4944 +extern struct attrnames attr_trusted;
4945 +extern struct attrnames *attr_namespaces[ATTR_NAMECOUNT];
4946 +
4947 +#define ATTR_SYSCOUNT  2
4948 +extern struct attrnames posix_acl_access;
4949 +extern struct attrnames posix_acl_default;
4950 +extern struct attrnames *attr_system_names[ATTR_SYSCOUNT];
4951 +
4952 +extern attrnames_t *attr_lookup_namespace(char *, attrnames_t **, int);
4953 +extern int attr_generic_list(struct vnode *, void *, size_t, int, ssize_t *);
4954 +
4955 +#define ATTR_DONTFOLLOW        0x0001  /* -- unused, from IRIX -- */
4956 +#define ATTR_ROOT      0x0002  /* use attrs in root (trusted) namespace */
4957 +#define ATTR_TRUST     0x0004  /* -- unused, from IRIX -- */
4958  #define ATTR_CREATE    0x0010  /* pure create: fail if attr already exists */
4959  #define ATTR_REPLACE   0x0020  /* pure set: fail if attr does not exist */
4960 +#define ATTR_SYSTEM    0x0100  /* use attrs in system (pseudo) namespace */
4961  #define ATTR_KERNOTIME 0x1000  /* [kernel] don't update inode timestamps */
4962  #define ATTR_KERNOVAL  0x2000  /* [kernel] get attr size only, not value */
4963  #define ATTR_KERNAMELS 0x4000  /* [kernel] list attr names (simple list) */
4964 @@ -135,11 +163,8 @@
4965   * Function prototypes for the kernel.
4966   *========================================================================*/
4967  
4968 -struct cred;
4969 -struct vnode;
4970  struct xfs_inode;
4971  struct attrlist_cursor_kern;
4972 -struct xfs_ext_attr;
4973  struct xfs_da_args;
4974  
4975  /*
4976 diff -urN linux.org/fs/xfs/xfs_attr_leaf.c linux/fs/xfs/xfs_attr_leaf.c
4977 --- linux.org/fs/xfs/xfs_attr_leaf.c    2003-12-31 05:47:15.000000000 +0100
4978 +++ linux/fs/xfs/xfs_attr_leaf.c        2004-01-02 04:21:42.000000000 +0100
4979 @@ -1,5 +1,5 @@
4980  /*
4981 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4982 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
4983   *
4984   * This program is free software; you can redistribute it and/or modify it
4985   * under the terms of version 2 of the GNU General Public License as
4986 @@ -444,8 +444,10 @@
4987                                                         < context->bufsize) {
4988                 for (i = 0, sfe = &sf->list[0];
4989                                 i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
4990 -                       int ns = (sfe->flags & XFS_ATTR_ROOT)?
4991 -                                               ROOT_NAMES : USER_NAMES;
4992 +                       attrnames_t     *namesp;
4993 +
4994 +                       namesp = (sfe->flags & XFS_ATTR_ROOT) ? &attr_trusted :
4995 +                                 &attr_user;
4996                         if (((context->flags & ATTR_ROOT) != 0) !=
4997                             ((sfe->flags & XFS_ATTR_ROOT) != 0) &&
4998                             !(context->flags & ATTR_KERNFULLS)) {
4999 @@ -454,11 +456,11 @@
5000                         }
5001                         if (context->flags & ATTR_KERNOVAL) {
5002                                 ASSERT(context->flags & ATTR_KERNAMELS);
5003 -                               context->count += xfs_namespaces[ns].namelen +
5004 +                               context->count += namesp->attr_namelen +
5005                                         INT_GET(sfe->namelen, ARCH_CONVERT) + 1;
5006                         }
5007                         else {
5008 -                               if (xfs_attr_put_listent(context, ns,
5009 +                               if (xfs_attr_put_listent(context, namesp,
5010                                                    (char *)sfe->nameval,
5011                                                    (int)sfe->namelen,
5012                                                    (int)INT_GET(sfe->valuelen,
5013 @@ -544,18 +546,22 @@
5014          * Loop putting entries into the user buffer.
5015          */
5016         for ( ; i < nsbuf; i++, sbp++) {
5017 -               int ns = (sbp->flags & XFS_ATTR_ROOT)? ROOT_NAMES:USER_NAMES;
5018 +               attrnames_t     *namesp;
5019 +
5020 +               namesp = (sfe->flags & XFS_ATTR_ROOT) ? &attr_trusted :
5021 +                         &attr_user;
5022 +
5023                 if (cursor->hashval != INT_GET(sbp->hash, ARCH_CONVERT)) {
5024                         cursor->hashval = INT_GET(sbp->hash, ARCH_CONVERT);
5025                         cursor->offset = 0;
5026                 }
5027                 if (context->flags & ATTR_KERNOVAL) {
5028                         ASSERT(context->flags & ATTR_KERNAMELS);
5029 -                       context->count += xfs_namespaces[ns].namelen
5030 -                                       + sbp->namelen + 1;
5031 +                       context->count += namesp->attr_namelen +
5032 +                                               sbp->namelen + 1;
5033                 }
5034                 else {
5035 -                       if (xfs_attr_put_listent(context, ns,
5036 +                       if (xfs_attr_put_listent(context, namesp,
5037                                         sbp->name, sbp->namelen,
5038                                         INT_GET(sbp->valuelen, ARCH_CONVERT)))
5039                                 break;
5040 @@ -2270,7 +2276,7 @@
5041         retval = 0;
5042         for (  ; (i < INT_GET(leaf->hdr.count, ARCH_CONVERT))
5043              && (retval == 0); entry++, i++) {
5044 -               int ns = (entry->flags & XFS_ATTR_ROOT)? ROOT_NAMES:USER_NAMES;
5045 +               attrnames_t     *namesp;
5046  
5047                 if (INT_GET(entry->hashval, ARCH_CONVERT) != cursor->hashval) {
5048                         cursor->hashval = INT_GET(entry->hashval, ARCH_CONVERT);
5049 @@ -2284,14 +2290,17 @@
5050                     !(context->flags & ATTR_KERNFULLS))
5051                         continue;               /* skip non-matching entries */
5052  
5053 +               namesp = (entry->flags & XFS_ATTR_ROOT) ? &attr_trusted :
5054 +                         &attr_user;
5055 +
5056                 if (entry->flags & XFS_ATTR_LOCAL) {
5057                         name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i);
5058                         if (context->flags & ATTR_KERNOVAL) {
5059                                 ASSERT(context->flags & ATTR_KERNAMELS);
5060 -                               context->count += xfs_namespaces[ns].namelen
5061 -                                               + (int)name_loc->namelen + 1;
5062 +                               context->count += namesp->attr_namelen +
5063 +                                               (int)name_loc->namelen + 1;
5064                         } else {
5065 -                               retval = xfs_attr_put_listent(context, ns,
5066 +                               retval = xfs_attr_put_listent(context, namesp,
5067                                         (char *)name_loc->nameval,
5068                                         (int)name_loc->namelen,
5069                                         (int)INT_GET(name_loc->valuelen,
5070 @@ -2301,10 +2310,10 @@
5071                         name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
5072                         if (context->flags & ATTR_KERNOVAL) {
5073                                 ASSERT(context->flags & ATTR_KERNAMELS);
5074 -                               context->count += xfs_namespaces[ns].namelen
5075 -                                               + (int)name_rmt->namelen + 1;
5076 +                               context->count += namesp->attr_namelen +
5077 +                                               (int)name_rmt->namelen + 1;
5078                         } else {
5079 -                               retval = xfs_attr_put_listent(context, ns,
5080 +                               retval = xfs_attr_put_listent(context, namesp,
5081                                         (char *)name_rmt->name,
5082                                         (int)name_rmt->namelen,
5083                                         (int)INT_GET(name_rmt->valuelen,
5084 @@ -2333,7 +2342,7 @@
5085  /*ARGSUSED*/
5086  int
5087  xfs_attr_put_listent(xfs_attr_list_context_t *context,
5088 -                    int ns, char *name, int namelen, int valuelen)
5089 +                    attrnames_t *namesp, char *name, int namelen, int valuelen)
5090  {
5091         attrlist_ent_t *aep;
5092         int arraytop;
5093 @@ -2341,23 +2350,21 @@
5094         ASSERT(!(context->flags & ATTR_KERNOVAL));
5095         if (context->flags & ATTR_KERNAMELS) {
5096                 char *offset;
5097 -               xattr_namespace_t *nsp;
5098  
5099                 ASSERT(context->count >= 0);
5100  
5101 -               nsp = &xfs_namespaces[ns];
5102 -               arraytop = context->count + nsp->namelen + namelen+1;
5103 +               arraytop = context->count + namesp->attr_namelen + namelen + 1;
5104                 if (arraytop > context->firstu) {
5105                         context->count = -1;    /* insufficient space */
5106                         return(1);
5107                 }
5108                 offset = (char *)context->alist + context->count;
5109 -               strncpy(offset, nsp->name, nsp->namelen);       /* namespace */
5110 -               offset += nsp->namelen;
5111 +               strncpy(offset, namesp->attr_name, namesp->attr_namelen);
5112 +               offset += namesp->attr_namelen;
5113                 strncpy(offset, name, namelen);                 /* real name */
5114                 offset += namelen;
5115                 *offset = '\0';
5116 -               context->count += nsp->namelen + namelen + 1;
5117 +               context->count += namesp->attr_namelen + namelen + 1;
5118                 return(0);
5119         }
5120  
5121 diff -urN linux.org/fs/xfs/xfs_attr_leaf.h linux/fs/xfs/xfs_attr_leaf.h
5122 --- linux.org/fs/xfs/xfs_attr_leaf.h    2003-12-31 05:46:18.000000000 +0100
5123 +++ linux/fs/xfs/xfs_attr_leaf.h        2004-01-02 04:21:42.000000000 +0100
5124 @@ -1,5 +1,5 @@
5125  /*
5126 - * Copyright (c) 2000, 2002 Silicon Graphics, Inc.  All Rights Reserved.
5127 + * Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
5128   *
5129   * This program is free software; you can redistribute it and/or modify it
5130   * under the terms of version 2 of the GNU General Public License as
5131 @@ -44,6 +44,7 @@
5132  
5133  struct attrlist;
5134  struct attrlist_cursor_kern;
5135 +struct attrnames;
5136  struct xfs_dabuf;
5137  struct xfs_da_args;
5138  struct xfs_da_state;
5139 @@ -128,7 +129,7 @@
5140   * on the system call, they are "or"ed together for various operations.
5141   */
5142  #define        XFS_ATTR_LOCAL_BIT      0       /* attr is stored locally */
5143 -#define        XFS_ATTR_ROOT_BIT       1       /* limit access to attr to userid 0 */
5144 +#define        XFS_ATTR_ROOT_BIT       1       /* limit access to trusted attrs */
5145  #define        XFS_ATTR_INCOMPLETE_BIT 7       /* attr in middle of create/delete */
5146  #define XFS_ATTR_LOCAL         (1 << XFS_ATTR_LOCAL_BIT)
5147  #define XFS_ATTR_ROOT          (1 << XFS_ATTR_ROOT_BIT)
5148 @@ -299,7 +300,8 @@
5149                                         int *local);
5150  int    xfs_attr_leaf_entsize(struct xfs_attr_leafblock *leaf, int index);
5151  int    xfs_attr_put_listent(struct xfs_attr_list_context *context,
5152 -                            int ns, char *name, int namelen, int valuelen);
5153 +                            struct attrnames *, char *name, int namelen,
5154 +                            int valuelen);
5155  int    xfs_attr_rolltrans(struct xfs_trans **transp, struct xfs_inode *dp);
5156  
5157  #endif /* __XFS_ATTR_LEAF_H__ */
5158 diff -urN linux.org/fs/xfs/xfs_attr_sf.h linux/fs/xfs/xfs_attr_sf.h
5159 --- linux.org/fs/xfs/xfs_attr_sf.h      2003-12-31 05:46:54.000000000 +0100
5160 +++ linux/fs/xfs/xfs_attr_sf.h  2004-01-02 04:21:42.000000000 +0100
5161 @@ -104,14 +104,7 @@
5162         (INT_GET(((xfs_attr_shortform_t *)((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT))
5163  #endif
5164  
5165 -#ifdef XFS_ALL_TRACE
5166 -#define        XFS_ATTR_TRACE
5167 -#endif
5168 -
5169 -#if !defined(DEBUG)
5170 -#undef XFS_ATTR_TRACE
5171 -#endif
5172 -
5173 +#if defined(XFS_ATTR_TRACE)
5174  /*
5175   * Kernel tracing support for attribute lists
5176   */
5177 @@ -121,6 +114,7 @@
5178  struct xfs_attr_leafblock;
5179  
5180  #define        XFS_ATTR_TRACE_SIZE     4096    /* size of global trace buffer */
5181 +extern ktrace_t        *xfs_attr_trace_buf;
5182  
5183  /*
5184   * Trace record types.
5185 @@ -130,8 +124,6 @@
5186  #define        XFS_ATTR_KTRACE_L_CB    3       /* context, btree */
5187  #define        XFS_ATTR_KTRACE_L_CL    4       /* context, leaf */
5188  
5189 -#if defined(XFS_ATTR_TRACE)
5190 -
5191  void xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context);
5192  void xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
5193                               struct xfs_da_intnode *node);
5194 diff -urN linux.org/fs/xfs/xfs_bmap_btree.c linux/fs/xfs/xfs_bmap_btree.c
5195 --- linux.org/fs/xfs/xfs_bmap_btree.c   2003-12-31 05:47:31.000000000 +0100
5196 +++ linux/fs/xfs/xfs_bmap_btree.c       2004-01-02 04:21:42.000000000 +0100
5197 @@ -81,6 +81,13 @@
5198  
5199  
5200  #if defined(XFS_BMBT_TRACE)
5201 +
5202 +static char    ARGS[] = "args";
5203 +static char    ENTRY[] = "entry";
5204 +static char    ERROR[] = "error";
5205 +#undef EXIT
5206 +static char    EXIT[] = "exit";
5207 +
5208  /*
5209   * Add a trace buffer entry for the arguments given to the routine,
5210   * generic form.
5211 @@ -305,11 +312,6 @@
5212         xfs_bmbt_trace_argik(fname, c, i, k, __LINE__)
5213  #define        XFS_BMBT_TRACE_CURSOR(c,s)      \
5214         xfs_bmbt_trace_cursor(fname, c, s, __LINE__)
5215 -static char    ARGS[] = "args";
5216 -static char    ENTRY[] = "entry";
5217 -static char    ERROR[] = "error";
5218 -#undef EXIT
5219 -static char    EXIT[] = "exit";
5220  #else
5221  #define        XFS_BMBT_TRACE_ARGBI(c,b,i)
5222  #define        XFS_BMBT_TRACE_ARGBII(c,b,i,j)
5223 diff -urN linux.org/fs/xfs/xfs_bmap_btree.h linux/fs/xfs/xfs_bmap_btree.h
5224 --- linux.org/fs/xfs/xfs_bmap_btree.h   2003-12-31 05:47:25.000000000 +0100
5225 +++ linux/fs/xfs/xfs_bmap_btree.h       2004-01-02 04:21:43.000000000 +0100
5226 @@ -435,6 +435,10 @@
5227          INT_GET((bb)->bb_numrecs, ARCH_CONVERT) <= (mp)->m_bmap_dmxr[(level) != 0])
5228  #endif
5229  
5230 +
5231 +#ifdef __KERNEL__
5232 +
5233 +#if defined(XFS_BMBT_TRACE)
5234  /*
5235   * Trace buffer entry types.
5236   */
5237 @@ -449,18 +453,9 @@
5238  
5239  #define XFS_BMBT_TRACE_SIZE    4096    /* size of global trace buffer */
5240  #define XFS_BMBT_KTRACE_SIZE   32      /* size of per-inode trace buffer */
5241 -
5242 -#if defined(XFS_ALL_TRACE)
5243 -#define XFS_BMBT_TRACE
5244 +extern ktrace_t        *xfs_bmbt_trace_buf;
5245  #endif
5246  
5247 -#if !defined(DEBUG)
5248 -#undef XFS_BMBT_TRACE
5249 -#endif
5250 -
5251 -
5252 -#ifdef __KERNEL__
5253 -
5254  /*
5255   * Prototypes for xfs_bmap.c to call.
5256   */
5257 diff -urN linux.org/fs/xfs/xfs_bmap.c linux/fs/xfs/xfs_bmap.c
5258 --- linux.org/fs/xfs/xfs_bmap.c 2003-12-31 05:48:24.000000000 +0100
5259 +++ linux/fs/xfs/xfs_bmap.c     2004-01-02 04:21:42.000000000 +0100
5260 @@ -68,9 +68,6 @@
5261  #include "xfs_trans_space.h"
5262  #include "xfs_buf_item.h"
5263  
5264 -#ifdef DEBUG
5265 -ktrace_t       *xfs_bmap_trace_buf;
5266 -#endif
5267  
5268  #ifdef XFSDEBUG
5269  STATIC void
5270 @@ -404,7 +401,7 @@
5271  #define        xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
5272  #endif /* DEBUG */
5273  
5274 -#if defined(DEBUG) && defined(XFS_RW_TRACE)
5275 +#if defined(XFS_RW_TRACE)
5276  STATIC void
5277  xfs_bunmap_trace(
5278         xfs_inode_t             *ip,
5279 @@ -414,7 +411,7 @@
5280         inst_t                  *ra);
5281  #else
5282  #define        xfs_bunmap_trace(ip, bno, len, flags, ra)
5283 -#endif /* DEBUG && XFS_RW_TRACE */
5284 +#endif /* XFS_RW_TRACE */
5285  
5286  STATIC int
5287  xfs_bmap_count_tree(
5288 @@ -3543,6 +3540,8 @@
5289  
5290  
5291  #ifdef XFS_BMAP_TRACE
5292 +ktrace_t       *xfs_bmap_trace_buf;
5293 +
5294  /*
5295   * Add a bmap trace buffer entry.  Base routine for the others.
5296   */
5297 @@ -3575,14 +3574,14 @@
5298                 (void *)(__psint_t)cnt,
5299                 (void *)(__psunsigned_t)(ip->i_ino >> 32),
5300                 (void *)(__psunsigned_t)(unsigned)ip->i_ino,
5301 -               (void *)(__psunsigned_t)(INT_GET(r1->l0, ARCH_CONVERT) >> 32),
5302 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r1->l0, ARCH_CONVERT)),
5303 -               (void *)(__psunsigned_t)(INT_GET(r1->l1, ARCH_CONVERT) >> 32),
5304 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r1->l1, ARCH_CONVERT)),
5305 -               (void *)(__psunsigned_t)(INT_GET(r2->l0, ARCH_CONVERT) >> 32),
5306 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r2->l0, ARCH_CONVERT)),
5307 -               (void *)(__psunsigned_t)(INT_GET(r2->l1, ARCH_CONVERT) >> 32),
5308 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r2->l1, ARCH_CONVERT))
5309 +               (void *)(__psunsigned_t)(r1->l0 >> 32),
5310 +               (void *)(__psunsigned_t)(unsigned)(r1->l0),
5311 +               (void *)(__psunsigned_t)(r1->l1 >> 32),
5312 +               (void *)(__psunsigned_t)(unsigned)(r1->l1),
5313 +               (void *)(__psunsigned_t)(r2->l0 >> 32),
5314 +               (void *)(__psunsigned_t)(unsigned)(r2->l0),
5315 +               (void *)(__psunsigned_t)(r2->l1 >> 32),
5316 +               (void *)(__psunsigned_t)(unsigned)(r2->l1)
5317                 );
5318         ASSERT(ip->i_xtrace);
5319         ktrace_enter(ip->i_xtrace,
5320 @@ -3592,14 +3591,14 @@
5321                 (void *)(__psint_t)cnt,
5322                 (void *)(__psunsigned_t)(ip->i_ino >> 32),
5323                 (void *)(__psunsigned_t)(unsigned)ip->i_ino,
5324 -               (void *)(__psunsigned_t)(INT_GET(r1->l0, ARCH_CONVERT) >> 32),
5325 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r1->l0, ARCH_CONVERT)),
5326 -               (void *)(__psunsigned_t)(INT_GET(r1->l1, ARCH_CONVERT) >> 32),
5327 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r1->l1, ARCH_CONVERT)),
5328 -               (void *)(__psunsigned_t)(INT_GET(r2->l0, ARCH_CONVERT) >> 32),
5329 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r2->l0, ARCH_CONVERT)),
5330 -               (void *)(__psunsigned_t)(INT_GET(r2->l1, ARCH_CONVERT) >> 32),
5331 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r2->l1, ARCH_CONVERT))
5332 +               (void *)(__psunsigned_t)(r1->l0 >> 32),
5333 +               (void *)(__psunsigned_t)(unsigned)(r1->l0),
5334 +               (void *)(__psunsigned_t)(r1->l1 >> 32),
5335 +               (void *)(__psunsigned_t)(unsigned)(r1->l1),
5336 +               (void *)(__psunsigned_t)(r2->l0 >> 32),
5337 +               (void *)(__psunsigned_t)(unsigned)(r2->l0),
5338 +               (void *)(__psunsigned_t)(r2->l1 >> 32),
5339 +               (void *)(__psunsigned_t)(unsigned)(r2->l1)
5340                 );
5341  }
5342  
5343 @@ -3722,7 +3721,7 @@
5344         return rval;
5345  }
5346  
5347 -#if defined(DEBUG) && defined(XFS_RW_TRACE)
5348 +#if defined(XFS_RW_TRACE)
5349  STATIC void
5350  xfs_bunmap_trace(
5351         xfs_inode_t             *ip,
5352 @@ -3742,7 +3741,7 @@
5353                 (void *)(__psint_t)((xfs_dfiloff_t)bno & 0xffffffff),
5354                 (void *)(__psint_t)len,
5355                 (void *)(__psint_t)flags,
5356 -               (void *)(__psint_t)private.p_cpuid,
5357 +               (void *)(unsigned long)current_cpu(),
5358                 (void *)ra,
5359                 (void *)0,
5360                 (void *)0,
5361 diff -urN linux.org/fs/xfs/xfs_bmap.h linux/fs/xfs/xfs_bmap.h
5362 --- linux.org/fs/xfs/xfs_bmap.h 2003-12-31 05:46:44.000000000 +0100
5363 +++ linux/fs/xfs/xfs_bmap.h     2004-01-02 04:21:42.000000000 +0100
5364 @@ -90,26 +90,6 @@
5365  #define        DELAYSTARTBLOCK         ((xfs_fsblock_t)-1LL)
5366  #define        HOLESTARTBLOCK          ((xfs_fsblock_t)-2LL)
5367  
5368 -/*
5369 - * Trace operations for bmap extent tracing
5370 - */
5371 -#define        XFS_BMAP_KTRACE_DELETE  1
5372 -#define        XFS_BMAP_KTRACE_INSERT  2
5373 -#define        XFS_BMAP_KTRACE_PRE_UP  3
5374 -#define        XFS_BMAP_KTRACE_POST_UP 4
5375 -
5376 -#define        XFS_BMAP_TRACE_SIZE     4096    /* size of global trace buffer */
5377 -#define        XFS_BMAP_KTRACE_SIZE    32      /* size of per-inode trace buffer */
5378 -
5379 -#if defined(XFS_ALL_TRACE)
5380 -#define        XFS_BMAP_TRACE
5381 -#endif
5382 -
5383 -#if !defined(DEBUG)
5384 -#undef XFS_BMAP_TRACE
5385 -#endif
5386 -
5387 -
5388  #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_INIT)
5389  void xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp);
5390  #define        XFS_BMAP_INIT(flp,fbp)  xfs_bmap_init(flp,fbp)
5391 @@ -142,6 +122,33 @@
5392  } xfs_bmalloca_t;
5393  
5394  #ifdef __KERNEL__
5395 +
5396 +#if defined(XFS_BMAP_TRACE)
5397 +/*
5398 + * Trace operations for bmap extent tracing
5399 + */
5400 +#define        XFS_BMAP_KTRACE_DELETE  1
5401 +#define        XFS_BMAP_KTRACE_INSERT  2
5402 +#define        XFS_BMAP_KTRACE_PRE_UP  3
5403 +#define        XFS_BMAP_KTRACE_POST_UP 4
5404 +
5405 +#define        XFS_BMAP_TRACE_SIZE     4096    /* size of global trace buffer */
5406 +#define        XFS_BMAP_KTRACE_SIZE    32      /* size of per-inode trace buffer */
5407 +extern ktrace_t        *xfs_bmap_trace_buf;
5408 +
5409 +/*
5410 + * Add bmap trace insert entries for all the contents of the extent list.
5411 + */
5412 +void
5413 +xfs_bmap_trace_exlist(
5414 +       char                    *fname,         /* function name */
5415 +       struct xfs_inode        *ip,            /* incore inode pointer */
5416 +       xfs_extnum_t            cnt,            /* count of entries in list */
5417 +       int                     whichfork);     /* data or attr fork */
5418 +#else
5419 +#define        xfs_bmap_trace_exlist(f,ip,c,w)
5420 +#endif
5421 +
5422  /*
5423   * Convert inode from non-attributed to attributed.
5424   * Must not be in a transaction, ip must not be locked.
5425 @@ -260,20 +267,6 @@
5426         struct xfs_inode        *ip,            /* incore inode */
5427         int                     whichfork);     /* data or attr fork */
5428  
5429 -#if defined(XFS_BMAP_TRACE)
5430 -/*
5431 - * Add bmap trace insert entries for all the contents of the extent list.
5432 - */
5433 -void
5434 -xfs_bmap_trace_exlist(
5435 -       char                    *fname,         /* function name */
5436 -       struct xfs_inode        *ip,            /* incore inode pointer */
5437 -       xfs_extnum_t            cnt,            /* count of entries in list */
5438 -       int                     whichfork);     /* data or attr fork */
5439 -#else
5440 -#define        xfs_bmap_trace_exlist(f,ip,c,w)
5441 -#endif
5442 -
5443  /*
5444   * Map file blocks to filesystem blocks.
5445   * File range is given by the bno/len pair.
5446 @@ -375,7 +368,7 @@
5447  int
5448  xfs_bmap_count_blocks(
5449         xfs_trans_t             *tp,
5450 -       xfs_inode_t             *ip,
5451 +       struct xfs_inode        *ip,
5452         int                     whichfork,
5453         int                     *count);
5454  
5455 diff -urN linux.org/fs/xfs/xfs_buf.h linux/fs/xfs/xfs_buf.h
5456 --- linux.org/fs/xfs/xfs_buf.h  2003-12-31 05:48:37.000000000 +0100
5457 +++ linux/fs/xfs/xfs_buf.h      2004-01-02 04:21:43.000000000 +0100
5458 @@ -181,7 +181,7 @@
5459  #define XFS_BUF_SET_VTYPE(bp, type)
5460  #define XFS_BUF_SET_REF(bp, ref)
5461  
5462 -#define XFS_BUF_ISPINNED(bp)   pagebuf_ispin(bp)
5463 +#define XFS_BUF_ISPINNED(bp)   pagebuf_ispin(bp)
5464  
5465  #define XFS_BUF_VALUSEMA(bp)   pagebuf_lock_value(bp)
5466  #define XFS_BUF_CPSEMA(bp)     (pagebuf_cond_lock(bp) == 0)
5467 @@ -191,13 +191,11 @@
5468  
5469  /* setup the buffer target from a buftarg structure */
5470  #define XFS_BUF_SET_TARGET(bp, target) \
5471 -       (bp)->pb_target = (target)
5472 -
5473 +               (bp)->pb_target = (target)
5474  #define XFS_BUF_TARGET(bp)     ((bp)->pb_target)
5475 +#define XFS_BUFTARG_NAME(target)       \
5476 +               pagebuf_target_name(target)
5477  
5478 -#define XFS_BUFTARG_NAME(target) \
5479 -       ({ char __b[BDEVNAME_SIZE]; bdevname((target->pbr_bdev), __b); __b; })
5480 -       
5481  #define XFS_BUF_SET_VTYPE_REF(bp, type, ref)
5482  #define XFS_BUF_SET_VTYPE(bp, type)
5483  #define XFS_BUF_SET_REF(bp, ref)
5484 @@ -231,18 +229,11 @@
5485         pagebuf_rele(bp);
5486  }
5487  
5488 -
5489  #define xfs_bpin(bp)           pagebuf_pin(bp)
5490  #define xfs_bunpin(bp)         pagebuf_unpin(bp)
5491  
5492 -#ifdef PAGEBUF_TRACE
5493 -# define PB_DEFINE_TRACES
5494 -# include <pagebuf/page_buf_trace.h>
5495 -# define xfs_buftrace(id, bp)  PB_TRACE(bp, PB_TRACE_REC(external), (void *)id)
5496 -#else
5497 -# define xfs_buftrace(id, bp)  do { } while (0)
5498 -#endif
5499 -
5500 +#define xfs_buftrace(id, bp)   \
5501 +           pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0))
5502  
5503  #define xfs_biodone(pb)                    \
5504             pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), 0)
5505 diff -urN linux.org/fs/xfs/xfs_buf_item.c linux/fs/xfs/xfs_buf_item.c
5506 --- linux.org/fs/xfs/xfs_buf_item.c     2003-12-31 05:46:23.000000000 +0100
5507 +++ linux/fs/xfs/xfs_buf_item.c 2004-01-02 04:21:43.000000000 +0100
5508 @@ -1207,13 +1207,14 @@
5509                      (void *)((unsigned long)bip->bli_flags),
5510                      (void *)((unsigned long)bip->bli_recur),
5511                      (void *)((unsigned long)atomic_read(&bip->bli_refcount)),
5512 -                    (void *)XFS_BUF_ADDR(bp),
5513 +                    (void *)((unsigned long)
5514 +                               (0xFFFFFFFF & XFS_BUF_ADDR(bp) >> 32)),
5515 +                    (void *)((unsigned long)(0xFFFFFFFF & XFS_BUF_ADDR(bp))),
5516                      (void *)((unsigned long)XFS_BUF_COUNT(bp)),
5517 -                    (void *)((unsigned long)(0xFFFFFFFF & (XFS_BFLAGS(bp) >> 32))),
5518 -                    (void *)((unsigned long)(0xFFFFFFFF & XFS_BFLAGS(bp))),
5519 +                    (void *)((unsigned long)XFS_BUF_BFLAGS(bp)),
5520                      XFS_BUF_FSPRIVATE(bp, void *),
5521                      XFS_BUF_FSPRIVATE2(bp, void *),
5522 -                    (void *)((unsigned long)bp->b_pincount),
5523 +                    (void *)(unsigned long)XFS_BUF_ISPINNED(bp),
5524                      (void *)XFS_BUF_IODONE_FUNC(bp),
5525                      (void *)((unsigned long)(XFS_BUF_VALUSEMA(bp))),
5526                      (void *)bip->bli_item.li_desc,
5527 diff -urN linux.org/fs/xfs/xfs_buf_item.h linux/fs/xfs/xfs_buf_item.h
5528 --- linux.org/fs/xfs/xfs_buf_item.h     2003-12-31 05:48:00.000000000 +0100
5529 +++ linux/fs/xfs/xfs_buf_item.h 2004-01-02 04:21:43.000000000 +0100
5530 @@ -104,6 +104,15 @@
5531  struct xfs_buf;
5532  struct ktrace;
5533  struct xfs_mount;
5534 +struct xfs_buf_log_item;
5535 +
5536 +#if defined(XFS_BLI_TRACE)
5537 +#define        XFS_BLI_TRACE_SIZE      32
5538 +
5539 +void   xfs_buf_item_trace(char *, struct xfs_buf_log_item *);
5540 +#else
5541 +#define        xfs_buf_item_trace(id, bip)
5542 +#endif
5543  
5544  /*
5545   * This is the in core log item structure used to track information
5546 @@ -116,7 +125,7 @@
5547         unsigned int            bli_flags;      /* misc flags */
5548         unsigned int            bli_recur;      /* lock recursion count */
5549         atomic_t                bli_refcount;   /* cnt of tp refs */
5550 -#ifdef DEBUG
5551 +#ifdef XFS_BLI_TRACE
5552         struct ktrace           *bli_trace;     /* event trace buf */
5553  #endif
5554  #ifdef XFS_TRANS_DEBUG
5555 @@ -137,23 +146,6 @@
5556         struct xfs_buf_cancel   *bc_next;
5557  } xfs_buf_cancel_t;
5558  
5559 -#define        XFS_BLI_TRACE_SIZE      32
5560 -
5561 -
5562 -#if defined(XFS_ALL_TRACE)
5563 -#define        XFS_BLI_TRACE
5564 -#endif
5565 -
5566 -#if !defined(DEBUG)
5567 -#undef XFS_BLI_TRACE
5568 -#endif
5569 -
5570 -#if defined(XFS_BLI_TRACE)
5571 -void   xfs_buf_item_trace(char *, xfs_buf_log_item_t *);
5572 -#else
5573 -#define        xfs_buf_item_trace(id, bip)
5574 -#endif
5575 -
5576  void   xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
5577  void   xfs_buf_item_relse(struct xfs_buf *);
5578  void   xfs_buf_item_log(xfs_buf_log_item_t *, uint, uint);
5579 diff -urN linux.org/fs/xfs/xfs_da_btree.c linux/fs/xfs/xfs_da_btree.c
5580 --- linux.org/fs/xfs/xfs_da_btree.c     2003-12-31 05:48:06.000000000 +0100
5581 +++ linux/fs/xfs/xfs_da_btree.c 2004-01-02 04:21:43.000000000 +0100
5582 @@ -66,13 +66,6 @@
5583  #include "xfs_error.h"
5584  #include "xfs_bit.h"
5585  
5586 -#if defined(XFSDEBUG) && defined(CONFIG_KDB)
5587 -#undef xfs_buftrace
5588 -#define xfs_buftrace(A,B) \
5589 -       printk("    xfs_buftrace : %s (0x%p)\n", A, B); \
5590 -       BUG();
5591 -#endif
5592 -
5593  /*
5594   * xfs_da_btree.c
5595   *
5596 diff -urN linux.org/fs/xfs/xfs_dfrag.c linux/fs/xfs/xfs_dfrag.c
5597 --- linux.org/fs/xfs/xfs_dfrag.c        2003-12-31 05:46:28.000000000 +0100
5598 +++ linux/fs/xfs/xfs_dfrag.c    2004-01-02 04:21:43.000000000 +0100
5599 @@ -153,12 +153,12 @@
5600         if ((error = _MAC_XFS_IACCESS(tip, MACWRITE, NULL))) {
5601                 goto error0;
5602         }
5603 -       if ((current->fsuid != ip->i_d.di_uid) &&
5604 +       if ((current_fsuid(cred) != ip->i_d.di_uid) &&
5605             (error = xfs_iaccess(ip, S_IWUSR, NULL)) &&
5606             !capable_cred(NULL, CAP_FOWNER)) {
5607                 goto error0;
5608         }
5609 -       if ((current->fsuid != tip->i_d.di_uid) &&
5610 +       if ((current_fsuid(cred) != tip->i_d.di_uid) &&
5611             (error = xfs_iaccess(tip, S_IWUSR, NULL)) &&
5612             !capable_cred(NULL, CAP_FOWNER)) {
5613                 goto error0;
5614 diff -urN linux.org/fs/xfs/xfs_dir2_trace.c linux/fs/xfs/xfs_dir2_trace.c
5615 --- linux.org/fs/xfs/xfs_dir2_trace.c   2003-12-31 05:48:09.000000000 +0100
5616 +++ linux/fs/xfs/xfs_dir2_trace.c       2004-01-02 04:21:44.000000000 +0100
5617 @@ -1,5 +1,5 @@
5618  /*
5619 - * Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
5620 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
5621   *
5622   * This program is free software; you can redistribute it and/or modify it
5623   * under the terms of version 2 of the GNU General Public License as
5624 @@ -64,36 +64,37 @@
5625         char            *where,
5626         char            *name,
5627         int             namelen,
5628 -       __psunsigned_t  a0,
5629 -       __psunsigned_t  a1,
5630 -       __psunsigned_t  a2,
5631 -       __psunsigned_t  a3,
5632 -       __psunsigned_t  a4,
5633 -       __psunsigned_t  a5,
5634 -       __psunsigned_t  a6)
5635 +       void            *a0,
5636 +       void            *a1,
5637 +       void            *a2,
5638 +       void            *a3,
5639 +       void            *a4,
5640 +       void            *a5,
5641 +       void            *a6,
5642 +       void            *a7)
5643  {
5644 -       __psunsigned_t  n[6];
5645 +       void            *n[5];
5646  
5647         ASSERT(xfs_dir2_trace_buf);
5648         ASSERT(dp->i_dir_trace);
5649         if (name)
5650 -               memcpy(n, name, min(sizeof(n), namelen));
5651 +               memcpy(n, name, min((int)sizeof(n), namelen));
5652         else
5653                 memset((char *)n, 0, sizeof(n));
5654         ktrace_enter(xfs_dir2_trace_buf,
5655 -               (void *)(__psunsigned_t)type, (void *)where,
5656 +               (void *)(long)type, (void *)where,
5657                 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
5658 -               (void *)a4, (void *)a5, (void *)a6,
5659 -               (void *)(__psunsigned_t)namelen,
5660 +               (void *)a4, (void *)a5, (void *)a6, (void *)a7,
5661 +               (void *)(long)namelen,
5662                 (void *)n[0], (void *)n[1], (void *)n[2],
5663 -               (void *)n[3], (void *)n[4], (void *)n[5]);
5664 +               (void *)n[3], (void *)n[4]);
5665         ktrace_enter(dp->i_dir_trace,
5666 -               (void *)(__psunsigned_t)type, (void *)where,
5667 +               (void *)(long)type, (void *)where,
5668                 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
5669 -               (void *)a4, (void *)a5, (void *)a6,
5670 -               (void *)(__psunsigned_t)namelen,
5671 +               (void *)a4, (void *)a5, (void *)a6, (void *)a7,
5672 +               (void *)(long)namelen,
5673                 (void *)n[0], (void *)n[1], (void *)n[2],
5674 -               (void *)n[3], (void *)n[4], (void *)n[5]);
5675 +               (void *)n[3], (void *)n[4]);
5676  }
5677  
5678  void
5679 @@ -103,9 +104,11 @@
5680  {
5681         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS, where,
5682                 (char *)args->name, (int)args->namelen,
5683 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5684 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5685 -               (__psunsigned_t)args->justcheck, 0, 0);
5686 +               (void *)(unsigned long)args->hashval,
5687 +               (void *)((unsigned long)(args->inumber >> 32)),
5688 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5689 +               (void *)args->dp, (void *)args->trans,
5690 +               (void *)(unsigned long)args->justcheck, NULL, NULL);
5691  }
5692  
5693  void
5694 @@ -116,10 +119,12 @@
5695  {
5696         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_B, where,
5697                 (char *)args->name, (int)args->namelen,
5698 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5699 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5700 -               (__psunsigned_t)args->justcheck,
5701 -               (__psunsigned_t)(bp ? bp->bps[0] : NULL), 0);
5702 +               (void *)(unsigned long)args->hashval,
5703 +               (void *)((unsigned long)(args->inumber >> 32)),
5704 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5705 +               (void *)args->dp, (void *)args->trans,
5706 +               (void *)(unsigned long)args->justcheck,
5707 +               (void *)(bp ? bp->bps[0] : NULL), NULL);
5708  }
5709  
5710  void
5711 @@ -131,11 +136,13 @@
5712  {
5713         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BB, where,
5714                 (char *)args->name, (int)args->namelen,
5715 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5716 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5717 -               (__psunsigned_t)args->justcheck,
5718 -               (__psunsigned_t)(lbp ? lbp->bps[0] : NULL),
5719 -               (__psunsigned_t)(dbp ? dbp->bps[0] : NULL));
5720 +               (void *)(unsigned long)args->hashval,
5721 +               (void *)((unsigned long)(args->inumber >> 32)),
5722 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5723 +               (void *)args->dp, (void *)args->trans,
5724 +               (void *)(unsigned long)args->justcheck,
5725 +               (void *)(lbp ? lbp->bps[0] : NULL),
5726 +               (void *)(dbp ? dbp->bps[0] : NULL));
5727  }
5728  
5729  void
5730 @@ -148,12 +155,14 @@
5731         int             sd,
5732         int             c)
5733  {
5734 +       xfs_buf_t       *bpbs = bs ? bs->bps[0] : NULL;
5735 +       xfs_buf_t       *bpbd = bd ? bd->bps[0] : NULL;
5736 +
5737         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BIBII, where,
5738                 (char *)args->name, (int)args->namelen,
5739 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5740 -               (__psunsigned_t)(bs ? bs->bps[0] : NULL), (__psunsigned_t)ss,
5741 -               (__psunsigned_t)(bd ? bd->bps[0] : NULL), (__psunsigned_t)sd,
5742 -               (__psunsigned_t)c);
5743 +               (void *)args->dp, (void *)args->trans,
5744 +               (void *)bpbs, (void *)(long)ss, (void *)bpbd, (void *)(long)sd,
5745 +               (void *)(long)c, NULL);
5746  }
5747  
5748  void
5749 @@ -163,12 +172,16 @@
5750         xfs_dir2_db_t   db,
5751         xfs_dabuf_t     *bp)
5752  {
5753 +       xfs_buf_t       *dbp = bp ? bp->bps[0] : NULL;
5754 +
5755         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_DB, where,
5756                 (char *)args->name, (int)args->namelen,
5757 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5758 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5759 -               (__psunsigned_t)args->justcheck, (__psunsigned_t)db,
5760 -               (__psunsigned_t)(bp ? bp->bps[0] : NULL));
5761 +               (void *)(unsigned long)args->hashval,
5762 +               (void *)((unsigned long)(args->inumber >> 32)),
5763 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5764 +               (void *)args->dp, (void *)args->trans,
5765 +               (void *)(unsigned long)args->justcheck, (void *)(long)db,
5766 +               (void *)dbp);
5767  }
5768  
5769  void
5770 @@ -179,9 +192,13 @@
5771  {
5772         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_I, where,
5773                 (char *)args->name, (int)args->namelen,
5774 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5775 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5776 -               (__psunsigned_t)args->justcheck, (__psunsigned_t)i, 0);
5777 +               (void *)(unsigned long)args->hashval,
5778 +               (void *)((unsigned long)(args->inumber >> 32)),
5779 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5780 +               (void *)args->dp, (void *)args->trans,
5781 +               (void *)(unsigned long)args->justcheck,
5782 +               (void *)((unsigned long)(i >> 32)),
5783 +               (void *)((unsigned long)(i & 0xFFFFFFFF)));
5784  }
5785  
5786  void
5787 @@ -192,9 +209,11 @@
5788  {
5789         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_S, where,
5790                 (char *)args->name, (int)args->namelen,
5791 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5792 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5793 -               (__psunsigned_t)args->justcheck, (__psunsigned_t)s, 0);
5794 +               (void *)(unsigned long)args->hashval,
5795 +               (void *)((unsigned long)(args->inumber >> 32)),
5796 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5797 +               (void *)args->dp, (void *)args->trans,
5798 +               (void *)(unsigned long)args->justcheck, (void *)(long)s, 0);
5799  }
5800  
5801  void
5802 @@ -204,11 +223,15 @@
5803         int             s,
5804         xfs_dabuf_t     *bp)
5805  {
5806 +       xfs_buf_t       *dbp = bp ? bp->bps[0] : NULL;
5807 +
5808         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_SB, where,
5809                 (char *)args->name, (int)args->namelen,
5810 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5811 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5812 -               (__psunsigned_t)args->justcheck, (__psunsigned_t)s,
5813 -               (__psunsigned_t)(bp ? bp->bps[0] : NULL));
5814 +               (void *)(unsigned long)args->hashval,
5815 +               (void *)((unsigned long)(args->inumber >> 32)),
5816 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5817 +               (void *)args->dp, (void *)args->trans,
5818 +               (void *)(unsigned long)args->justcheck, (void *)(long)s,
5819 +               (void *)dbp);
5820  }
5821  #endif /* XFS_DIR2_TRACE */
5822 diff -urN linux.org/fs/xfs/xfs_dir2_trace.h linux/fs/xfs/xfs_dir2_trace.h
5823 --- linux.org/fs/xfs/xfs_dir2_trace.h   2003-12-31 05:46:56.000000000 +0100
5824 +++ linux/fs/xfs/xfs_dir2_trace.h       2004-01-02 04:21:44.000000000 +0100
5825 @@ -36,20 +36,15 @@
5826   * Tracing for xfs v2 directories.
5827   */
5828  
5829 +#if defined(XFS_DIR2_TRACE)
5830 +
5831  struct ktrace;
5832  struct xfs_dabuf;
5833  struct xfs_da_args;
5834  
5835 -#ifdef XFS_ALL_TRACE
5836 -#define XFS_DIR2_TRACE
5837 -#endif /* XFS_ALL_TRACE */
5838 -
5839 -#if !defined(DEBUG)
5840 -#undef XFS_DIR2_TRACE
5841 -#endif /* !DEBUG */
5842 -
5843  #define        XFS_DIR2_GTRACE_SIZE            4096    /* global buffer */
5844  #define        XFS_DIR2_KTRACE_SIZE            32      /* per-inode buffer */
5845 +extern struct ktrace *xfs_dir2_trace_buf;
5846  
5847  #define        XFS_DIR2_KTRACE_ARGS            1       /* args only */
5848  #define        XFS_DIR2_KTRACE_ARGS_B          2       /* args + buffer */
5849 @@ -60,8 +55,6 @@
5850  #define        XFS_DIR2_KTRACE_ARGS_SB         7       /* args, int, buffer */
5851  #define        XFS_DIR2_KTRACE_ARGS_BIBII      8       /* args, buf/int/buf/int/int */
5852  
5853 -#ifdef XFS_DIR2_TRACE
5854 -
5855  void xfs_dir2_trace_args(char *where, struct xfs_da_args *args);
5856  void xfs_dir2_trace_args_b(char *where, struct xfs_da_args *args,
5857                            struct xfs_dabuf *bp);
5858 @@ -90,6 +83,4 @@
5859  
5860  #endif /* XFS_DIR2_TRACE */
5861  
5862 -extern struct ktrace *xfs_dir2_trace_buf;
5863 -
5864  #endif /* __XFS_DIR2_TRACE_H__ */
5865 diff -urN linux.org/fs/xfs/xfs_dir.c linux/fs/xfs/xfs_dir.c
5866 --- linux.org/fs/xfs/xfs_dir.c  2003-12-31 05:46:43.000000000 +0100
5867 +++ linux/fs/xfs/xfs_dir.c      2004-01-02 04:21:43.000000000 +0100
5868 @@ -1093,10 +1093,10 @@
5869  xfs_dir_trace_g_du(char *where, xfs_inode_t *dp, uio_t *uio)
5870  {
5871         xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DU, where,
5872 -                    (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
5873 -                    (__psunsigned_t)(uio->uio_offset >> 32),
5874 -                    (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
5875 -                    (__psunsigned_t)uio->uio_resid,
5876 +                    (void *)dp, (void *)dp->i_mount,
5877 +                    (void *)((unsigned long)(uio->uio_offset >> 32)),
5878 +                    (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
5879 +                    (void *)(unsigned long)uio->uio_resid,
5880                      NULL, NULL, NULL, NULL, NULL, NULL, NULL);
5881  }
5882  
5883 @@ -1107,11 +1107,11 @@
5884  xfs_dir_trace_g_dub(char *where, xfs_inode_t *dp, uio_t *uio, xfs_dablk_t bno)
5885  {
5886         xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUB, where,
5887 -                    (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
5888 -                    (__psunsigned_t)(uio->uio_offset >> 32),
5889 -                    (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
5890 -                    (__psunsigned_t)uio->uio_resid,
5891 -                    (__psunsigned_t)bno,
5892 +                    (void *)dp, (void *)dp->i_mount,
5893 +                    (void *)((unsigned long)(uio->uio_offset >> 32)),
5894 +                    (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
5895 +                    (void *)(unsigned long)uio->uio_resid,
5896 +                    (void *)(unsigned long)bno,
5897                      NULL, NULL, NULL, NULL, NULL, NULL);
5898  }
5899  
5900 @@ -1122,15 +1122,21 @@
5901  xfs_dir_trace_g_dun(char *where, xfs_inode_t *dp, uio_t *uio,
5902                         xfs_da_intnode_t *node)
5903  {
5904 +       int     last = INT_GET(node->hdr.count, ARCH_CONVERT) - 1;
5905 +
5906         xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUN, where,
5907 -                    (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
5908 -                    (__psunsigned_t)(uio->uio_offset >> 32),
5909 -                    (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
5910 -                    (__psunsigned_t)uio->uio_resid,
5911 -                    (__psunsigned_t)INT_GET(node->hdr.info.forw, ARCH_CONVERT),
5912 -                    (__psunsigned_t)INT_GET(node->hdr.count, ARCH_CONVERT),
5913 -                    (__psunsigned_t)INT_GET(node->btree[0].hashval, ARCH_CONVERT),
5914 -                    (__psunsigned_t)INT_GET(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT),
5915 +                    (void *)dp, (void *)dp->i_mount,
5916 +                    (void *)((unsigned long)(uio->uio_offset >> 32)),
5917 +                    (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
5918 +                    (void *)(unsigned long)uio->uio_resid,
5919 +                    (void *)(unsigned long)
5920 +                       INT_GET(node->hdr.info.forw, ARCH_CONVERT),
5921 +                    (void *)(unsigned long)
5922 +                       INT_GET(node->hdr.count, ARCH_CONVERT),
5923 +                    (void *)(unsigned long)
5924 +                       INT_GET(node->btree[0].hashval, ARCH_CONVERT),
5925 +                    (void *)(unsigned long)
5926 +                       INT_GET(node->btree[last].hashval, ARCH_CONVERT),
5927                      NULL, NULL, NULL);
5928  }
5929  
5930 @@ -1141,15 +1147,21 @@
5931  xfs_dir_trace_g_dul(char *where, xfs_inode_t *dp, uio_t *uio,
5932                         xfs_dir_leafblock_t *leaf)
5933  {
5934 +       int     last = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1;
5935 +
5936         xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUL, where,
5937 -                    (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
5938 -                    (__psunsigned_t)(uio->uio_offset >> 32),
5939 -                    (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
5940 -                    (__psunsigned_t)uio->uio_resid,
5941 -                    (__psunsigned_t)INT_GET(leaf->hdr.info.forw, ARCH_CONVERT),
5942 -                    (__psunsigned_t)INT_GET(leaf->hdr.count, ARCH_CONVERT),
5943 -                    (__psunsigned_t)INT_GET(leaf->entries[0].hashval, ARCH_CONVERT),
5944 -                    (__psunsigned_t)INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT),
5945 +                    (void *)dp, (void *)dp->i_mount,
5946 +                    (void *)((unsigned long)(uio->uio_offset >> 32)),
5947 +                    (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
5948 +                    (void *)(unsigned long)uio->uio_resid,
5949 +                    (void *)(unsigned long)
5950 +                       INT_GET(leaf->hdr.info.forw, ARCH_CONVERT),
5951 +                    (void *)(unsigned long)
5952 +                       INT_GET(leaf->hdr.count, ARCH_CONVERT),
5953 +                    (void *)(unsigned long)
5954 +                       INT_GET(leaf->entries[0].hashval, ARCH_CONVERT),
5955 +                    (void *)(unsigned long)
5956 +                       INT_GET(leaf->entries[last].hashval, ARCH_CONVERT),
5957                      NULL, NULL, NULL);
5958  }
5959  
5960 @@ -1161,11 +1173,12 @@
5961                         xfs_dir_leaf_entry_t *entry)
5962  {
5963         xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUE, where,
5964 -                    (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
5965 -                    (__psunsigned_t)(uio->uio_offset >> 32),
5966 -                    (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
5967 -                    (__psunsigned_t)uio->uio_resid,
5968 -                    (__psunsigned_t)INT_GET(entry->hashval, ARCH_CONVERT),
5969 +                    (void *)dp, (void *)dp->i_mount,
5970 +                    (void *)((unsigned long)(uio->uio_offset >> 32)),
5971 +                    (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
5972 +                    (void *)(unsigned long)uio->uio_resid,
5973 +                    (void *)(unsigned long)
5974 +                       INT_GET(entry->hashval, ARCH_CONVERT),
5975                      NULL, NULL, NULL, NULL, NULL, NULL);
5976  }
5977  
5978 @@ -1176,12 +1189,12 @@
5979  xfs_dir_trace_g_duc(char *where, xfs_inode_t *dp, uio_t *uio, xfs_off_t cookie)
5980  {
5981         xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUC, where,
5982 -                    (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
5983 -                    (__psunsigned_t)(uio->uio_offset >> 32),
5984 -                    (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
5985 -                    (__psunsigned_t)uio->uio_resid,
5986 -                    (__psunsigned_t)(cookie >> 32),
5987 -                    (__psunsigned_t)(cookie & 0xFFFFFFFF),
5988 +                    (void *)dp, (void *)dp->i_mount,
5989 +                    (void *)((unsigned long)(uio->uio_offset >> 32)),
5990 +                    (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
5991 +                    (void *)(unsigned long)uio->uio_resid,
5992 +                    (void *)((unsigned long)(cookie >> 32)),
5993 +                    (void *)((unsigned long)(cookie & 0xFFFFFFFF)),
5994                      NULL, NULL, NULL, NULL, NULL);
5995  }
5996  
5997 @@ -1191,15 +1204,15 @@
5998   */
5999  void
6000  xfs_dir_trace_enter(int type, char *where,
6001 -                       __psunsigned_t a0, __psunsigned_t a1,
6002 -                       __psunsigned_t a2, __psunsigned_t a3,
6003 -                       __psunsigned_t a4, __psunsigned_t a5,
6004 -                       __psunsigned_t a6, __psunsigned_t a7,
6005 -                       __psunsigned_t a8, __psunsigned_t a9,
6006 -                       __psunsigned_t a10, __psunsigned_t a11)
6007 +                       void * a0, void * a1,
6008 +                       void * a2, void * a3,
6009 +                       void * a4, void * a5,
6010 +                       void * a6, void * a7,
6011 +                       void * a8, void * a9,
6012 +                       void * a10, void * a11)
6013  {
6014         ASSERT(xfs_dir_trace_buf);
6015 -       ktrace_enter(xfs_dir_trace_buf, (void *)((__psunsigned_t)type),
6016 +       ktrace_enter(xfs_dir_trace_buf, (void *)(unsigned long)type,
6017                                         (void *)where,
6018                                         (void *)a0, (void *)a1, (void *)a2,
6019                                         (void *)a3, (void *)a4, (void *)a5,
6020 diff -urN linux.org/fs/xfs/xfs_dir.h linux/fs/xfs/xfs_dir.h
6021 --- linux.org/fs/xfs/xfs_dir.h  2003-12-31 05:46:52.000000000 +0100
6022 +++ linux/fs/xfs/xfs_dir.h      2004-01-02 04:21:43.000000000 +0100
6023 @@ -43,14 +43,6 @@
6024   * as possible so as to fit into the literal area of the inode.
6025   */
6026  
6027 -#ifdef XFS_ALL_TRACE
6028 -#define        XFS_DIR_TRACE
6029 -#endif
6030 -
6031 -#if !defined(DEBUG)
6032 -#undef XFS_DIR_TRACE
6033 -#endif
6034 -
6035  /*========================================================================
6036   * Function prototypes for the kernel.
6037   *========================================================================*/
6038 diff -urN linux.org/fs/xfs/xfs_dir_sf.h linux/fs/xfs/xfs_dir_sf.h
6039 --- linux.org/fs/xfs/xfs_dir_sf.h       2003-12-31 05:47:55.000000000 +0100
6040 +++ linux/fs/xfs/xfs_dir_sf.h   2004-01-02 04:21:44.000000000 +0100
6041 @@ -126,13 +126,7 @@
6042                ((uint)sizeof(xfs_dir_sf_entry_t)-1)*(count) + (totallen))
6043  #endif
6044  
6045 -#ifdef XFS_ALL_TRACE
6046 -#define        XFS_DIR_TRACE
6047 -#endif
6048 -
6049 -#if !defined(DEBUG)
6050 -#undef XFS_DIR_TRACE
6051 -#endif
6052 +#if defined(XFS_DIR_TRACE)
6053  
6054  /*
6055   * Kernel tracing support for directories.
6056 @@ -145,6 +139,7 @@
6057  struct xfs_dir_leaf_entry;
6058  
6059  #define        XFS_DIR_TRACE_SIZE      4096    /* size of global trace buffer */
6060 +extern ktrace_t        *xfs_dir_trace_buf;
6061  
6062  /*
6063   * Trace record types.
6064 @@ -156,8 +151,6 @@
6065  #define        XFS_DIR_KTRACE_G_DUE    5       /* dp, uio, leaf entry */
6066  #define        XFS_DIR_KTRACE_G_DUC    6       /* dp, uio, cookie */
6067  
6068 -#if defined(XFS_DIR_TRACE)
6069 -
6070  void xfs_dir_trace_g_du(char *where, struct xfs_inode *dp, struct uio *uio);
6071  void xfs_dir_trace_g_dub(char *where, struct xfs_inode *dp, struct uio *uio,
6072                               xfs_dablk_t bno);
6073 @@ -170,12 +163,9 @@
6074  void xfs_dir_trace_g_duc(char *where, struct xfs_inode *dp, struct uio *uio,
6075                               xfs_off_t cookie);
6076  void xfs_dir_trace_enter(int type, char *where,
6077 -                            __psunsigned_t a0, __psunsigned_t a1,
6078 -                            __psunsigned_t a2, __psunsigned_t a3,
6079 -                            __psunsigned_t a4, __psunsigned_t a5,
6080 -                            __psunsigned_t a6, __psunsigned_t a7,
6081 -                            __psunsigned_t a8, __psunsigned_t a9,
6082 -                            __psunsigned_t a10, __psunsigned_t a11);
6083 +                            void *a0, void *a1, void *a2, void *a3,
6084 +                            void *a4, void *a5, void *a6, void *a7,
6085 +                            void *a8, void *a9, void *a10, void *a11);
6086  #else
6087  #define        xfs_dir_trace_g_du(w,d,u)
6088  #define        xfs_dir_trace_g_dub(w,d,u,b)
6089 diff -urN linux.org/fs/xfs/xfs_dmapi.h linux/fs/xfs/xfs_dmapi.h
6090 --- linux.org/fs/xfs/xfs_dmapi.h        2003-12-31 05:48:36.000000000 +0100
6091 +++ linux/fs/xfs/xfs_dmapi.h    2004-01-02 04:21:44.000000000 +0100
6092 @@ -175,14 +175,6 @@
6093                         DM_FLAGS_NDELAY : 0)
6094  #define AT_DELAY_FLAG(f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)
6095  
6096 -/*
6097 - *     Macros to turn caller specified delay/block flags into
6098 - *     dm_send_xxxx_event flag DM_FLAGS_NDELAY.
6099 - */
6100 -
6101 -#define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \
6102 -                       DM_FLAGS_NDELAY : 0)
6103 -
6104  
6105  extern struct bhv_vfsops xfs_dmops;
6106  
6107 diff -urN linux.org/fs/xfs/xfs_dmops.c linux/fs/xfs/xfs_dmops.c
6108 --- linux.org/fs/xfs/xfs_dmops.c        2003-12-31 05:48:36.000000000 +0100
6109 +++ linux/fs/xfs/xfs_dmops.c    2004-01-02 04:21:44.000000000 +0100
6110 @@ -43,8 +43,6 @@
6111  #include "xfs_dmapi.h"
6112  #include "xfs_mount.h"
6113  
6114 -
6115 -#ifndef CONFIG_XFS_DMAPI
6116  xfs_dmops_t    xfs_dmcore_xfs = {
6117         .xfs_send_data          = (xfs_send_data_t)fs_nosys,
6118         .xfs_send_mmap          = (xfs_send_mmap_t)fs_noerr,
6119 @@ -52,4 +50,3 @@
6120         .xfs_send_namesp        = (xfs_send_namesp_t)fs_nosys,
6121         .xfs_send_unmount       = (xfs_send_unmount_t)fs_noval,
6122  };
6123 -#endif /* CONFIG_XFS_DMAPI */
6124 diff -urN linux.org/fs/xfs/xfs_error.c linux/fs/xfs/xfs_error.c
6125 --- linux.org/fs/xfs/xfs_error.c        2003-12-31 05:48:26.000000000 +0100
6126 +++ linux/fs/xfs/xfs_error.c    2004-01-02 04:21:44.000000000 +0100
6127 @@ -102,7 +102,7 @@
6128         if (random() % randfactor)
6129                 return 0;
6130  
6131 -       memcpy(&fsid, fsidp, sizeof(fsid_t));
6132 +       memcpy(&fsid, fsidp, sizeof(xfs_fsid_t));
6133  
6134         for (i = 0; i < XFS_NUM_INJECT_ERROR; i++)  {
6135                 if (xfs_etest[i] == error_tag && xfs_etest_fsid[i] == fsid) {
6136 @@ -123,7 +123,7 @@
6137         int len;
6138         int64_t fsid;
6139  
6140 -       memcpy(&fsid, mp->m_fixedfsid, sizeof(fsid_t));
6141 +       memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t));
6142  
6143         for (i = 0; i < XFS_NUM_INJECT_ERROR; i++)  {
6144                 if (xfs_etest_fsid[i] == fsid && xfs_etest[i] == error_tag) {
6145 @@ -156,7 +156,7 @@
6146         int i;
6147         int64_t fsid;
6148  
6149 -       memcpy(&fsid, mp->m_fixedfsid, sizeof(fsid_t));
6150 +       memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t));
6151  
6152         for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) {
6153                 if (xfs_etest_fsid[i] == fsid && xfs_etest[i] == error_tag) {
6154 @@ -209,7 +209,7 @@
6155  {
6156         int64_t fsid;
6157  
6158 -       memcpy(&fsid, mp->m_fixedfsid, sizeof(fsid_t));
6159 +       memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t));
6160  
6161         return xfs_errortag_clearall_umount(fsid, mp->m_fsname, 1);
6162  }
6163 @@ -258,12 +258,6 @@
6164  }
6165  
6166  void
6167 -xfs_stack_trace(void)
6168 -{
6169 -       dump_stack();
6170 -}
6171 -
6172 -void
6173  xfs_error_report(
6174         char            *tag,
6175         int             level,
6176 diff -urN linux.org/fs/xfs/xfs_fsops.c linux/fs/xfs/xfs_fsops.c
6177 --- linux.org/fs/xfs/xfs_fsops.c        2003-12-31 05:48:18.000000000 +0100
6178 +++ linux/fs/xfs/xfs_fsops.c    2004-01-02 04:21:42.000000000 +0100
6179 @@ -51,6 +51,7 @@
6180  #include "xfs_fsops.h"
6181  #include "xfs_itable.h"
6182  #include "xfs_rw.h"
6183 +#include "xfs_refcache.h"
6184  #include "xfs_trans_space.h"
6185  #include "xfs_rtalloc.h"
6186  #include "xfs_dir2.h"
6187 @@ -593,6 +594,9 @@
6188         /* Stop new writers */
6189         xfs_start_freeze(mp, XFS_FREEZE_WRITE);
6190  
6191 +       /* Flush the refcache */
6192 +       xfs_refcache_purge_mp(mp);
6193 +
6194         /* Flush delalloc and delwri data */
6195         VFS_SYNC(vfsp, SYNC_DELWRI|SYNC_WAIT, NULL, error);
6196  
6197 diff -urN linux.org/fs/xfs/xfsidbg.c linux/fs/xfs/xfsidbg.c
6198 --- linux.org/fs/xfs/xfsidbg.c  2003-12-31 05:48:07.000000000 +0100
6199 +++ linux/fs/xfs/xfsidbg.c      2004-01-02 04:21:43.000000000 +0100
6200 @@ -31,7 +31,6 @@
6201   */
6202  
6203  #include "xfs.h"
6204 -#include "pagebuf/page_buf_internal.h"
6205  
6206  #include <linux/ctype.h>
6207  #include <linux/kdb.h>
6208 @@ -61,9 +60,11 @@
6209  #include "xfs_attr_sf.h"
6210  #include "xfs_dir_sf.h"
6211  #include "xfs_dir2_sf.h"
6212 +#include "xfs_dir2_trace.h"
6213  #include "xfs_dinode.h"
6214 -#include "xfs_inode.h"
6215 +#include "xfs_rw.h"
6216  #include "xfs_bmap.h"
6217 +#include "xfs_inode.h"
6218  #include "xfs_da_btree.h"
6219  #include "xfs_attr.h"
6220  #include "xfs_attr_leaf.h"
6221 @@ -72,18 +73,66 @@
6222  #include "xfs_dir2_leaf.h"
6223  #include "xfs_dir2_block.h"
6224  #include "xfs_dir2_node.h"
6225 -#include "xfs_dir2_trace.h"
6226  #include "xfs_log_priv.h"
6227  #include "xfs_log_recover.h"
6228 -#include "xfs_rw.h"
6229  #include "xfs_bit.h"
6230  #include "xfs_quota.h"
6231  #include "quota/xfs_qm.h"
6232 +#include "xfs_iomap.h"
6233  
6234  MODULE_AUTHOR("Silicon Graphics, Inc.");
6235  MODULE_DESCRIPTION("Additional kdb commands for debugging XFS");
6236  MODULE_LICENSE("GPL");
6237  
6238 +#define qprintf        kdb_printf
6239 +
6240 +/*
6241 + * Command table functions. (tracing)
6242 + */
6243 +#ifdef XFS_ALLOC_TRACE
6244 +static void    xfsidbg_xalatrace(int);
6245 +static void    xfsidbg_xalbtrace(xfs_agblock_t);
6246 +static void    xfsidbg_xalgtrace(xfs_agnumber_t);
6247 +static void    xfsidbg_xalmtrace(xfs_mount_t *);
6248 +static void    xfsidbg_xalttrace(int);
6249 +#endif
6250 +#ifdef XFS_ATTR_TRACE
6251 +static void    xfsidbg_xattrtrace(int);
6252 +#endif
6253 +#ifdef XFS_BLI_TRACE
6254 +static void    xfsidbg_xblitrace(xfs_buf_log_item_t *);
6255 +#endif
6256 +#ifdef XFS_BMAP_TRACE
6257 +static void    xfsidbg_xbmatrace(int);
6258 +static void    xfsidbg_xbmitrace(xfs_inode_t *);
6259 +static void    xfsidbg_xbmstrace(xfs_inode_t *);
6260 +static void    xfsidbg_xbxatrace(int);
6261 +static void    xfsidbg_xbxitrace(xfs_inode_t *);
6262 +static void    xfsidbg_xbxstrace(xfs_inode_t *);
6263 +#endif
6264 +#ifdef XFS_ILOCK_TRACE
6265 +static void    xfsidbg_xilock_trace(xfs_inode_t *);
6266 +static void    xfsidbg_xailock_trace(int);
6267 +#endif
6268 +#ifdef XFS_DIR_TRACE
6269 +static void    xfsidbg_xdirtrace(int);
6270 +#endif
6271 +#ifdef XFS_DIR2_TRACE
6272 +static void    xfsidbg_xdir2atrace(int);
6273 +static void    xfsidbg_xdir2itrace(xfs_inode_t *);
6274 +#endif
6275 +#ifdef XFS_LOG_TRACE
6276 +static void    xfsidbg_xiclogtrace(xlog_in_core_t *);
6277 +static void    xfsidbg_xlog_granttrace(xlog_t *);
6278 +#endif
6279 +#ifdef XFS_DQUOT_TRACE
6280 +static void    xfsidbg_xqm_dqtrace(xfs_dquot_t *);
6281 +#endif
6282 +#ifdef XFS_RW_TRACE
6283 +static void    xfsidbg_xrwtrace(xfs_inode_t *);
6284 +#endif
6285 +
6286 +
6287  /*
6288   * Command table functions.
6289   */
6290 @@ -91,9 +140,6 @@
6291  static void    xfsidbg_xagi(xfs_agi_t *);
6292  static void    xfsidbg_xaildump(xfs_mount_t *);
6293  static void    xfsidbg_xalloc(xfs_alloc_arg_t *);
6294 -#ifdef DEBUG
6295 -static void    xfsidbg_xalmtrace(xfs_mount_t *);
6296 -#endif
6297  static void    xfsidbg_xattrcontext(xfs_attr_list_context_t *);
6298  static void    xfsidbg_xattrleaf(xfs_attr_leafblock_t *);
6299  static void    xfsidbg_xattrsf(xfs_attr_shortform_t *);
6300 @@ -105,6 +151,8 @@
6301  static void    xfsidbg_xbtcur(xfs_btree_cur_t *);
6302  static void    xfsidbg_xbuf(xfs_buf_t *);
6303  static void    xfsidbg_xbuf_real(xfs_buf_t *, int);
6304 +static void    xfsidbg_xarg(int);
6305 +static void    xfsidbg_xchksum(uint *);
6306  static void    xfsidbg_xchash(xfs_mount_t *mp);
6307  static void    xfsidbg_xchashlist(xfs_chashlist_t *chl);
6308  static void    xfsidbg_xdaargs(xfs_da_args_t *);
6309 @@ -144,13 +192,18 @@
6310  static void    xfsidbg_xsb(xfs_sb_t *, int convert);
6311  static void    xfsidbg_xtp(xfs_trans_t *);
6312  static void    xfsidbg_xtrans_res(xfs_mount_t *);
6313 -#ifdef CONFIG_XFS_QUOTA
6314 +#ifdef CONFIG_XFS_QUOTA
6315  static void    xfsidbg_xqm(void);
6316  static void    xfsidbg_xqm_htab(void);
6317  static void    xfsidbg_xqm_freelist_print(xfs_frlist_t *qlist, char *title);
6318  static void    xfsidbg_xqm_freelist(void);
6319  #endif
6320  
6321 +#ifdef XFS_BMAP_TRACE
6322 +static void    xfs_convert_extent(xfs_bmbt_rec_32_t *, xfs_dfiloff_t *,
6323 +                               xfs_dfsbno_t *, xfs_dfilblks_t *, int *);
6324 +#endif
6325 +
6326  /* kdb wrappers */
6327  
6328  static int     kdbm_xfs_xagf(
6329 @@ -216,7 +269,8 @@
6330         return 0;
6331  }
6332  
6333 -static int     kdbm_xfs_xalloc(
6334 +#ifdef XFS_ALLOC_TRACE
6335 +static int     kdbm_xfs_xalatrace(
6336         int     argc,
6337         const char **argv,
6338         const char **envp,
6339 @@ -226,19 +280,19 @@
6340         int nextarg = 1;
6341         long offset = 0;
6342         int diag;
6343 -
6344 +       
6345         if (argc != 1)
6346                 return KDB_ARGCOUNT;
6347 +
6348         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6349         if (diag)
6350                 return diag;
6351  
6352 -       xfsidbg_xalloc((xfs_alloc_arg_t *) addr);
6353 +       xfsidbg_xalatrace((int) addr);
6354         return 0;
6355  }
6356  
6357 -#ifdef DEBUG
6358 -static int     kdbm_xfs_xalmtrace(
6359 +static int     kdbm_xfs_xalbtrace(
6360         int     argc,
6361         const char **argv,
6362         const char **envp,
6363 @@ -251,16 +305,16 @@
6364  
6365         if (argc != 1)
6366                 return KDB_ARGCOUNT;
6367 +
6368         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6369         if (diag)
6370                 return diag;
6371  
6372 -       xfsidbg_xalmtrace((xfs_mount_t *) addr);
6373 +       xfsidbg_xalbtrace((xfs_agblock_t) addr);
6374         return 0;
6375  }
6376 -#endif /* DEBUG */
6377  
6378 -static int     kdbm_xfs_xattrcontext(
6379 +static int     kdbm_xfs_xalgtrace(
6380         int     argc,
6381         const char **argv,
6382         const char **envp,
6383 @@ -273,15 +327,18 @@
6384  
6385         if (argc != 1)
6386                 return KDB_ARGCOUNT;
6387 +
6388         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6389         if (diag)
6390                 return diag;
6391  
6392 -       xfsidbg_xattrcontext((xfs_attr_list_context_t *) addr);
6393 +       xfsidbg_xalgtrace((xfs_agnumber_t) addr);
6394         return 0;
6395  }
6396 +#endif
6397  
6398 -static int     kdbm_xfs_xattrleaf(
6399 +#ifdef XFS_ATTR_TRACE
6400 +static int     kdbm_xfs_xattrtrace(
6401         int     argc,
6402         const char **argv,
6403         const char **envp,
6404 @@ -294,15 +351,18 @@
6405  
6406         if (argc != 1)
6407                 return KDB_ARGCOUNT;
6408 +
6409         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6410         if (diag)
6411                 return diag;
6412  
6413 -       xfsidbg_xattrleaf((xfs_attr_leafblock_t *) addr);
6414 +       xfsidbg_xattrtrace((int) addr);
6415         return 0;
6416  }
6417 +#endif
6418  
6419 -static int     kdbm_xfs_xattrsf(
6420 +#ifdef XFS_BLI_TRACE
6421 +static int     kdbm_xfs_xblitrace(
6422         int     argc,
6423         const char **argv,
6424         const char **envp,
6425 @@ -315,15 +375,18 @@
6426  
6427         if (argc != 1)
6428                 return KDB_ARGCOUNT;
6429 +
6430         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6431         if (diag)
6432                 return diag;
6433  
6434 -       xfsidbg_xattrsf((xfs_attr_shortform_t *) addr);
6435 +       xfsidbg_xblitrace((xfs_buf_log_item_t *) addr);
6436         return 0;
6437  }
6438 +#endif
6439  
6440 -static int     kdbm_xfs_xbirec(
6441 +#ifdef XFS_BMAP_TRACE
6442 +static int     kdbm_xfs_xbmatrace(
6443         int     argc,
6444         const char **argv,
6445         const char **envp,
6446 @@ -336,15 +399,16 @@
6447  
6448         if (argc != 1)
6449                 return KDB_ARGCOUNT;
6450 +
6451         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6452         if (diag)
6453                 return diag;
6454  
6455 -       xfsidbg_xbirec((xfs_bmbt_irec_t *) addr);
6456 +       xfsidbg_xbmatrace((int) addr);
6457         return 0;
6458  }
6459  
6460 -static int     kdbm_xfs_xbmalla(
6461 +static int     kdbm_xfs_xbmitrace(
6462         int     argc,
6463         const char **argv,
6464         const char **envp,
6465 @@ -357,15 +421,16 @@
6466  
6467         if (argc != 1)
6468                 return KDB_ARGCOUNT;
6469 +
6470         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6471         if (diag)
6472                 return diag;
6473  
6474 -       xfsidbg_xbmalla((xfs_bmalloca_t *)addr);
6475 +       xfsidbg_xbmitrace((xfs_inode_t *) addr);
6476         return 0;
6477  }
6478  
6479 -static int     kdbm_xfs_xbrec(
6480 +static int     kdbm_xfs_xbmstrace(
6481         int     argc,
6482         const char **argv,
6483         const char **envp,
6484 @@ -378,15 +443,16 @@
6485  
6486         if (argc != 1)
6487                 return KDB_ARGCOUNT;
6488 +
6489         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6490         if (diag)
6491                 return diag;
6492  
6493 -       xfsidbg_xbrec((xfs_bmbt_rec_64_t *) addr);
6494 +       xfsidbg_xbmstrace((xfs_inode_t *) addr);
6495         return 0;
6496  }
6497  
6498 -static int     kdbm_xfs_xbroot(
6499 +static int     kdbm_xfs_xbxatrace(
6500         int     argc,
6501         const char **argv,
6502         const char **envp,
6503 @@ -399,15 +465,16 @@
6504  
6505         if (argc != 1)
6506                 return KDB_ARGCOUNT;
6507 +
6508         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6509         if (diag)
6510                 return diag;
6511  
6512 -       xfsidbg_xbroot((xfs_inode_t *) addr);
6513 +       xfsidbg_xbxatrace((int) addr);
6514         return 0;
6515  }
6516  
6517 -static int     kdbm_xfs_xbroota(
6518 +static int     kdbm_xfs_xbxitrace(
6519         int     argc,
6520         const char **argv,
6521         const char **envp,
6522 @@ -420,15 +487,16 @@
6523  
6524         if (argc != 1)
6525                 return KDB_ARGCOUNT;
6526 +
6527         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6528         if (diag)
6529                 return diag;
6530  
6531 -       xfsidbg_xbroota((xfs_inode_t *) addr);
6532 +       xfsidbg_xbxitrace((xfs_inode_t *) addr);
6533         return 0;
6534  }
6535  
6536 -static int     kdbm_xfs_xbtcur(
6537 +static int     kdbm_xfs_xbxstrace(
6538         int     argc,
6539         const char **argv,
6540         const char **envp,
6541 @@ -441,15 +509,18 @@
6542  
6543         if (argc != 1)
6544                 return KDB_ARGCOUNT;
6545 +
6546         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6547         if (diag)
6548                 return diag;
6549  
6550 -       xfsidbg_xbtcur((xfs_btree_cur_t *) addr);
6551 +       xfsidbg_xbxstrace((xfs_inode_t *) addr);
6552         return 0;
6553  }
6554 +#endif
6555  
6556 -static int     kdbm_xfs_xbuf(
6557 +#ifdef XFS_DIR2_TRACE
6558 +static int     kdbm_xfs_xdir2atrace(
6559         int     argc,
6560         const char **argv,
6561         const char **envp,
6562 @@ -462,16 +533,16 @@
6563  
6564         if (argc != 1)
6565                 return KDB_ARGCOUNT;
6566 +
6567         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6568         if (diag)
6569                 return diag;
6570  
6571 -       xfsidbg_xbuf((xfs_buf_t *) addr);
6572 +       xfsidbg_xdir2atrace((int) addr);
6573         return 0;
6574  }
6575  
6576 -
6577 -static int     kdbm_xfs_xchash(
6578 +static int     kdbm_xfs_xdir2itrace(
6579         int     argc,
6580         const char **argv,
6581         const char **envp,
6582 @@ -484,15 +555,18 @@
6583  
6584         if (argc != 1)
6585                 return KDB_ARGCOUNT;
6586 +
6587         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6588         if (diag)
6589                 return diag;
6590  
6591 -       xfsidbg_xchash((xfs_mount_t *) addr);
6592 +       xfsidbg_xdir2itrace((xfs_inode_t *) addr);
6593         return 0;
6594  }
6595 +#endif
6596  
6597 -static int     kdbm_xfs_xchashlist(
6598 +#ifdef XFS_DIR_TRACE
6599 +static int     kdbm_xfs_xdirtrace(
6600         int     argc,
6601         const char **argv,
6602         const char **envp,
6603 @@ -505,16 +579,18 @@
6604  
6605         if (argc != 1)
6606                 return KDB_ARGCOUNT;
6607 +
6608         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6609         if (diag)
6610                 return diag;
6611  
6612 -       xfsidbg_xchashlist((xfs_chashlist_t *) addr);
6613 +       xfsidbg_xdirtrace((int) addr);
6614         return 0;
6615  }
6616 +#endif
6617  
6618 -
6619 -static int     kdbm_xfs_xdaargs(
6620 +#ifdef XFS_LOG_TRACE
6621 +static int     kdbm_xfs_xiclogtrace(
6622         int     argc,
6623         const char **argv,
6624         const char **envp,
6625 @@ -527,15 +603,18 @@
6626  
6627         if (argc != 1)
6628                 return KDB_ARGCOUNT;
6629 +
6630         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6631         if (diag)
6632                 return diag;
6633  
6634 -       xfsidbg_xdaargs((xfs_da_args_t *) addr);
6635 +       xfsidbg_xiclogtrace((xlog_in_core_t *) addr);
6636         return 0;
6637  }
6638 +#endif
6639  
6640 -static int     kdbm_xfs_xdabuf(
6641 +#ifdef XFS_ILOCK_TRACE
6642 +static int     kdbm_xfs_xilock_trace(
6643         int     argc,
6644         const char **argv,
6645         const char **envp,
6646 @@ -548,15 +627,16 @@
6647  
6648         if (argc != 1)
6649                 return KDB_ARGCOUNT;
6650 +
6651         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6652         if (diag)
6653                 return diag;
6654  
6655 -       xfsidbg_xdabuf((xfs_dabuf_t *) addr);
6656 +       xfsidbg_xilock_trace((xfs_inode_t *) addr);
6657         return 0;
6658  }
6659  
6660 -static int     kdbm_xfs_xdanode(
6661 +static int     kdbm_xfs_xailock_trace(
6662         int     argc,
6663         const char **argv,
6664         const char **envp,
6665 @@ -569,15 +649,18 @@
6666  
6667         if (argc != 1)
6668                 return KDB_ARGCOUNT;
6669 +
6670         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6671         if (diag)
6672                 return diag;
6673  
6674 -       xfsidbg_xdanode((xfs_da_intnode_t *) addr);
6675 +       xfsidbg_xailock_trace((int) addr);
6676         return 0;
6677  }
6678 +#endif
6679  
6680 -static int     kdbm_xfs_xdastate(
6681 +#ifdef XFS_LOG_TRACE
6682 +static int     kdbm_xfs_xlog_granttrace(
6683         int     argc,
6684         const char **argv,
6685         const char **envp,
6686 @@ -590,15 +673,18 @@
6687  
6688         if (argc != 1)
6689                 return KDB_ARGCOUNT;
6690 +
6691         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6692         if (diag)
6693                 return diag;
6694  
6695 -       xfsidbg_xdastate((xfs_da_state_t *) addr);
6696 +       xfsidbg_xlog_granttrace((xlog_t *) addr);
6697         return 0;
6698  }
6699 +#endif
6700  
6701 -static int     kdbm_xfs_xdirleaf(
6702 +#ifdef XFS_DQUOT_TRACE
6703 +static int     kdbm_xfs_xqm_dqtrace(
6704         int     argc,
6705         const char **argv,
6706         const char **envp,
6707 @@ -611,15 +697,18 @@
6708  
6709         if (argc != 1)
6710                 return KDB_ARGCOUNT;
6711 +
6712         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6713         if (diag)
6714                 return diag;
6715  
6716 -       xfsidbg_xdirleaf((xfs_dir_leafblock_t *) addr);
6717 +       xfsidbg_xqm_dqtrace((xfs_dquot_t *) addr);
6718         return 0;
6719  }
6720 +#endif
6721  
6722 -static int     kdbm_xfs_xdirsf(
6723 +#ifdef XFS_RW_TRACE
6724 +static int     kdbm_xfs_xrwtrace(
6725         int     argc,
6726         const char **argv,
6727         const char **envp,
6728 @@ -632,15 +721,17 @@
6729  
6730         if (argc != 1)
6731                 return KDB_ARGCOUNT;
6732 +
6733         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6734         if (diag)
6735                 return diag;
6736  
6737 -       xfsidbg_xdirsf((xfs_dir_shortform_t *) addr);
6738 +       xfsidbg_xrwtrace((xfs_inode_t *) addr);
6739         return 0;
6740  }
6741 +#endif
6742  
6743 -static int     kdbm_xfs_xdir2free(
6744 +static int     kdbm_xfs_xalloc(
6745         int     argc,
6746         const char **argv,
6747         const char **envp,
6748 @@ -657,11 +748,12 @@
6749         if (diag)
6750                 return diag;
6751  
6752 -       xfsidbg_xdir2free((xfs_dir2_free_t *) addr);
6753 +       xfsidbg_xalloc((xfs_alloc_arg_t *) addr);
6754         return 0;
6755  }
6756  
6757 -static int     kdbm_xfs_xdir2sf(
6758 +#ifdef XFS_ALLOC_TRACE
6759 +static int     kdbm_xfs_xalmtrace(
6760         int     argc,
6761         const char **argv,
6762         const char **envp,
6763 @@ -678,11 +770,11 @@
6764         if (diag)
6765                 return diag;
6766  
6767 -       xfsidbg_xdir2sf((xfs_dir2_sf_t *) addr);
6768 +       xfsidbg_xalmtrace((xfs_mount_t *) addr);
6769         return 0;
6770  }
6771  
6772 -static int     kdbm_xfs_xexlist(
6773 +static int     kdbm_xfs_xalttrace(
6774         int     argc,
6775         const char **argv,
6776         const char **envp,
6777 @@ -699,11 +791,12 @@
6778         if (diag)
6779                 return diag;
6780  
6781 -       xfsidbg_xexlist((xfs_inode_t *) addr);
6782 +       xfsidbg_xalttrace((int) addr);
6783         return 0;
6784  }
6785 +#endif /* XFS_ALLOC_TRACE */
6786  
6787 -static int     kdbm_xfs_xflist(
6788 +static int     kdbm_xfs_xattrcontext(
6789         int     argc,
6790         const char **argv,
6791         const char **envp,
6792 @@ -720,24 +813,32 @@
6793         if (diag)
6794                 return diag;
6795  
6796 -       xfsidbg_xflist((xfs_bmap_free_t *) addr);
6797 +       xfsidbg_xattrcontext((xfs_attr_list_context_t *) addr);
6798         return 0;
6799  }
6800  
6801 -static int     kdbm_xfs_xhelp(
6802 +static int     kdbm_xfs_xattrleaf(
6803         int     argc,
6804         const char **argv,
6805         const char **envp,
6806         struct pt_regs *regs)
6807  {
6808 -       if (argc != 0)
6809 +       unsigned long addr;
6810 +       int nextarg = 1;
6811 +       long offset = 0;
6812 +       int diag;
6813 +
6814 +       if (argc != 1)
6815                 return KDB_ARGCOUNT;
6816 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6817 +       if (diag)
6818 +               return diag;
6819  
6820 -       xfsidbg_xhelp();
6821 +       xfsidbg_xattrleaf((xfs_attr_leafblock_t *) addr);
6822         return 0;
6823  }
6824  
6825 -static int     kdbm_xfs_xiclog(
6826 +static int     kdbm_xfs_xattrsf(
6827         int     argc,
6828         const char **argv,
6829         const char **envp,
6830 @@ -754,11 +855,11 @@
6831         if (diag)
6832                 return diag;
6833  
6834 -       xfsidbg_xiclog((xlog_in_core_t *) addr);
6835 +       xfsidbg_xattrsf((xfs_attr_shortform_t *) addr);
6836         return 0;
6837  }
6838  
6839 -static int     kdbm_xfs_xiclogall(
6840 +static int     kdbm_xfs_xbirec(
6841         int     argc,
6842         const char **argv,
6843         const char **envp,
6844 @@ -775,11 +876,11 @@
6845         if (diag)
6846                 return diag;
6847  
6848 -       xfsidbg_xiclogall((xlog_in_core_t *) addr);
6849 +       xfsidbg_xbirec((xfs_bmbt_irec_t *) addr);
6850         return 0;
6851  }
6852  
6853 -static int     kdbm_xfs_xiclogcb(
6854 +static int     kdbm_xfs_xbmalla(
6855         int     argc,
6856         const char **argv,
6857         const char **envp,
6858 @@ -796,11 +897,11 @@
6859         if (diag)
6860                 return diag;
6861  
6862 -       xfsidbg_xiclogcb((xlog_in_core_t *) addr);
6863 +       xfsidbg_xbmalla((xfs_bmalloca_t *)addr);
6864         return 0;
6865  }
6866  
6867 -static int     kdbm_xfs_xihash(
6868 +static int     kdbm_xfs_xbrec(
6869         int     argc,
6870         const char **argv,
6871         const char **envp,
6872 @@ -817,11 +918,11 @@
6873         if (diag)
6874                 return diag;
6875  
6876 -       xfsidbg_xihash((xfs_mount_t *) addr);
6877 +       xfsidbg_xbrec((xfs_bmbt_rec_64_t *) addr);
6878         return 0;
6879  }
6880  
6881 -static int     kdbm_xfs_xinodes(
6882 +static int     kdbm_xfs_xbroot(
6883         int     argc,
6884         const char **argv,
6885         const char **envp,
6886 @@ -838,11 +939,11 @@
6887         if (diag)
6888                 return diag;
6889  
6890 -       xfsidbg_xinodes((xfs_mount_t *) addr);
6891 +       xfsidbg_xbroot((xfs_inode_t *) addr);
6892         return 0;
6893  }
6894  
6895 -static int     kdbm_xfs_delayed_blocks(
6896 +static int     kdbm_xfs_xbroota(
6897         int     argc,
6898         const char **argv,
6899         const char **envp,
6900 @@ -859,12 +960,11 @@
6901         if (diag)
6902                 return diag;
6903  
6904 -       xfsidbg_delayed_blocks((xfs_mount_t *) addr);
6905 +       xfsidbg_xbroota((xfs_inode_t *) addr);
6906         return 0;
6907  }
6908  
6909 -
6910 -static int     kdbm_xfs_xinodes_quiesce(
6911 +static int     kdbm_xfs_xbtcur(
6912         int     argc,
6913         const char **argv,
6914         const char **envp,
6915 @@ -881,11 +981,11 @@
6916         if (diag)
6917                 return diag;
6918  
6919 -       xfsidbg_xinodes_quiesce((xfs_mount_t *) addr);
6920 +       xfsidbg_xbtcur((xfs_btree_cur_t *) addr);
6921         return 0;
6922  }
6923  
6924 -static int     kdbm_xfs_xlog(
6925 +static int     kdbm_xfs_xbuf(
6926         int     argc,
6927         const char **argv,
6928         const char **envp,
6929 @@ -902,11 +1002,12 @@
6930         if (diag)
6931                 return diag;
6932  
6933 -       xfsidbg_xlog((xlog_t *) addr);
6934 +       xfsidbg_xbuf((xfs_buf_t *) addr);
6935         return 0;
6936  }
6937  
6938 -static int     kdbm_xfs_xlog_ritem(
6939 +
6940 +static int     kdbm_xfs_xarg(
6941         int     argc,
6942         const char **argv,
6943         const char **envp,
6944 @@ -923,11 +1024,11 @@
6945         if (diag)
6946                 return diag;
6947  
6948 -       xfsidbg_xlog_ritem((xlog_recover_item_t *) addr);
6949 +       xfsidbg_xarg((int) addr);
6950         return 0;
6951  }
6952  
6953 -static int     kdbm_xfs_xlog_rtrans(
6954 +static int     kdbm_xfs_xchksum(
6955         int     argc,
6956         const char **argv,
6957         const char **envp,
6958 @@ -944,11 +1045,12 @@
6959         if (diag)
6960                 return diag;
6961  
6962 -       xfsidbg_xlog_rtrans((xlog_recover_t *) addr);
6963 +       xfsidbg_xchksum((uint *) addr);
6964         return 0;
6965  }
6966  
6967 -static int     kdbm_xfs_xlog_rtrans_entire(
6968 +
6969 +static int     kdbm_xfs_xchash(
6970         int     argc,
6971         const char **argv,
6972         const char **envp,
6973 @@ -965,11 +1067,11 @@
6974         if (diag)
6975                 return diag;
6976  
6977 -       xfsidbg_xlog_rtrans_entire((xlog_recover_t *) addr);
6978 +       xfsidbg_xchash((xfs_mount_t *) addr);
6979         return 0;
6980  }
6981  
6982 -static int     kdbm_xfs_xlog_tic(
6983 +static int     kdbm_xfs_xchashlist(
6984         int     argc,
6985         const char **argv,
6986         const char **envp,
6987 @@ -986,11 +1088,12 @@
6988         if (diag)
6989                 return diag;
6990  
6991 -       xfsidbg_xlog_tic((xlog_ticket_t *) addr);
6992 +       xfsidbg_xchashlist((xfs_chashlist_t *) addr);
6993         return 0;
6994  }
6995  
6996 -static int     kdbm_xfs_xlogitem(
6997 +
6998 +static int     kdbm_xfs_xdaargs(
6999         int     argc,
7000         const char **argv,
7001         const char **envp,
7002 @@ -1007,11 +1110,11 @@
7003         if (diag)
7004                 return diag;
7005  
7006 -       xfsidbg_xlogitem((xfs_log_item_t *) addr);
7007 +       xfsidbg_xdaargs((xfs_da_args_t *) addr);
7008         return 0;
7009  }
7010  
7011 -static int     kdbm_xfs_xmount(
7012 +static int     kdbm_xfs_xdabuf(
7013         int     argc,
7014         const char **argv,
7015         const char **envp,
7016 @@ -1028,11 +1131,11 @@
7017         if (diag)
7018                 return diag;
7019  
7020 -       xfsidbg_xmount((xfs_mount_t *) addr);
7021 +       xfsidbg_xdabuf((xfs_dabuf_t *) addr);
7022         return 0;
7023  }
7024  
7025 -static int     kdbm_xfs_xnode(
7026 +static int     kdbm_xfs_xdanode(
7027         int     argc,
7028         const char **argv,
7029         const char **envp,
7030 @@ -1049,11 +1152,11 @@
7031         if (diag)
7032                 return diag;
7033  
7034 -       xfsidbg_xnode((xfs_inode_t *) addr);
7035 +       xfsidbg_xdanode((xfs_da_intnode_t *) addr);
7036         return 0;
7037  }
7038  
7039 -static int     kdbm_xfs_xcore(
7040 +static int     kdbm_xfs_xdastate(
7041         int     argc,
7042         const char **argv,
7043         const char **envp,
7044 @@ -1070,11 +1173,11 @@
7045         if (diag)
7046                 return diag;
7047  
7048 -       xfsidbg_xcore((xfs_iocore_t *) addr);
7049 +       xfsidbg_xdastate((xfs_da_state_t *) addr);
7050         return 0;
7051  }
7052  
7053 -static int     kdbm_xfs_xperag(
7054 +static int     kdbm_xfs_xdirleaf(
7055         int     argc,
7056         const char **argv,
7057         const char **envp,
7058 @@ -1091,11 +1194,11 @@
7059         if (diag)
7060                 return diag;
7061  
7062 -       xfsidbg_xperag((xfs_mount_t *) addr);
7063 +       xfsidbg_xdirleaf((xfs_dir_leafblock_t *) addr);
7064         return 0;
7065  }
7066  
7067 -static int     kdbm_xfs_xqm_diskdq(
7068 +static int     kdbm_xfs_xdirsf(
7069         int     argc,
7070         const char **argv,
7071         const char **envp,
7072 @@ -1112,11 +1215,11 @@
7073         if (diag)
7074                 return diag;
7075  
7076 -       xfsidbg_xqm_diskdq((xfs_disk_dquot_t *) addr);
7077 +       xfsidbg_xdirsf((xfs_dir_shortform_t *) addr);
7078         return 0;
7079  }
7080  
7081 -static int     kdbm_xfs_xqm_dqattached_inos(
7082 +static int     kdbm_xfs_xdir2free(
7083         int     argc,
7084         const char **argv,
7085         const char **envp,
7086 @@ -1133,11 +1236,11 @@
7087         if (diag)
7088                 return diag;
7089  
7090 -       xfsidbg_xqm_dqattached_inos((xfs_mount_t *) addr);
7091 +       xfsidbg_xdir2free((xfs_dir2_free_t *) addr);
7092         return 0;
7093  }
7094  
7095 -static int     kdbm_xfs_xqm_dquot(
7096 +static int     kdbm_xfs_xdir2sf(
7097         int     argc,
7098         const char **argv,
7099         const char **envp,
7100 @@ -1154,38 +1257,53 @@
7101         if (diag)
7102                 return diag;
7103  
7104 -       xfsidbg_xqm_dquot((xfs_dquot_t *) addr);
7105 +       xfsidbg_xdir2sf((xfs_dir2_sf_t *) addr);
7106         return 0;
7107  }
7108  
7109 -#ifdef CONFIG_XFS_QUOTA
7110 -static int     kdbm_xfs_xqm(
7111 +static int     kdbm_xfs_xexlist(
7112         int     argc,
7113         const char **argv,
7114         const char **envp,
7115         struct pt_regs *regs)
7116  {
7117 -       if (argc != 0)
7118 +       unsigned long addr;
7119 +       int nextarg = 1;
7120 +       long offset = 0;
7121 +       int diag;
7122 +
7123 +       if (argc != 1)
7124                 return KDB_ARGCOUNT;
7125 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7126 +       if (diag)
7127 +               return diag;
7128  
7129 -       xfsidbg_xqm();
7130 +       xfsidbg_xexlist((xfs_inode_t *) addr);
7131         return 0;
7132  }
7133  
7134 -static int     kdbm_xfs_xqm_freelist(
7135 +static int     kdbm_xfs_xflist(
7136         int     argc,
7137         const char **argv,
7138         const char **envp,
7139         struct pt_regs *regs)
7140  {
7141 -       if (argc != 0)
7142 +       unsigned long addr;
7143 +       int nextarg = 1;
7144 +       long offset = 0;
7145 +       int diag;
7146 +
7147 +       if (argc != 1)
7148                 return KDB_ARGCOUNT;
7149 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7150 +       if (diag)
7151 +               return diag;
7152  
7153 -       xfsidbg_xqm_freelist();
7154 +       xfsidbg_xflist((xfs_bmap_free_t *) addr);
7155         return 0;
7156  }
7157  
7158 -static int     kdbm_xfs_xqm_htab(
7159 +static int     kdbm_xfs_xhelp(
7160         int     argc,
7161         const char **argv,
7162         const char **envp,
7163 @@ -1194,12 +1312,11 @@
7164         if (argc != 0)
7165                 return KDB_ARGCOUNT;
7166  
7167 -       xfsidbg_xqm_htab();
7168 +       xfsidbg_xhelp();
7169         return 0;
7170  }
7171 -#endif
7172  
7173 -static int     kdbm_xfs_xqm_mplist(
7174 +static int     kdbm_xfs_xiclog(
7175         int     argc,
7176         const char **argv,
7177         const char **envp,
7178 @@ -1216,11 +1333,11 @@
7179         if (diag)
7180                 return diag;
7181  
7182 -       xfsidbg_xqm_mplist((xfs_mount_t *) addr);
7183 +       xfsidbg_xiclog((xlog_in_core_t *) addr);
7184         return 0;
7185  }
7186  
7187 -static int     kdbm_xfs_xqm_qinfo(
7188 +static int     kdbm_xfs_xiclogall(
7189         int     argc,
7190         const char **argv,
7191         const char **envp,
7192 @@ -1237,11 +1354,473 @@
7193         if (diag)
7194                 return diag;
7195  
7196 -       xfsidbg_xqm_qinfo((xfs_mount_t *) addr);
7197 +       xfsidbg_xiclogall((xlog_in_core_t *) addr);
7198         return 0;
7199  }
7200  
7201 -static int     kdbm_xfs_xqm_tpdqinfo(
7202 +static int     kdbm_xfs_xiclogcb(
7203 +       int     argc,
7204 +       const char **argv,
7205 +       const char **envp,
7206 +       struct pt_regs *regs)
7207 +{
7208 +       unsigned long addr;
7209 +       int nextarg = 1;
7210 +       long offset = 0;
7211 +       int diag;
7212 +
7213 +       if (argc != 1)
7214 +               return KDB_ARGCOUNT;
7215 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7216 +       if (diag)
7217 +               return diag;
7218 +
7219 +       xfsidbg_xiclogcb((xlog_in_core_t *) addr);
7220 +       return 0;
7221 +}
7222 +
7223 +static int     kdbm_xfs_xihash(
7224 +       int     argc,
7225 +       const char **argv,
7226 +       const char **envp,
7227 +       struct pt_regs *regs)
7228 +{
7229 +       unsigned long addr;
7230 +       int nextarg = 1;
7231 +       long offset = 0;
7232 +       int diag;
7233 +
7234 +       if (argc != 1)
7235 +               return KDB_ARGCOUNT;
7236 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7237 +       if (diag)
7238 +               return diag;
7239 +
7240 +       xfsidbg_xihash((xfs_mount_t *) addr);
7241 +       return 0;
7242 +}
7243 +
7244 +static int     kdbm_xfs_xinodes(
7245 +       int     argc,
7246 +       const char **argv,
7247 +       const char **envp,
7248 +       struct pt_regs *regs)
7249 +{
7250 +       unsigned long addr;
7251 +       int nextarg = 1;
7252 +       long offset = 0;
7253 +       int diag;
7254 +
7255 +       if (argc != 1)
7256 +               return KDB_ARGCOUNT;
7257 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7258 +       if (diag)
7259 +               return diag;
7260 +
7261 +       xfsidbg_xinodes((xfs_mount_t *) addr);
7262 +       return 0;
7263 +}
7264 +
7265 +static int     kdbm_xfs_delayed_blocks(
7266 +       int     argc,
7267 +       const char **argv,
7268 +       const char **envp,
7269 +       struct pt_regs *regs)
7270 +{
7271 +       unsigned long addr;
7272 +       int nextarg = 1;
7273 +       long offset = 0;
7274 +       int diag;
7275 +
7276 +       if (argc != 1)
7277 +               return KDB_ARGCOUNT;
7278 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7279 +       if (diag)
7280 +               return diag;
7281 +
7282 +       xfsidbg_delayed_blocks((xfs_mount_t *) addr);
7283 +       return 0;
7284 +}
7285 +
7286 +
7287 +static int     kdbm_xfs_xinodes_quiesce(
7288 +       int     argc,
7289 +       const char **argv,
7290 +       const char **envp,
7291 +       struct pt_regs *regs)
7292 +{
7293 +       unsigned long addr;
7294 +       int nextarg = 1;
7295 +       long offset = 0;
7296 +       int diag;
7297 +
7298 +       if (argc != 1)
7299 +               return KDB_ARGCOUNT;
7300 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7301 +       if (diag)
7302 +               return diag;
7303 +
7304 +       xfsidbg_xinodes_quiesce((xfs_mount_t *) addr);
7305 +       return 0;
7306 +}
7307 +
7308 +static int     kdbm_xfs_xlog(
7309 +       int     argc,
7310 +       const char **argv,
7311 +       const char **envp,
7312 +       struct pt_regs *regs)
7313 +{
7314 +       unsigned long addr;
7315 +       int nextarg = 1;
7316 +       long offset = 0;
7317 +       int diag;
7318 +
7319 +       if (argc != 1)
7320 +               return KDB_ARGCOUNT;
7321 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7322 +       if (diag)
7323 +               return diag;
7324 +
7325 +       xfsidbg_xlog((xlog_t *) addr);
7326 +       return 0;
7327 +}
7328 +
7329 +static int     kdbm_xfs_xlog_ritem(
7330 +       int     argc,
7331 +       const char **argv,
7332 +       const char **envp,
7333 +       struct pt_regs *regs)
7334 +{
7335 +       unsigned long addr;
7336 +       int nextarg = 1;
7337 +       long offset = 0;
7338 +       int diag;
7339 +
7340 +       if (argc != 1)
7341 +               return KDB_ARGCOUNT;
7342 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7343 +       if (diag)
7344 +               return diag;
7345 +
7346 +       xfsidbg_xlog_ritem((xlog_recover_item_t *) addr);
7347 +       return 0;
7348 +}
7349 +
7350 +static int     kdbm_xfs_xlog_rtrans(
7351 +       int     argc,
7352 +       const char **argv,
7353 +       const char **envp,
7354 +       struct pt_regs *regs)
7355 +{
7356 +       unsigned long addr;
7357 +       int nextarg = 1;
7358 +       long offset = 0;
7359 +       int diag;
7360 +
7361 +       if (argc != 1)
7362 +               return KDB_ARGCOUNT;
7363 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7364 +       if (diag)
7365 +               return diag;
7366 +
7367 +       xfsidbg_xlog_rtrans((xlog_recover_t *) addr);
7368 +       return 0;
7369 +}
7370 +
7371 +static int     kdbm_xfs_xlog_rtrans_entire(
7372 +       int     argc,
7373 +       const char **argv,
7374 +       const char **envp,
7375 +       struct pt_regs *regs)
7376 +{
7377 +       unsigned long addr;
7378 +       int nextarg = 1;
7379 +       long offset = 0;
7380 +       int diag;
7381 +
7382 +       if (argc != 1)
7383 +               return KDB_ARGCOUNT;
7384 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7385 +       if (diag)
7386 +               return diag;
7387 +
7388 +       xfsidbg_xlog_rtrans_entire((xlog_recover_t *) addr);
7389 +       return 0;
7390 +}
7391 +
7392 +static int     kdbm_xfs_xlog_tic(
7393 +       int     argc,
7394 +       const char **argv,
7395 +       const char **envp,
7396 +       struct pt_regs *regs)
7397 +{
7398 +       unsigned long addr;
7399 +       int nextarg = 1;
7400 +       long offset = 0;
7401 +       int diag;
7402 +
7403 +       if (argc != 1)
7404 +               return KDB_ARGCOUNT;
7405 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7406 +       if (diag)
7407 +               return diag;
7408 +
7409 +       xfsidbg_xlog_tic((xlog_ticket_t *) addr);
7410 +       return 0;
7411 +}
7412 +
7413 +static int     kdbm_xfs_xlogitem(
7414 +       int     argc,
7415 +       const char **argv,
7416 +       const char **envp,
7417 +       struct pt_regs *regs)
7418 +{
7419 +       unsigned long addr;
7420 +       int nextarg = 1;
7421 +       long offset = 0;
7422 +       int diag;
7423 +
7424 +       if (argc != 1)
7425 +               return KDB_ARGCOUNT;
7426 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7427 +       if (diag)
7428 +               return diag;
7429 +
7430 +       xfsidbg_xlogitem((xfs_log_item_t *) addr);
7431 +       return 0;
7432 +}
7433 +
7434 +static int     kdbm_xfs_xmount(
7435 +       int     argc,
7436 +       const char **argv,
7437 +       const char **envp,
7438 +       struct pt_regs *regs)
7439 +{
7440 +       unsigned long addr;
7441 +       int nextarg = 1;
7442 +       long offset = 0;
7443 +       int diag;
7444 +
7445 +       if (argc != 1)
7446 +               return KDB_ARGCOUNT;
7447 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7448 +       if (diag)
7449 +               return diag;
7450 +
7451 +       xfsidbg_xmount((xfs_mount_t *) addr);
7452 +       return 0;
7453 +}
7454 +
7455 +static int     kdbm_xfs_xnode(
7456 +       int     argc,
7457 +       const char **argv,
7458 +       const char **envp,
7459 +       struct pt_regs *regs)
7460 +{
7461 +       unsigned long addr;
7462 +       int nextarg = 1;
7463 +       long offset = 0;
7464 +       int diag;
7465 +
7466 +       if (argc != 1)
7467 +               return KDB_ARGCOUNT;
7468 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7469 +       if (diag)
7470 +               return diag;
7471 +
7472 +       xfsidbg_xnode((xfs_inode_t *) addr);
7473 +       return 0;
7474 +}
7475 +
7476 +static int     kdbm_xfs_xcore(
7477 +       int     argc,
7478 +       const char **argv,
7479 +       const char **envp,
7480 +       struct pt_regs *regs)
7481 +{
7482 +       unsigned long addr;
7483 +       int nextarg = 1;
7484 +       long offset = 0;
7485 +       int diag;
7486 +
7487 +       if (argc != 1)
7488 +               return KDB_ARGCOUNT;
7489 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7490 +       if (diag)
7491 +               return diag;
7492 +
7493 +       xfsidbg_xcore((xfs_iocore_t *) addr);
7494 +       return 0;
7495 +}
7496 +
7497 +static int     kdbm_xfs_xperag(
7498 +       int     argc,
7499 +       const char **argv,
7500 +       const char **envp,
7501 +       struct pt_regs *regs)
7502 +{
7503 +       unsigned long addr;
7504 +       int nextarg = 1;
7505 +       long offset = 0;
7506 +       int diag;
7507 +
7508 +       if (argc != 1)
7509 +               return KDB_ARGCOUNT;
7510 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7511 +       if (diag)
7512 +               return diag;
7513 +
7514 +       xfsidbg_xperag((xfs_mount_t *) addr);
7515 +       return 0;
7516 +}
7517 +
7518 +static int     kdbm_xfs_xqm_diskdq(
7519 +       int     argc,
7520 +       const char **argv,
7521 +       const char **envp,
7522 +       struct pt_regs *regs)
7523 +{
7524 +       unsigned long addr;
7525 +       int nextarg = 1;
7526 +       long offset = 0;
7527 +       int diag;
7528 +
7529 +       if (argc != 1)
7530 +               return KDB_ARGCOUNT;
7531 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7532 +       if (diag)
7533 +               return diag;
7534 +
7535 +       xfsidbg_xqm_diskdq((xfs_disk_dquot_t *) addr);
7536 +       return 0;
7537 +}
7538 +
7539 +static int     kdbm_xfs_xqm_dqattached_inos(
7540 +       int     argc,
7541 +       const char **argv,
7542 +       const char **envp,
7543 +       struct pt_regs *regs)
7544 +{
7545 +       unsigned long addr;
7546 +       int nextarg = 1;
7547 +       long offset = 0;
7548 +       int diag;
7549 +
7550 +       if (argc != 1)
7551 +               return KDB_ARGCOUNT;
7552 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7553 +       if (diag)
7554 +               return diag;
7555 +
7556 +       xfsidbg_xqm_dqattached_inos((xfs_mount_t *) addr);
7557 +       return 0;
7558 +}
7559 +
7560 +static int     kdbm_xfs_xqm_dquot(
7561 +       int     argc,
7562 +       const char **argv,
7563 +       const char **envp,
7564 +       struct pt_regs *regs)
7565 +{
7566 +       unsigned long addr;
7567 +       int nextarg = 1;
7568 +       long offset = 0;
7569 +       int diag;
7570 +
7571 +       if (argc != 1)
7572 +               return KDB_ARGCOUNT;
7573 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7574 +       if (diag)
7575 +               return diag;
7576 +
7577 +       xfsidbg_xqm_dquot((xfs_dquot_t *) addr);
7578 +       return 0;
7579 +}
7580 +
7581 +#ifdef CONFIG_XFS_QUOTA
7582 +static int     kdbm_xfs_xqm(
7583 +       int     argc,
7584 +       const char **argv,
7585 +       const char **envp,
7586 +       struct pt_regs *regs)
7587 +{
7588 +       if (argc != 0)
7589 +               return KDB_ARGCOUNT;
7590 +
7591 +       xfsidbg_xqm();
7592 +       return 0;
7593 +}
7594 +
7595 +static int     kdbm_xfs_xqm_freelist(
7596 +       int     argc,
7597 +       const char **argv,
7598 +       const char **envp,
7599 +       struct pt_regs *regs)
7600 +{
7601 +       if (argc != 0)
7602 +               return KDB_ARGCOUNT;
7603 +
7604 +       xfsidbg_xqm_freelist();
7605 +       return 0;
7606 +}
7607 +
7608 +static int     kdbm_xfs_xqm_htab(
7609 +       int     argc,
7610 +       const char **argv,
7611 +       const char **envp,
7612 +       struct pt_regs *regs)
7613 +{
7614 +       if (argc != 0)
7615 +               return KDB_ARGCOUNT;
7616 +
7617 +       xfsidbg_xqm_htab();
7618 +       return 0;
7619 +}
7620 +#endif
7621 +
7622 +static int     kdbm_xfs_xqm_mplist(
7623 +       int     argc,
7624 +       const char **argv,
7625 +       const char **envp,
7626 +       struct pt_regs *regs)
7627 +{
7628 +       unsigned long addr;
7629 +       int nextarg = 1;
7630 +       long offset = 0;
7631 +       int diag;
7632 +
7633 +       if (argc != 1)
7634 +               return KDB_ARGCOUNT;
7635 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7636 +       if (diag)
7637 +               return diag;
7638 +
7639 +       xfsidbg_xqm_mplist((xfs_mount_t *) addr);
7640 +       return 0;
7641 +}
7642 +
7643 +static int     kdbm_xfs_xqm_qinfo(
7644 +       int     argc,
7645 +       const char **argv,
7646 +       const char **envp,
7647 +       struct pt_regs *regs)
7648 +{
7649 +       unsigned long addr;
7650 +       int nextarg = 1;
7651 +       long offset = 0;
7652 +       int diag;
7653 +
7654 +       if (argc != 1)
7655 +               return KDB_ARGCOUNT;
7656 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7657 +       if (diag)
7658 +               return diag;
7659 +
7660 +       xfsidbg_xqm_qinfo((xfs_mount_t *) addr);
7661 +       return 0;
7662 +}
7663 +
7664 +static int     kdbm_xfs_xqm_tpdqinfo(
7665         int     argc,
7666         const char **argv,
7667         const char **envp,
7668 @@ -1404,45 +1983,52 @@
7669  }
7670  
7671  
7672 -static void    printvnode(vnode_t *vp)
7673 +static void printbhv(bhv_desc_t *bdp)
7674  {
7675 -       bhv_desc_t      *bh;
7676         kdb_symtab_t     symtab;
7677  
7678 +       if (bdp == NULL) {
7679 +               kdb_printf("NULL bhv\n");
7680 +               return;
7681 +       }
7682 +
7683 +       kdb_printf("bhv at 0x%p\n", bdp);
7684 +       while (bdp) {
7685 +               if (kdbnearsym((unsigned long)bdp->bd_ops, &symtab))
7686 +                       kdb_printf("  ops %s", symtab.sym_name);
7687 +               else
7688 +                       kdb_printf("  ops %s/0x%p", "???", (void *)bdp->bd_ops);
7689 +
7690 +               kdb_printf(" vobj 0x%p pdata 0x%p next 0x%p\n",
7691 +                          bdp->bd_vobj, bdp->bd_pdata, bdp->bd_next);
7692 +
7693 +               bdp = bdp->bd_next;
7694 +       }
7695 +}
7696  
7697 -       kdb_printf("vnode: 0x%p type ", vp);
7698 +
7699 +static void    printvnode(vnode_t *vp, unsigned long addr)
7700 +{
7701 +       kdb_printf("vnode: 0x%lx type ", addr);
7702         if ((size_t)vp->v_type >= sizeof(vnode_type)/sizeof(vnode_type[0]))
7703                 kdb_printf("out of range 0x%x", vp->v_type);
7704         else
7705                 kdb_printf("%s", vnode_type[vp->v_type]);
7706 -       kdb_printf(" v_bh %p\n", &vp->v_bh);
7707 +       kdb_printf(" v_bh 0x%p\n", &vp->v_bh);
7708  
7709 -       if ((bh = vp->v_bh.bh_first)) {
7710 -               kdb_printf("   v_inode 0x%p v_bh->bh_first 0x%p pobj 0x%p\n",
7711 -                                       LINVFS_GET_IP(vp), bh, bh->bd_pdata);
7712 -
7713 -               if (kdbnearsym((unsigned long)bh->bd_ops, &symtab))
7714 -                       kdb_printf("   ops %s ", symtab.sym_name);
7715 -               else
7716 -                       kdb_printf("   ops %s/0x%p ",
7717 -                                               "???", (void *)bh->bd_ops);
7718 -       } else {
7719 -               kdb_printf("   v_inode 0x%p v_bh->bh_first = NULLBHV ",
7720 -                                       LINVFS_GET_IP(vp));
7721 -       }
7722 +       printbhv(vp->v_fbhv);
7723  
7724         printflags((__psunsigned_t)vp->v_flag, tab_vflags, "flag =");
7725         kdb_printf("\n");
7726  
7727 -#ifdef CONFIG_XFS_VNODE_TRACING
7728 +#ifdef XFS_VNODE_TRACE
7729         kdb_printf("   v_trace 0x%p\n", vp->v_trace);
7730 -#endif /* CONFIG_XFS_VNODE_TRACING */
7731 +#endif /* XFS_VNODE_TRACE */
7732  
7733 -       kdb_printf("   v_vfsp 0x%p v_number %Lx\n",
7734 -               vp->v_vfsp, vp->v_number);
7735 +       kdb_printf("   v_vfsp 0x%p v_number 0x%llx\n",
7736 +               vp->v_vfsp, (unsigned long long)vp->v_number);
7737  }
7738  
7739 -
7740  static int     kdbm_vnode(
7741         int     argc,
7742         const char **argv,
7743 @@ -1453,9 +2039,7 @@
7744         int nextarg = 1;
7745         long offset = 0;
7746         int diag;
7747 -       vnode_t         *vp;
7748 -/*     bhv_desc_t      *bh; */
7749 -/*     kdb_symtab_t     symtab;*/
7750 +       vnode_t         vp;
7751  
7752         if (argc != 1)
7753                 return KDB_ARGCOUNT;
7754 @@ -1465,14 +2049,82 @@
7755         if (diag)
7756                 return diag;
7757  
7758 -       vp = (vnode_t *)addr;
7759 +       if ((diag = kdb_getarea(vp, addr)))
7760 +               return diag;
7761 +
7762 +       printvnode(&vp, addr);
7763 +
7764 +       return 0;
7765 +}
7766 +
7767 +static void
7768 +print_vfs(vfs_t        *vfs, unsigned long addr)
7769 +{
7770 +       kdb_printf("vfsp at 0x%lx", addr);
7771 +       kdb_printf(" vfs_flag 0x%x\n", vfs->vfs_flag);
7772 +       kdb_printf(" vfs_super 0x%p", vfs->vfs_super);
7773 +       kdb_printf(" vfs_bh 0x%p\n", &vfs->vfs_bh);
7774 +
7775 +       printbhv(vfs->vfs_fbhv);
7776 +}
7777 +
7778 +static int     kdbm_bhv(
7779 +       int     argc,
7780 +       const char **argv,
7781 +       const char **envp,
7782 +       struct pt_regs *regs)
7783 +{
7784 +       unsigned long addr;
7785 +       int nextarg = 1;
7786 +       long offset = 0;
7787 +       int diag;
7788 +       bhv_desc_t      *bh;
7789 +
7790 +       if (argc != 1)
7791 +               return KDB_ARGCOUNT;
7792 +
7793 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7794 +
7795 +       if (diag)
7796 +               return diag;
7797 +
7798 +       bh = (bhv_desc_t *)addr;
7799 +
7800 +       printbhv(bh);
7801 +
7802 +       return 0;
7803 +}
7804 +
7805 +static int     kdbm_vfs(
7806 +       int     argc,
7807 +       const char **argv,
7808 +       const char **envp,
7809 +       struct pt_regs *regs)
7810 +{
7811 +       unsigned long addr;
7812 +       int nextarg = 1;
7813 +       long offset = 0;
7814 +       int diag;
7815 +       vfs_t           vfs;
7816 +
7817 +       if (argc != 1)
7818 +               return KDB_ARGCOUNT;
7819 +
7820 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7821 +
7822 +       if (diag)
7823 +               return diag;
7824 +
7825 +       if ((diag = kdb_getarea(vfs, addr)))
7826 +               return diag;
7827  
7828 -       printvnode(vp);
7829 +       print_vfs(&vfs, addr);
7830  
7831         return 0;
7832  }
7833  
7834 -#ifdef CONFIG_XFS_VNODE_TRACING
7835 +
7836 +#ifdef XFS_VNODE_TRACE
7837  /*
7838   * Print a vnode trace entry.
7839   */
7840 @@ -1668,7 +2320,7 @@
7841  
7842         return 0;
7843  }
7844 -#endif /* CONFIG_XFS_VNODE_TRACING */
7845 +#endif /* XFS_VNODE_TRACE */
7846  
7847  
7848  static void    printinode(struct inode *ip)
7849 @@ -1682,16 +2334,21 @@
7850         kdb_printf(" i_ino = %lu i_count = %u i_size %Ld\n",
7851                                         ip->i_ino, atomic_read(&ip->i_count),
7852                                         ip->i_size);
7853 -
7854 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
7855         kdb_printf(
7856 -               " i_mode = 0x%x  i_nlink = %d  i_rdev = %u:%u i_state = 0x%lx\n",
7857 +               " i_mode = 0x%x  i_nlink = %d  i_rdev = 0x%x i_state = 0x%lx\n",
7858                                         ip->i_mode, ip->i_nlink,
7859 -                                       MAJOR(ip->i_rdev),
7860 -                                       MINOR(ip->i_rdev),
7861 -                                       ip->i_state);
7862 -
7863 -       kdb_printf(" i_hash.nxt = 0x%p i_hash.prv = 0x%p\n",
7864 -                                       ip->i_hash.next, ip->i_hash.prev);
7865 +                                       kdev_t_to_nr(ip->i_rdev), ip->i_state);
7866 +       kdb_printf(" i_hash.nxt = 0x%p i_hash.pprv = 0x%p\n",
7867 +                                        ip->i_hash.next, ip->i_hash.prev);
7868 +#else
7869 +       kdb_printf(
7870 +               " i_mode = 0x%x  i_nlink = %d  i_rdev = 0x%x i_state = 0x%lx\n",
7871 +                                       ip->i_mode, ip->i_nlink,
7872 +                                       ip->i_rdev, ip->i_state);
7873 +       kdb_printf(" i_hash.nxt = 0x%p i_hash.pprv = 0x%p\n",
7874 +                                        ip->i_hash.next, ip->i_hash.pprev);
7875 +#endif
7876         kdb_printf(" i_list.nxt = 0x%p i_list.prv = 0x%p\n",
7877                                         ip->i_list.next, ip->i_list.prev);
7878         kdb_printf(" i_dentry.nxt = 0x%p i_dentry.prv = 0x%p\n",
7879 @@ -1717,52 +2374,44 @@
7880  {
7881         int             diag;
7882         int             nextarg = 1;
7883 -/*     char            *symname; */
7884         long            offset = 0;
7885         unsigned long   addr;
7886         struct inode    *ip;
7887 -/*     bhv_desc_t      *bh; */
7888 -#ifdef CONFIG_XFS_VNODE_TRACING
7889 +       vnode_t         vp;
7890 +#ifdef XFS_VNODE_TRACE
7891         ktrace_entry_t  *ktep;
7892         ktrace_snap_t   kts;
7893  #endif
7894 -       vnode_t         *vp;
7895  
7896         if (argc != 1)
7897                 return KDB_ARGCOUNT;
7898  
7899         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7900 -
7901         if (diag)
7902                 return diag;
7903  
7904 -       vp = (vnode_t *)addr;
7905 -
7906 -       ip = LINVFS_GET_IP(vp);
7907 +       if ((diag = kdb_getarea(vp, addr)))
7908 +               return diag;
7909  
7910 +       ip = LINVFS_GET_IP((vnode_t *)addr);
7911         kdb_printf("--> Inode @ 0x%p\n", ip);
7912         printinode(ip);
7913  
7914 -       kdb_printf("--> Vnode @ 0x%p\n", vp);
7915 -       printvnode(vp);
7916 -
7917 -#ifdef CONFIG_XFS_VNODE_TRACING
7918 +       kdb_printf("--> Vnode @ 0x%lx\n", addr);
7919 +       printvnode(&vp, addr);
7920  
7921 -       kdb_printf("--> Vntrace @ 0x%p/0x%p\n", vp, vp->v_trace);
7922 -
7923 -       if (vp->v_trace == NULL)
7924 +#ifdef XFS_VNODE_TRACE
7925 +       kdb_printf("--> Vntrace @ 0x%lx/0x%p\n", addr, vp.v_trace);
7926 +       if (vp.v_trace == NULL)
7927                 return 0;
7928 -
7929 -       ktep = ktrace_first(vp->v_trace, &kts);
7930 -
7931 +       ktep = ktrace_first(vp.v_trace, &kts);
7932         while (ktep != NULL) {
7933                 if (vn_trace_pr_entry(ktep))
7934                         kdb_printf("\n");
7935  
7936 -               ktep = ktrace_next(vp->v_trace, &kts);
7937 +               ktep = ktrace_next(vp.v_trace, &kts);
7938         }
7939 -#endif /* CONFIG_XFS_VNODE_TRACING */
7940 -
7941 +#endif /* XFS_VNODE_TRACE */
7942         return 0;
7943  }
7944  
7945 @@ -1772,15 +2421,15 @@
7946  static char    *pb_flag_vals[] = {
7947  /*  0 */ "READ", "WRITE", "MAPPED", "PARTIAL", "ASYNC",
7948  /*  5 */ "NONE", "DELWRI", "FREED", "SYNC", "MAPPABLE",
7949 -/* 10 */ "STALE", "FS_MANAGED", "INVALID12", "LOCK", "TRYLOCK",
7950 +/* 10 */ "STALE", "FS_MANAGED", "FS_DATAIOD", "LOCK", "TRYLOCK",
7951  /* 15 */ "DONT_BLOCK", "LOCKABLE", "PRIVATE_BH", "ALL_PAGES_MAPPED", 
7952          "ADDR_ALLOCATED",
7953  /* 20 */ "MEM_ALLOCATED", "FORCEIO", "FLUSH", "READ_AHEAD",
7954          NULL };
7955  
7956 -static char    *pbm_flag_vals[] = {
7957 +static char    *iomap_flag_vals[] = {
7958         "EOF", "HOLE", "DELAY", "INVALID0x08",
7959 -       "INVALID0x10", "UNWRITTEN", "INVALID0x40", "INVALID0x80",
7960 +       "INVALID0x10", "UNWRITTEN", "NEW", "INVALID0x80",
7961         NULL };
7962  
7963  
7964 @@ -1795,7 +2444,7 @@
7965         for (index = 0; flags && mapping[index]; flags >>= 1, index++) {
7966                 if (flags & 1) {
7967                         if ((offset + strlen(mapping[index]) + 1) >= 80) {
7968 -                               strcat(buffer, "\n            ");
7969 +                               strcat(buffer, "\n          ");
7970                                 offset = 12;
7971                         } else if (offset > 12) {
7972                                 strcat(buffer, " ");
7973 @@ -1832,6 +2481,48 @@
7974         return 0;
7975  }
7976  
7977 +static void
7978 +print_pagebuf(
7979 +       page_buf_t      *pb,
7980 +       unsigned long addr)
7981 +{
7982 +       kdb_printf("page_buf_t at 0x%lx\n", addr);
7983 +       kdb_printf("  pb_flags %s\n", pb_flags(pb->pb_flags));
7984 +       kdb_printf("  pb_target 0x%p pb_hold %d pb_next 0x%p pb_prev 0x%p\n",
7985 +                  pb->pb_target, pb->pb_hold.counter,
7986 +                  list_entry(pb->pb_list.next, page_buf_t, pb_list),
7987 +                  list_entry(pb->pb_list.prev, page_buf_t, pb_list));
7988 +       kdb_printf("  pb_hash_index %d pb_hash_next 0x%p pb_hash_prev 0x%p\n",
7989 +                  pb->pb_hash_index,
7990 +                  list_entry(pb->pb_hash_list.next, page_buf_t, pb_hash_list),
7991 +                  list_entry(pb->pb_hash_list.prev, page_buf_t, pb_hash_list));
7992 +       kdb_printf("  pb_file_offset 0x%llx pb_buffer_length 0x%llx pb_addr 0x%p\n",
7993 +                  (unsigned long long) pb->pb_file_offset,
7994 +                  (unsigned long long) pb->pb_buffer_length,
7995 +                  pb->pb_addr);
7996 +       kdb_printf("  pb_bn 0x%Lx pb_count_desired 0x%lx pb_locked %d\n",
7997 +                  pb->pb_bn,
7998 +                  (unsigned long) pb->pb_count_desired, (int)pb->pb_locked);
7999 +       kdb_printf("  pb_flushtime %ld (%ld) pb_io_remaining %d pb_error %u\n",
8000 +                  pb->pb_flushtime, pb->pb_flushtime - jiffies,
8001 +                  pb->pb_io_remaining.counter, pb->pb_error);
8002 +       kdb_printf("  pb_page_count %u pb_offset 0x%x pb_pages 0x%p\n",
8003 +               pb->pb_page_count, pb->pb_offset,
8004 +               pb->pb_pages);
8005 +       kdb_printf("  pb_iodonesema (%d,%d) pb_sema (%d,%d) pincount (%d)\n",
8006 +                  pb->pb_iodonesema.count.counter,
8007 +                  pb->pb_iodonesema.sleepers,
8008 +                  pb->pb_sema.count.counter, pb->pb_sema.sleepers,
8009 +                  pb->pb_pin_count.counter);
8010 +#ifdef PAGEBUF_LOCK_TRACKING
8011 +       kdb_printf("  last holder %d\n", pb->pb_last_holder);
8012 +#endif
8013 +       if (pb->pb_fspriv || pb->pb_fspriv2) {
8014 +               kdb_printf(  "  pb_fspriv 0x%p pb_fspriv2 0x%p\n",
8015 +                          pb->pb_fspriv, pb->pb_fspriv2);
8016 +       }
8017 +}
8018 +
8019  static int
8020  kdbm_pb(int argc, const char **argv, const char **envp, struct pt_regs *regs)
8021  {
8022 @@ -1849,109 +2540,64 @@
8023             (diag = kdb_getarea(bp, addr)))
8024                 return diag;
8025  
8026 -       kdb_printf("page_buf_t at 0x%lx\n", addr);
8027 -       kdb_printf("  pb_flags %s\n", pb_flags(bp.pb_flags));
8028 -       kdb_printf("  pb_target 0x%p pb_hold %d pb_next 0x%p pb_prev 0x%p\n",
8029 -                  bp.pb_target, bp.pb_hold.counter,
8030 -                  bp.pb_list.next, bp.pb_list.prev);
8031 -       kdb_printf("  pb_hash_index %d pb_hash_next 0x%p pb_hash_prev 0x%p\n",
8032 -                  bp.pb_hash_index,
8033 -                  bp.pb_hash_list.next,
8034 -                  bp.pb_hash_list.prev);
8035 -       kdb_printf("  pb_file_offset 0x%llx pb_buffer_length 0x%llx pb_addr 0x%p\n",
8036 -                  (unsigned long long) bp.pb_file_offset,
8037 -                  (unsigned long long) bp.pb_buffer_length,
8038 -                  bp.pb_addr);
8039 -       kdb_printf("  pb_bn 0x%Lx pb_count_desired 0x%lx\n",
8040 -                  bp.pb_bn,
8041 -                  (unsigned long) bp.pb_count_desired);
8042 -       kdb_printf("  pb_io_remaining %d pb_error %u\n",
8043 -                  bp.pb_io_remaining.counter,
8044 -                  bp.pb_error);
8045 -       kdb_printf("  pb_page_count %u pb_offset 0x%x pb_pages 0x%p\n",
8046 -               bp.pb_page_count, bp.pb_offset,
8047 -               bp.pb_pages);
8048 -#ifdef PAGEBUF_LOCK_TRACKING
8049 -       kdb_printf("  pb_iodonesema (%d,%d) pb_sema (%d,%d) pincount (%d) last holder %d\n",
8050 -                  bp.pb_iodonesema.count.counter,
8051 -                  bp.pb_iodonesema.sleepers,
8052 -                  bp.pb_sema.count.counter, bp.pb_sema.sleepers,
8053 -                  bp.pb_pin_count.counter, bp.pb_last_holder);
8054 -#else
8055 -       kdb_printf("  pb_iodonesema (%d,%d) pb_sema (%d,%d) pincount (%d)\n",
8056 -                  bp.pb_iodonesema.count.counter,
8057 -                  bp.pb_iodonesema.sleepers,
8058 -                  bp.pb_sema.count.counter, bp.pb_sema.sleepers,
8059 -                  bp.pb_pin_count.counter);
8060 -#endif
8061 -       if (bp.pb_fspriv || bp.pb_fspriv2) {
8062 -               kdb_printf(  "pb_fspriv 0x%p pb_fspriv2 0x%p\n",
8063 -                          bp.pb_fspriv, bp.pb_fspriv2);
8064 -       }
8065 +       print_pagebuf(&bp, addr);
8066  
8067         return 0;
8068  }
8069  
8070 -/* XXXXXXXXXXXXXXXXXXXXXX */
8071 -/* The start of this deliberately looks like a read_descriptor_t in layout */
8072 -typedef struct {
8073 -       read_descriptor_t io_rdesc;
8074 -
8075 -       /* 0x10 */
8076 -       page_buf_rw_t io_dir;   /* read or write */
8077 -       loff_t io_offset;       /* Starting offset of I/O */
8078 -       int io_iovec_nr;        /* Number of entries in iovec */
8079 -
8080 -       /* 0x20 */
8081 -       struct iovec **io_iovec;        /* iovec list indexed by iovec_index */
8082 -       loff_t io_iovec_offset; /* offset into current iovec. */
8083 -       int io_iovec_index;     /* current iovec being processed */
8084 -       unsigned int io_sshift; /* sector bit shift */
8085 -       loff_t io_i_size;       /* size of the file */
8086 -} pb_io_desc_t;
8087 -
8088  static int
8089 -kdbm_pbiodesc(int argc, const char **argv, const char **envp,
8090 +kdbm_pbdelay(int argc, const char **argv, const char **envp,
8091         struct pt_regs *regs)
8092  {
8093 -       pb_io_desc_t    pbio;
8094 +#ifdef DEBUG
8095 +       unsigned long   verbose = 0;
8096 +       int     count = 0;
8097 +       struct list_head        *curr, *next;
8098 +       page_buf_t      bp;
8099         unsigned long addr;
8100 -       long    offset=0;
8101 -       int nextarg;
8102         int diag;
8103 +       extern struct list_head pbd_delwrite_queue;
8104  
8105 -       if (argc != 1)
8106 +       if (argc > 1)
8107                 return KDB_ARGCOUNT;
8108  
8109 -       nextarg = 1;
8110 -       if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs)) ||
8111 -           (diag = kdb_getarea(pbio, addr)))
8112 -
8113 -       kdb_printf("pb_io_desc_t at 0x%lx\n", addr);
8114 -       kdb_printf("  io_rdesc [ written 0x%lx count 0x%lx buf 0x%p error %d ]\n",
8115 -                       (unsigned long) pbio.io_rdesc.written,
8116 -                       (unsigned long) pbio.io_rdesc.count,
8117 -                       pbio.io_rdesc.buf, pbio.io_rdesc.error);
8118 -
8119 -       kdb_printf("  io_dir %d io_offset 0x%Lx io_iovec_nr 0x%d\n",
8120 -                       pbio.io_dir, pbio.io_offset, pbio.io_iovec_nr);
8121 +       if (argc == 1) {
8122 +               if ((diag = kdbgetularg(argv[1], &verbose))) {
8123 +                       return diag;
8124 +               }
8125 +       }
8126  
8127 -       kdb_printf("  io_iovec 0x%p io_iovec_offset 0x%Lx io_iovec_index 0x%d\n",
8128 -               pbio.io_iovec, pbio.io_iovec_offset, pbio.io_iovec_index);
8129 +       if (!verbose) {
8130 +               kdb_printf("index pb       pin   flushtime\n");
8131 +       }
8132  
8133 -       kdb_printf("  io_sshift 0x%d io_i_size 0x%Lx\n",
8134 -               pbio.io_sshift, pbio.io_i_size);
8135 +       list_for_each_safe(curr, next, &pbd_delwrite_queue) {
8136 +               addr = (unsigned long)list_entry(curr, page_buf_t, pb_list);
8137 +               if ((diag = kdb_getarea(bp, addr)))
8138 +                       return diag;
8139  
8140 +               if (verbose) {
8141 +                       print_pagebuf(&bp, addr);
8142 +               } else {
8143 +                       kdb_printf("%4d  0x%lx   %d   %ld\n",
8144 +                               count++, addr, 
8145 +                               bp.pb_pin_count.counter,
8146 +                               bp.pb_flushtime - jiffies);
8147 +               }
8148 +       }
8149 +#else
8150 +       kdb_printf("pbd_delwrite_queue inaccessible (non-debug)\n");
8151 +#endif
8152         return 0;
8153  }
8154  
8155  static int
8156 -kdbm_pbmap(int argc, const char **argv, const char **envp,
8157 +kdbm_iomap(int argc, const char **argv, const char **envp,
8158         struct pt_regs *regs)
8159  {
8160 -       page_buf_bmap_t pbm;
8161 +       xfs_iomap_t iomap;
8162         unsigned long addr;
8163 -       long    offset=0;
8164 +       long offset=0;
8165         int nextarg;
8166         int diag;
8167  
8168 @@ -1960,113 +2606,49 @@
8169  
8170         nextarg = 1;
8171         if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs)) ||
8172 -           (diag = kdb_getarea(pbm, addr)))
8173 +           (diag = kdb_getarea(iomap, addr)))
8174  
8175 -       kdb_printf("page_buf_bmap_t at 0x%lx\n", addr);
8176 -       kdb_printf("  pbm_bn 0x%llx pbm_offset 0x%Lx pbm_delta 0x%lx pbm_bsize 0x%lx\n",
8177 -               (long long) pbm.pbm_bn, pbm.pbm_offset,
8178 -               (unsigned long) pbm.pbm_delta, (unsigned long) pbm.pbm_bsize);
8179 +       kdb_printf("iomap_t at 0x%lx\n", addr);
8180 +       kdb_printf("  iomap_bn 0x%llx iomap_offset 0x%Lx iomap_delta 0x%lx iomap_bsize 0x%lx\n",
8181 +               (long long) iomap.iomap_bn, iomap.iomap_offset,
8182 +               (unsigned long) iomap.iomap_delta, (unsigned long) iomap.iomap_bsize);
8183  
8184 -       kdb_printf("  pbm_flags %s\n", map_flags(pbm.pbm_flags, pbm_flag_vals));
8185 +       kdb_printf("  iomap_flags %s\n", map_flags(iomap.iomap_flags, iomap_flag_vals));
8186  
8187         return 0;
8188  }
8189  
8190  #ifdef PAGEBUF_TRACE
8191 -# ifdef __PAGEBUF_TRACE__
8192 -# undef __PAGEBUF_TRACE__
8193 -# undef PB_DEFINE_TRACES
8194 -# undef PB_TRACE_START
8195 -# undef PB_TRACE_REC
8196 -# undef PB_TRACE_END
8197 -# endif
8198 -#include "pagebuf/page_buf_trace.h"
8199 -
8200 -#define EV_SIZE        (sizeof(event_names)/sizeof(char *))
8201 -
8202 -void
8203 -pb_trace_core(
8204 -       unsigned long match,
8205 -       char    *event_match,
8206 -       unsigned long long offset,
8207 -       long long mask)
8208 -{
8209 -       extern struct pagebuf_trace_buf pb_trace;
8210 -       int i, total, end;
8211 -       pagebuf_trace_t *trace;
8212 -       char    *event;
8213 -       char    value[10];
8214 -
8215 -       end = pb_trace.start - 1;
8216 -       if (end < 0)
8217 -               end = PB_TRACE_BUFSIZE - 1;
8218 -
8219 -       if (match && (match < PB_TRACE_BUFSIZE)) {
8220 -               for (i = pb_trace.start, total = 0; i != end; i = CIRC_INC(i)) {
8221 -                       trace = &pb_trace.buf[i];
8222 -                       if (trace->pb == 0)
8223 -                               continue;
8224 -                       total++;
8225 -               }
8226 -               total = total - match;
8227 -               for (i = pb_trace.start; i != end && total; i = CIRC_INC(i)) {
8228 -                       trace = &pb_trace.buf[i];
8229 -                       if (trace->pb == 0)
8230 -                               continue;
8231 -                       total--;
8232 -               }
8233 -               match = 0;
8234 -       } else
8235 -               i = pb_trace.start;
8236 -       for ( ; i != end; i = CIRC_INC(i)) {
8237 -               trace = &pb_trace.buf[i];
8238 -
8239 -               if (offset) {
8240 -                       if ((trace->offset & ~mask) != offset)
8241 -                               continue;
8242 -               }
8243 -
8244 -               if (trace->pb == 0)
8245 -                       continue;
8246 -
8247 -               if ((match != 0) && (trace->pb != match))
8248 -                       continue;
8249 -
8250 -               if ((trace->event < EV_SIZE-1) && event_names[trace->event]) {
8251 -                       event = event_names[trace->event];
8252 -               } else if (trace->event == EV_SIZE-1) {
8253 -                       event = (char *)trace->misc;
8254 -               } else {
8255 -                       event = value;
8256 -                       sprintf(value, "%8d", trace->event);
8257 -               }
8258 -
8259 -               if (event_match && strcmp(event, event_match)) {
8260 -                       continue;
8261 -               }
8262 +static int pagebuf_trace_entry(ktrace_entry_t *ktep)
8263 +{
8264 +       unsigned long long daddr;
8265  
8266 +       daddr = ((unsigned long long)(unsigned long)ktep->val[8] << 32)
8267 +               | ((unsigned long long)(unsigned long)ktep->val[9]);
8268  
8269 -               kdb_printf("pb 0x%lx [%s] (hold %u lock %d) misc 0x%p",
8270 -                          trace->pb, event,
8271 -                          trace->hold, trace->lock_value,
8272 -                          trace->misc);
8273 -               kdb_symbol_print((unsigned int)trace->ra, NULL,
8274 -                       KDB_SP_SPACEB|KDB_SP_PAREN|KDB_SP_NEWLINE);
8275 -               kdb_printf("    offset 0x%Lx size 0x%x task 0x%p\n",
8276 -                          trace->offset, trace->size, trace->task);
8277 -               kdb_printf("    flags: %s\n",
8278 -                          pb_flags(trace->flags));
8279 -       }
8280 +       kdb_printf("pb 0x%p [%s] (hold %lu lock %ld) data 0x%p",
8281 +               ktep->val[0],
8282 +               (char *)ktep->val[1],
8283 +               (unsigned long)ktep->val[3],
8284 +               (long)ktep->val[4],
8285 +               ktep->val[6]);
8286 +       kdb_symbol_print((unsigned long)ktep->val[7], NULL,
8287 +               KDB_SP_SPACEB|KDB_SP_PAREN|KDB_SP_NEWLINE);
8288 +       kdb_printf("    offset 0x%llx size 0x%lx task 0x%p\n",
8289 +               daddr, (long)ktep->val[10], ktep->val[5]);
8290 +       kdb_printf("    flags: %s\n", pb_flags((int)(long)ktep->val[2]));
8291 +       return 1;
8292  }
8293  
8294 -
8295  static int
8296  kdbm_pbtrace_offset(int argc, const char **argv, const char **envp,
8297         struct pt_regs *regs)
8298  {
8299 -       long mask = 0;
8300 -       unsigned long offset = 0;
8301 -       int diag;
8302 +       long            mask = 0;
8303 +       unsigned long   offset = 0;
8304 +       int             diag;
8305 +       ktrace_entry_t  *ktep;
8306 +       ktrace_snap_t   kts;
8307  
8308         if (argc > 2)
8309                 return KDB_ARGCOUNT;
8310 @@ -2078,13 +2660,23 @@
8311         }
8312  
8313         if (argc > 1) {
8314 -               diag = kdbgetularg(argv[1], &mask);
8315 +               diag = kdbgetularg(argv[1], &mask);     /* sign extent mask */
8316                 if (diag)
8317                         return diag;
8318         }
8319  
8320 -       pb_trace_core(0, NULL, (unsigned long long)offset,
8321 -                              (long long)mask);        /* sign extent mask */
8322 +       ktep = ktrace_first(pagebuf_trace_buf, &kts);
8323 +       while (ktep != NULL) {
8324 +               unsigned long long daddr;
8325 +
8326 +               daddr = ((unsigned long long)(unsigned long)ktep->val[8] << 32)
8327 +                       | ((unsigned long long)(unsigned long)ktep->val[9]);
8328 +               if (offset && ((daddr & ~mask) != offset))
8329 +                       continue;
8330 +               if (pagebuf_trace_entry(ktep))
8331 +                       kdb_printf("\n");
8332 +               ktep = ktrace_next(pagebuf_trace_buf, &kts);
8333 +       }
8334         return 0;
8335  }
8336  
8337 @@ -2092,10 +2684,12 @@
8338  kdbm_pbtrace(int argc, const char **argv, const char **envp,
8339         struct pt_regs *regs)
8340  {
8341 -       unsigned long addr = 0;
8342 -       int diag, nextarg;
8343 -       long offset = 0;
8344 -       char    *event_match = NULL;
8345 +       unsigned long   addr = 0;
8346 +       int             diag, nextarg;
8347 +       long            offset = 0;
8348 +       char            *event_match = NULL;
8349 +       ktrace_entry_t  *ktep;
8350 +       ktrace_snap_t   kts;
8351  
8352         if (argc > 1)
8353                 return KDB_ARGCOUNT;
8354 @@ -2103,69 +2697,102 @@
8355         if (argc == 1) {
8356                 if (isupper(argv[1][0]) || islower(argv[1][0])) {
8357                         event_match = (char *)argv[1];
8358 -                       printk("event match on \"%s\"\n", event_match);
8359 +                       kdb_printf("event match on \"%s\"\n", event_match);
8360                         argc = 0;
8361                 } else {
8362                         nextarg = 1;
8363 -                       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
8364 +                       diag = kdbgetaddrarg(argc, argv,
8365 +                                       &nextarg, &addr, &offset, NULL, regs);
8366                         if (diag) {
8367 -                               printk("failed to parse %s as a number\n",
8368 -                                                               argv[1]);
8369 +                               kdb_printf("non-numeric arg: %s\n", argv[1]);
8370                                 return diag;
8371                         }
8372                 }
8373         }
8374  
8375 -       pb_trace_core(addr, event_match, 0LL, 0LL);
8376 -       return 0;
8377 -}
8378 -
8379 -#else  /* PAGEBUF_TRACE */
8380 -static int
8381 -kdbm_pbtrace(int argc, const char **argv, const char **envp,
8382 -       struct pt_regs *regs)
8383 -{
8384 -       kdb_printf("pagebuf tracing not compiled in\n");
8385 -
8386 +       ktep = ktrace_first(pagebuf_trace_buf, &kts);
8387 +       while (ktep != NULL) {
8388 +               if (addr && (ktep->val[0] != (void *)addr))
8389 +                       continue;
8390 +               if (event_match && strcmp((char *)ktep->val[1], event_match))
8391 +                       continue;
8392 +               if (pagebuf_trace_entry(ktep))
8393 +                       qprintf("\n");
8394 +               ktep = ktrace_next(pagebuf_trace_buf, &kts);
8395 +       }
8396         return 0;
8397  }
8398 -#endif /* PAGEBUF_TRACE */
8399 +#endif
8400  
8401 -static struct xif {
8402 +struct xif {
8403         char    *name;
8404         int     (*func)(int, const char **, const char **, struct pt_regs *);
8405         char    *args;
8406         char    *help;
8407 -} xfsidbg_funcs[] = {
8408 +};
8409 +
8410 +static struct xif xfsidbg_funcs[] = {
8411 +  {  "bhv",    kdbm_bhv,       "<bhv>", "Dump bhv chain"},
8412    {  "vn",     kdbm_vn,        "<vnode>", "Dump inode/vnode/trace"},
8413    {  "vnode",  kdbm_vnode,     "<vnode>", "Dump vnode"},
8414 -#ifdef CONFIG_XFS_VNODE_TRACING
8415 +  {  "vfs",    kdbm_vfs,       "<vfs>", "Dump vfs"},
8416 +#ifdef XFS_VNODE_TRACE
8417    {  "vntrace",        kdbm_vntrace,   "<vntrace>", "Dump vnode Trace"},
8418 -  {  "vntraceaddr",    kdbm_vntraceaddr, "<vntrace>", "Dump vnode Trace by Address"},
8419 -#endif /* CONFIG_XFS_VNODE_TRACING */
8420 +  {  "vntraceaddr",    kdbm_vntraceaddr, "<vntrace>",
8421 +                               "Dump vnode Trace by Address"},
8422 +#endif
8423    {  "xagf",   kdbm_xfs_xagf,  "<agf>",
8424                                 "Dump XFS allocation group freespace" },
8425    {  "xagi",   kdbm_xfs_xagi,  "<agi>",
8426                                 "Dump XFS allocation group inode" },
8427    {  "xail",   kdbm_xfs_xaildump,      "<xfs_mount_t>",
8428                                 "Dump XFS AIL for a mountpoint" },
8429 +#ifdef XFS_ALLOC_TRACE
8430 +  {  "xalatrc",        kdbm_xfs_xalatrace,     "<count>",
8431 +                               "Dump XFS alloc count trace" },
8432 +  {  "xalbtrc",        kdbm_xfs_xalbtrace,     "<xfs_agblock_t>",
8433 +                               "Dump XFS alloc block trace" },
8434 +  {  "xalgtrc",        kdbm_xfs_xalgtrace,     "<xfs_agnumber_t>",
8435 +                               "Dump XFS alloc alloc-group trace" },
8436 +#endif
8437 +
8438    {  "xalloc", kdbm_xfs_xalloc,        "<xfs_alloc_arg_t>",
8439                                 "Dump XFS allocation args structure" },
8440 -#ifdef DEBUG
8441 +#ifdef XFS_ALLOC_TRACE
8442    {  "xalmtrc",        kdbm_xfs_xalmtrace,     "<xfs_mount_t>",
8443                                 "Dump XFS alloc mount-point trace" },
8444 +  {  "xalttrc",        kdbm_xfs_xalttrace,     "<tag>",
8445 +                               "Dump XFS alloc trace by tag number" },
8446  #endif
8447 +  {  "xarg",   kdbm_xfs_xarg,          "<value>",
8448 +                               "Input XFS argument for next function" },
8449    {  "xattrcx",        kdbm_xfs_xattrcontext,  "<xfs_attr_list_context_t>",
8450                                 "Dump XFS attr_list context struct"},
8451    {  "xattrlf",        kdbm_xfs_xattrleaf,     "<xfs_attr_leafblock_t>",
8452                                 "Dump XFS attribute leaf block"},
8453    {  "xattrsf",        kdbm_xfs_xattrsf,       "<xfs_attr_shortform_t>",
8454                                 "Dump XFS attribute shortform"},
8455 +#ifdef XFS_ATTR_TRACE
8456 +  {  "xattrtr",        kdbm_xfs_xattrtrace,    "<count>",
8457 +                               "Dump XFS attribute attr_list() trace" },
8458 +#endif
8459    {  "xbirec", kdbm_xfs_xbirec,        "<xfs_bmbt_irec_t",
8460                                 "Dump XFS bmap incore record"},
8461 +#ifdef XFS_BLI_TRACE
8462 +  {  "xblitrc",        kdbm_xfs_xblitrace,     "<xfs_buf_log_item_t>",
8463 +                               "Dump XFS buf log item trace" },
8464 +#endif
8465    {  "xbmalla",        kdbm_xfs_xbmalla,       "<xfs_bmalloca_t>",
8466                                 "Dump XFS bmalloc args structure"},
8467 -  {  "xbrec",  kdbm_xfs_xbrec,         "<xfs_bmbt_rec_64_t",
8468 +#ifdef XFS_BMAP_TRACE
8469 +  {  "xbmatrc",        kdbm_xfs_xbmatrace,     "<count>",
8470 +                               "Dump XFS bmap btree count trace" },
8471 +  {  "xbmitrc",        kdbm_xfs_xbmitrace,     "<xfs_inode_t>",
8472 +                               "Dump XFS bmap btree per-inode trace" },
8473 +  {  "xbmstrc",        kdbm_xfs_xbmstrace,     "<xfs_inode_t>",
8474 +                               "Dump XFS bmap btree inode trace" },
8475 +#endif
8476 +  {  "xbrec",  kdbm_xfs_xbrec,         "<xfs_bmbt_rec_64_t>",
8477                                 "Dump XFS bmap record"},
8478    {  "xbroot", kdbm_xfs_xbroot,        "<xfs_inode_t>",
8479                                 "Dump XFS bmap btree root (data)"},
8480 @@ -2175,12 +2802,29 @@
8481                                 "Dump XFS btree cursor"},
8482    {  "xbuf",   kdbm_xfs_xbuf,          "<xfs_buf_t>",
8483                                 "Dump XFS data from a buffer"},
8484 +#ifdef XFS_BMAP_TRACE
8485 +  {  "xbxatrc",        kdbm_xfs_xbxatrace,     "<count>",
8486 +                               "Dump XFS bmap extent count trace" },
8487 +  {  "xbxitrc",        kdbm_xfs_xbxitrace,     "<xfs_inode_t>",
8488 +                               "Dump XFS bmap extent per-inode trace" },
8489 +  {  "xbxstrc",        kdbm_xfs_xbxstrace,     "<xfs_inode_t>",
8490 +                               "Dump XFS bmap extent inode trace" },
8491 +#endif
8492    {  "xchash", kdbm_xfs_xchash,        "<xfs_mount_t>",
8493                                 "Dump XFS cluster hash"},
8494    {  "xchlist",        kdbm_xfs_xchashlist,    "<xfs_chashlist_t>",
8495                                 "Dump XFS cluster hash list"},
8496 +  {  "xchksum",        kdbm_xfs_xchksum,       "<addr>", "Dump chksum" },
8497 +#ifdef XFS_DIR2_TRACE
8498 +  {  "xd2atrc",        kdbm_xfs_xdir2atrace,   "<count>",
8499 +                               "Dump XFS directory v2 count trace" },
8500 +#endif
8501    {  "xd2free",        kdbm_xfs_xdir2free,     "<xfs_dir2_free_t>",
8502                                 "Dump XFS directory v2 freemap"},
8503 +#ifdef XFS_DIR2_TRACE
8504 +  {  "xd2itrc",        kdbm_xfs_xdir2itrace,   "<xfs_inode_t>",
8505 +                               "Dump XFS directory v2 per-inode trace" },
8506 +#endif
8507    {  "xdaargs",        kdbm_xfs_xdaargs,       "<xfs_da_args_t>",
8508                                 "Dump XFS dir/attr args structure"},
8509    {  "xdabuf", kdbm_xfs_xdabuf,        "<xfs_dabuf_t>",
8510 @@ -2197,12 +2841,20 @@
8511                                 "Dump XFS directory shortform"},
8512    {  "xdir2sf",        kdbm_xfs_xdir2sf,       "<xfs_dir2_sf_t>",
8513                                 "Dump XFS directory v2 shortform"},
8514 +#ifdef XFS_DIR_TRACE
8515 +  {  "xdirtrc",        kdbm_xfs_xdirtrace,     "<count>",
8516 +                               "Dump XFS directory getdents() trace" },
8517 +#endif
8518    {  "xdiskdq",        kdbm_xfs_xqm_diskdq,    "<xfs_disk_dquot_t>",
8519                                 "Dump XFS ondisk dquot (quota) struct"},
8520    {  "xdqatt", kdbm_xfs_xqm_dqattached_inos,   "<xfs_mount_t>",
8521                                  "All incore inodes with dquots"},
8522    {  "xdqinfo",        kdbm_xfs_xqm_tpdqinfo,  "<xfs_trans_t>",
8523                                 "Dump dqinfo structure of a trans"},
8524 +#ifdef XFS_DQUOT_TRACE
8525 +  {  "xdqtrace",kdbm_xfs_xqm_dqtrace,  "<xfs_dquot_t>",
8526 +                               "Dump trace of a given dquot" },
8527 +#endif
8528    {  "xdquot", kdbm_xfs_xqm_dquot,     "<xfs_dquot_t>",
8529                                 "Dump XFS dquot (quota) structure"},
8530    {  "xexlist",        kdbm_xfs_xexlist,       "<xfs_inode_t>",
8531 @@ -2215,12 +2867,26 @@
8532                                 "Dump All XFS in-core logs"},
8533    {  "xiclog", kdbm_xfs_xiclog,        "<xlog_in_core_t>",
8534                                 "Dump XFS in-core log"},
8535 +#ifdef XFS_LOG_TRACE
8536 +  {  "xictrc", kdbm_xfs_xiclogtrace,   "<xlog_in_core_t>",
8537 +                               "Dump XFS in-core log trace" },
8538 +#endif
8539    {  "xihash", kdbm_xfs_xihash,        "<xfs_mount_t>",
8540                                 "Dump XFS inode hash statistics"},
8541 +#ifdef XFS_ILOCK_TRACE
8542 +  {  "xilocktrc",kdbm_xfs_xilock_trace,        "<xfs_inode_t>",
8543 +                               "Dump XFS ilock trace" },
8544 +  {  "xailcktrc",kdbm_xfs_xailock_trace,"<count>",
8545 +                               "Dump XFS global ilock trace" },
8546 +#endif
8547    {  "xinodes",        kdbm_xfs_xinodes,       "<xfs_mount_t>",
8548                                 "Dump XFS inodes per mount"},
8549    {  "xquiesce",kdbm_xfs_xinodes_quiesce, "<xfs_mount_t>",
8550                                 "Dump non-quiesced XFS inodes per mount"},
8551 +#ifdef XFS_LOG_TRACE
8552 +  {  "xl_grtr",        kdbm_xfs_xlog_granttrace,       "<xlog_t>",
8553 +                               "Dump XFS log grant trace" },
8554 +#endif
8555    {  "xl_rcit",        kdbm_xfs_xlog_ritem,    "<xlog_recover_item_t>",
8556                                 "Dump XFS recovery item"},
8557    {  "xl_rctr",        kdbm_xfs_xlog_rtrans,   "<xlog_recover_t>",
8558 @@ -2255,6 +2921,10 @@
8559  #endif /* CONFIG_XFS_QUOTA */
8560    {  "xqmplist",kdbm_xfs_xqm_mplist,   "<xfs_mount_t>",
8561                                 "Dump XFS all dquots of a f/s"},
8562 +#ifdef XFS_RW_TRACE
8563 +  {  "xrwtrc", kdbm_xfs_xrwtrace,      "<xfs_inode_t>",
8564 +                               "Dump XFS inode read/write trace" },
8565 +#endif
8566    {  "xsb",    kdbm_xfs_xsb,           "<xfs_sb_t> <cnv>",
8567                                 "Dump XFS superblock"},
8568    {  "xtp",    kdbm_xfs_xtp,           "<xfs_trans_t>",
8569 @@ -2264,6 +2934,18 @@
8570    {  0,                0,      0 }
8571  };
8572  
8573 +static struct xif pb_funcs[] = {
8574 +  {  "pb",     kdbm_pb,        "<vaddr>",      "Display page_buf_t" },
8575 +  {  "pbflags",        kdbm_pb_flags,  "<flags>",      "Display page_buf flags" },
8576 +  {  "iomapap",        kdbm_iomap,     "<iomap_t *>",  "Display IOmap" },
8577 +  {  "pbdelay",        kdbm_pbdelay,   "0|1",          "Display delwri pagebufs" },
8578 +#ifdef PAGEBUF_TRACE
8579 +  {  "pbtrace",        kdbm_pbtrace,   "<vaddr>|<count>",      "page_buf_t trace" },
8580 +  {  "pboffset",kdbm_pbtrace_offset, "<daddr> [<mask>]","page_buf_t trace" },
8581 +#endif
8582 +  {  0,                0,      0 }
8583 +};
8584 +
8585  static int
8586  __init xfsidbg_init(void)
8587  {
8588 @@ -2271,20 +2953,8 @@
8589  
8590         for (p = xfsidbg_funcs; p->name; p++)
8591                 kdb_register(p->name, p->func, p->args, p->help, 0);
8592 -
8593 -       kdb_register("pb", kdbm_pb, "<vaddr>", "Display page_buf_t", 0);
8594 -       kdb_register("pbflags", kdbm_pb_flags, "<flags>",
8595 -                                       "Display page buf flags", 0);
8596 -       kdb_register("pbiodesc", kdbm_pbiodesc, "<pb_io_desc_t *>",
8597 -                                       "Display I/O Descriptor", 0);
8598 -       kdb_register("pbmap", kdbm_pbmap, "<page_buf_bmap_t *>",
8599 -                                       "Display Bmap", 0);
8600 -       kdb_register("pbtrace", kdbm_pbtrace, "<vaddr>|<count>",
8601 -                                       "page_buf_t trace", 0);
8602 -#ifdef PAGEBUF_TRACE
8603 -       kdb_register("pboffset", kdbm_pbtrace_offset, "<addr> [<mask>]",
8604 -                                       "page_buf_t trace", 0);
8605 -#endif
8606 +       for (p = pb_funcs; p->name; p++)
8607 +               kdb_register(p->name, p->func, p->args, p->help, 0);
8608         return 0;
8609  }
8610  
8611 @@ -2295,16 +2965,8 @@
8612  
8613         for (p = xfsidbg_funcs; p->name; p++)
8614                 kdb_unregister(p->name);
8615 -
8616 -       kdb_unregister("pb");
8617 -       kdb_unregister("pbflags");
8618 -       kdb_unregister("pbmap");
8619 -       kdb_unregister("pbiodesc");
8620 -       kdb_unregister("pbtrace");
8621 -#ifdef PAGEBUF_TRACE
8622 -       kdb_unregister("pboffset");
8623 -#endif
8624 -
8625 +       for (p = pb_funcs; p->name; p++)
8626 +               kdb_unregister(p->name);
8627  }
8628  
8629  /*
8630 @@ -2315,19 +2977,35 @@
8631         "start_bno", "near_bno", "this_bno"
8632  };
8633  
8634 +static int xargument = 0;
8635  
8636  /*
8637   * Prototypes for static functions.
8638   */
8639 -#ifdef DEBUG
8640 +#ifdef XFS_ALLOC_TRACE
8641  static int xfs_alloc_trace_entry(ktrace_entry_t *ktep);
8642  #endif
8643 +#ifdef XFS_ATTR_TRACE
8644 +static int xfs_attr_trace_entry(ktrace_entry_t *ktep);
8645 +#endif
8646 +#ifdef XFS_BMAP_TRACE
8647 +static int xfs_bmap_trace_entry(ktrace_entry_t *ktep);
8648 +#endif
8649 +#ifdef XFS_BMAP_TRACE
8650 +static int xfs_bmbt_trace_entry(ktrace_entry_t *ktep);
8651 +#endif
8652  static void xfs_broot(xfs_inode_t *ip, xfs_ifork_t *f);
8653  static void xfs_btalloc(xfs_alloc_block_t *bt, int bsz);
8654  static void xfs_btbmap(xfs_bmbt_block_t *bt, int bsz);
8655  static void xfs_btino(xfs_inobt_block_t *bt, int bsz);
8656  static void xfs_buf_item_print(xfs_buf_log_item_t *blip, int summary);
8657  static void xfs_dastate_path(xfs_da_state_path_t *p);
8658 +#ifdef XFS_DIR_TRACE
8659 +static int xfs_dir_trace_entry(ktrace_entry_t *ktep);
8660 +#endif
8661 +#ifdef XFS_DIR2_TRACE
8662 +static int xfs_dir2_trace_entry(ktrace_entry_t *ktep);
8663 +#endif
8664  static void xfs_dir2data(void *addr, int size);
8665  static void xfs_dir2leaf(xfs_dir2_leaf_t *leaf, int size);
8666  static void xfs_dquot_item_print(xfs_dq_logitem_t *lip, int summary);
8667 @@ -2345,6 +3023,10 @@
8668  static void xfs_prdinode(xfs_dinode_t *di, int coreonly, int convert);
8669  static void xfs_prdinode_core(xfs_dinode_core_t *dip, int convert);
8670  static void xfs_qoff_item_print(xfs_qoff_logitem_t *lip, int summary);
8671 +#ifdef XFS_RW_TRACE
8672 +static void xfs_rw_enter_trace_entry(ktrace_entry_t *ktep);
8673 +static int xfs_rw_trace_entry(ktrace_entry_t *ktep);
8674 +#endif
8675  static void xfs_xexlist_fork(xfs_inode_t *ip, int whichfork);
8676  static void xfs_xnode_fork(char *name, xfs_ifork_t *f);
8677  
8678 @@ -2352,7 +3034,7 @@
8679   * Static functions.
8680   */
8681  
8682 -#ifdef DEBUG
8683 +#ifdef XFS_ALLOC_TRACE
8684  /*
8685   * Print xfs alloc trace buffer entry.
8686   */
8687 @@ -2378,24 +3060,24 @@
8688                 return 0;
8689         switch ((long)ktep->val[0] & 0xffffL) {
8690         case XFS_ALLOC_KTRACE_ALLOC:
8691 -               kdb_printf("alloc %s[%s %d] mp 0x%p\n",
8692 +               kdb_printf("alloc %s[%s %ld] mp 0x%p\n",
8693                         (char *)ktep->val[1],
8694                         ktep->val[2] ? (char *)ktep->val[2] : "",
8695 -                       (__psint_t)ktep->val[0] >> 16,
8696 +                       (long)ktep->val[0] >> 16,
8697                         (xfs_mount_t *)ktep->val[3]);
8698                 kdb_printf(
8699 -       "agno %d agbno %d minlen %d maxlen %d mod %d prod %d minleft %d\n",
8700 -                       (__psunsigned_t)ktep->val[4],
8701 -                       (__psunsigned_t)ktep->val[5],
8702 -                       (__psunsigned_t)ktep->val[6],
8703 -                       (__psunsigned_t)ktep->val[7],
8704 -                       (__psunsigned_t)ktep->val[8],
8705 -                       (__psunsigned_t)ktep->val[9],
8706 -                       (__psunsigned_t)ktep->val[10]);
8707 -               kdb_printf("total %d alignment %d len %d type %s otype %s\n",
8708 -                       (__psunsigned_t)ktep->val[11],
8709 -                       (__psunsigned_t)ktep->val[12],
8710 -                       (__psunsigned_t)ktep->val[13],
8711 +       "agno %ld agbno %ld minlen %ld maxlen %ld mod %ld prod %ld minleft %ld\n",
8712 +                       (long)ktep->val[4],
8713 +                       (long)ktep->val[5],
8714 +                       (long)ktep->val[6],
8715 +                       (long)ktep->val[7],
8716 +                       (long)ktep->val[8],
8717 +                       (long)ktep->val[9],
8718 +                       (long)ktep->val[10]);
8719 +               kdb_printf("total %ld alignment %ld len %ld type %s otype %s\n",
8720 +                       (long)ktep->val[11],
8721 +                       (long)ktep->val[12],
8722 +                       (long)ktep->val[13],
8723                         xfs_alloctype[((__psint_t)ktep->val[14]) >> 16],
8724                         xfs_alloctype[((__psint_t)ktep->val[14]) & 0xffff]);
8725                 kdb_printf("wasdel %d wasfromfl %d isfl %d userdata %d\n",
8726 @@ -2405,76 +3087,76 @@
8727                         ((__psint_t)ktep->val[15] & (1 << 0)) != 0);
8728                 break;
8729         case XFS_ALLOC_KTRACE_FREE:
8730 -               kdb_printf("free %s[%s %d] mp 0x%p\n",
8731 +               kdb_printf("free %s[%s %ld] mp 0x%p\n",
8732                         (char *)ktep->val[1],
8733                         ktep->val[2] ? (char *)ktep->val[2] : "",
8734 -                       (__psint_t)ktep->val[0] >> 16,
8735 +                       (long)ktep->val[0] >> 16,
8736                         (xfs_mount_t *)ktep->val[3]);
8737 -               kdb_printf("agno %d agbno %d len %d isfl %d\n",
8738 -                       (__psunsigned_t)ktep->val[4],
8739 -                       (__psunsigned_t)ktep->val[5],
8740 -                       (__psunsigned_t)ktep->val[6],
8741 -                       (__psint_t)ktep->val[7]);
8742 +               kdb_printf("agno %ld agbno %ld len %ld isfl %d\n",
8743 +                       (long)ktep->val[4],
8744 +                       (long)ktep->val[5],
8745 +                       (long)ktep->val[6],
8746 +                       (__psint_t)ktep->val[7] != 0);
8747                 break;
8748         case XFS_ALLOC_KTRACE_MODAGF:
8749 -               kdb_printf("modagf %s[%s %d] mp 0x%p\n",
8750 +               kdb_printf("modagf %s[%s %ld] mp 0x%p\n",
8751                         (char *)ktep->val[1],
8752                         ktep->val[2] ? (char *)ktep->val[2] : "",
8753 -                       (__psint_t)ktep->val[0] >> 16,
8754 +                       (long)ktep->val[0] >> 16,
8755                         (xfs_mount_t *)ktep->val[3]);
8756                 printflags((__psint_t)ktep->val[4], modagf_flags, "modified");
8757 -               kdb_printf("seqno %d length %d roots b %d c %d\n",
8758 -                       (__psunsigned_t)ktep->val[5],
8759 -                       (__psunsigned_t)ktep->val[6],
8760 -                       (__psunsigned_t)ktep->val[7],
8761 -                       (__psunsigned_t)ktep->val[8]);
8762 -               kdb_printf("levels b %d c %d flfirst %d fllast %d flcount %d\n",
8763 -                       (__psunsigned_t)ktep->val[9],
8764 -                       (__psunsigned_t)ktep->val[10],
8765 -                       (__psunsigned_t)ktep->val[11],
8766 -                       (__psunsigned_t)ktep->val[12],
8767 -                       (__psunsigned_t)ktep->val[13]);
8768 -               kdb_printf("freeblks %d longest %d\n",
8769 -                       (__psunsigned_t)ktep->val[14],
8770 -                       (__psunsigned_t)ktep->val[15]);
8771 +               kdb_printf("seqno %lu length %lu roots b %lu c %lu\n",
8772 +                       (unsigned long)ktep->val[5],
8773 +                       (unsigned long)ktep->val[6],
8774 +                       (unsigned long)ktep->val[7],
8775 +                       (unsigned long)ktep->val[8]);
8776 +               kdb_printf("levels b %lu c %lu flfirst %lu fllast %lu flcount %lu\n",
8777 +                       (unsigned long)ktep->val[9],
8778 +                       (unsigned long)ktep->val[10],
8779 +                       (unsigned long)ktep->val[11],
8780 +                       (unsigned long)ktep->val[12],
8781 +                       (unsigned long)ktep->val[13]);
8782 +               kdb_printf("freeblks %lu longest %lu\n",
8783 +                       (unsigned long)ktep->val[14],
8784 +                       (unsigned long)ktep->val[15]);
8785                 break;
8786  
8787         case XFS_ALLOC_KTRACE_UNBUSY:
8788 -               kdb_printf("unbusy %s [%s %d] mp 0x%p\n",
8789 +               kdb_printf("unbusy %s [%s %ld] mp 0x%p\n",
8790                         (char *)ktep->val[1],
8791                         ktep->val[2] ? (char *)ktep->val[2] : "",
8792 -                       (__psint_t)ktep->val[0] >> 16,
8793 +                       (long)ktep->val[0] >> 16,
8794                         (xfs_mount_t *)ktep->val[3]);
8795 -               kdb_printf("      agno %d slot %d tp 0x%x\n",
8796 -                       (__psunsigned_t)ktep->val[4],
8797 -                       (__psunsigned_t)ktep->val[7],
8798 -                       (__psunsigned_t)ktep->val[8]);
8799 +               kdb_printf("      agno %lu slot %lu tp 0x%p\n",
8800 +                       (unsigned long)ktep->val[4],
8801 +                       (unsigned long)ktep->val[7],
8802 +                       (xfs_trans_t *)ktep->val[8]);
8803                 break;
8804         case XFS_ALLOC_KTRACE_BUSY:
8805 -               kdb_printf("busy %s [%s %d] mp 0x%p\n",
8806 +               kdb_printf("busy %s [%s %ld] mp 0x%p\n",
8807                         (char *)ktep->val[1],
8808                         ktep->val[2] ? (char *)ktep->val[2] : "",
8809 -                       (__psint_t)ktep->val[0] >> 16,
8810 +                       (long)ktep->val[0] >> 16,
8811                         (xfs_mount_t *)ktep->val[3]);
8812 -               kdb_printf("      agno %d agbno %d len %d slot %d tp 0x%x\n",
8813 -                       (__psunsigned_t)ktep->val[4],
8814 -                       (__psunsigned_t)ktep->val[5],
8815 -                       (__psunsigned_t)ktep->val[6],
8816 -                       (__psunsigned_t)ktep->val[7],
8817 -                       (__psunsigned_t)ktep->val[8]);
8818 +               kdb_printf("      agno %lu agbno %lu len %lu slot %lu tp 0x%p\n",
8819 +                       (unsigned long)ktep->val[4],
8820 +                       (unsigned long)ktep->val[5],
8821 +                       (unsigned long)ktep->val[6],
8822 +                       (unsigned long)ktep->val[7],
8823 +                       (xfs_trans_t *)ktep->val[8]);
8824                 break;
8825         case XFS_ALLOC_KTRACE_BUSYSEARCH:
8826 -               kdb_printf("busy-search %s [%s %d] mp 0x%p\n",
8827 +               kdb_printf("busy-search %s [%s %ld] mp 0x%p\n",
8828                         (char *)ktep->val[1],
8829                         ktep->val[2] ? (char *)ktep->val[2] : "",
8830 -                       (__psint_t)ktep->val[0] >> 16,
8831 +                       (long)ktep->val[0] >> 16,
8832                         (xfs_mount_t *)ktep->val[3]);
8833 -               kdb_printf("      agno %d agbno %d len %d slot %d tp 0x%x\n",
8834 -                       (__psunsigned_t)ktep->val[4],
8835 -                       (__psunsigned_t)ktep->val[5],
8836 -                       (__psunsigned_t)ktep->val[6],
8837 -                       (__psunsigned_t)ktep->val[7],
8838 -                       (__psunsigned_t)ktep->val[8]);
8839 +               kdb_printf("      agno %ld agbno %ld len %ld slot %ld tp 0x%p\n",
8840 +                       (unsigned long)ktep->val[4],
8841 +                       (unsigned long)ktep->val[5],
8842 +                       (unsigned long)ktep->val[6],
8843 +                       (unsigned long)ktep->val[7],
8844 +                       (xfs_trans_t *)ktep->val[8]);
8845                 break;
8846         default:
8847                 kdb_printf("unknown alloc trace record\n");
8848 @@ -2482,7 +3164,242 @@
8849         }
8850         return 1;
8851  }
8852 -#endif /* DEBUG */
8853 +#endif /* XFS_ALLOC_TRACE */
8854 +
8855 +#ifdef XFS_ATTR_TRACE
8856 +/*
8857 + * Print an attribute trace buffer entry.
8858 + */
8859 +static int
8860 +xfs_attr_trace_entry(ktrace_entry_t *ktep)
8861 +{
8862 +       static char *attr_arg_flags[] = {
8863 +               "DONTFOLLOW",   /* 0x0001 */
8864 +               "ROOT",         /* 0x0002 */
8865 +               "TRUSTED",      /* 0x0004 */
8866 +               "?",            /* 0x0008 */
8867 +               "CREATE",       /* 0x0010 */
8868 +               "REPLACE",      /* 0x0020 */
8869 +               "?",            /* 0x0040 */
8870 +               "?",            /* 0x0080 */
8871 +               "SYSTEM",       /* 0x0100 */
8872 +               "?",            /* 0x0200 */
8873 +               "?",            /* 0x0400 */
8874 +               "?",            /* 0x0800 */
8875 +               "KERNOTIME",    /* 0x1000 */
8876 +               "KERNOVAL",     /* 0x2000 */
8877 +               "KERNAMELS",    /* 0x4000 */
8878 +               "KERNFULLS",    /* 0x8000 */
8879 +               NULL
8880 +       };
8881 +
8882 +       if (!ktep->val[0])
8883 +               return 0;
8884 +
8885 +       qprintf("-- %s: cursor h/b/o 0x%lx/0x%lx/%lu, dupcnt %lu, dp 0x%p\n",
8886 +                (char *)ktep->val[1],
8887 +                (unsigned long)ktep->val[3],
8888 +                (unsigned long)ktep->val[4],
8889 +                (unsigned long)ktep->val[5],
8890 +                (unsigned long)ktep->val[11],
8891 +                (xfs_inode_t *)ktep->val[2]);
8892 +       qprintf("   alist 0x%p, size %lu, count %lu, firstu %lu, Llen %lu",
8893 +                (attrlist_t *)ktep->val[6],
8894 +                (unsigned long)ktep->val[7],
8895 +                (unsigned long)ktep->val[8],
8896 +                (unsigned long)ktep->val[9],
8897 +                (unsigned long)ktep->val[10]);
8898 +       printflags((__psunsigned_t)(ktep->val[12]), attr_arg_flags, ", flags");
8899 +       qprintf("\n");
8900 +
8901 +       switch ((__psint_t)ktep->val[0]) {
8902 +       case XFS_ATTR_KTRACE_L_C:
8903 +               break;
8904 +       case XFS_ATTR_KTRACE_L_CN:
8905 +               qprintf("   node: count %lu, 1st hash 0x%lx, last hash 0x%lx\n",
8906 +                        (unsigned long)ktep->val[13],
8907 +                        (unsigned long)ktep->val[14],
8908 +                        (unsigned long)ktep->val[15]);
8909 +               break;
8910 +       case XFS_ATTR_KTRACE_L_CB:
8911 +               qprintf("   btree: hash 0x%lx, blkno 0x%lx\n",
8912 +                        (unsigned long)ktep->val[13],
8913 +                        (unsigned long)ktep->val[14]);
8914 +               break;
8915 +       case XFS_ATTR_KTRACE_L_CL:
8916 +               qprintf("   leaf: count %ld, 1st hash 0x%lx, last hash 0x%lx\n",
8917 +                        (unsigned long)ktep->val[13],
8918 +                        (unsigned long)ktep->val[14],
8919 +                        (unsigned long)ktep->val[15]);
8920 +               break;
8921 +       default:
8922 +               qprintf("   unknown attr trace record format\n");
8923 +               break;
8924 +       }
8925 +       return 1;
8926 +}
8927 +#endif /* XFS_ATTR_TRACE */
8928 +
8929 +#ifdef XFS_BMAP_TRACE
8930 +/*
8931 + * Print xfs bmap extent trace buffer entry.
8932 + */
8933 +static int
8934 +xfs_bmap_trace_entry(ktrace_entry_t *ktep)
8935 +{
8936 +       xfs_dfsbno_t        b;
8937 +       xfs_dfilblks_t    c;
8938 +       xfs_inode_t          *ip;
8939 +       xfs_ino_t              ino;
8940 +       xfs_dfiloff_t      o;
8941 +       int                  flag;
8942 +       int                  opcode;
8943 +       static char          *ops[] = { "del", "ins", "pre", "post" };
8944 +       xfs_bmbt_rec_32_t       r;
8945 +       int                  whichfork;
8946 +
8947 +       opcode = ((__psint_t)ktep->val[0]) & 0xffff;
8948 +       if (opcode == 0)
8949 +               return 0;
8950 +       whichfork = ((__psint_t)ktep->val[0]) >> 16;
8951 +       ip = (xfs_inode_t *)ktep->val[3];
8952 +       ino = ((xfs_ino_t)(unsigned long)ktep->val[6] << 32) |
8953 +               ((xfs_ino_t)(unsigned long)ktep->val[7]);
8954 +       qprintf("%s %s:%s ip %p ino %s %cf\n",
8955 +               ops[opcode - 1], (char *)ktep->val[1],
8956 +               (char *)ktep->val[2], ip, xfs_fmtino(ino, ip->i_mount),
8957 +               "da"[whichfork]);
8958 +       r.l0 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[8];
8959 +       r.l1 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[9];
8960 +       r.l2 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[10];
8961 +       r.l3 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[11];
8962 +       xfs_convert_extent(&r, &o, &b, &c, &flag);
8963 +       qprintf(" idx %ld offset %lld block %s",
8964 +               (long)ktep->val[4], o,
8965 +               xfs_fmtfsblock((xfs_fsblock_t)b, ip->i_mount));
8966 +       qprintf(" count %lld flag %d\n", c, flag);
8967 +       if ((__psint_t)ktep->val[5] != 2)
8968 +               return 1;
8969 +       r.l0 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[12];
8970 +       r.l1 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[13];
8971 +       r.l2 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[14];
8972 +       r.l3 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[15];
8973 +       xfs_convert_extent(&r, &o, &b, &c, &flag);
8974 +       qprintf(" offset %lld block %s", o,
8975 +               xfs_fmtfsblock((xfs_fsblock_t)b, ip->i_mount));
8976 +       qprintf(" count %lld flag %d\n", c, flag);
8977 +       return 1;
8978 +}
8979 +
8980 +/*
8981 + * Print xfs bmap btree trace buffer entry.
8982 + */
8983 +static int
8984 +xfs_bmbt_trace_entry(
8985 +       ktrace_entry_t    *ktep)
8986 +{
8987 +       int                     line;
8988 +       xfs_bmbt_rec_32_t       r;
8989 +       xfs_bmbt_irec_t         s;
8990 +       int                     type;
8991 +       int                     whichfork;
8992 +
8993 +       type = (__psint_t)ktep->val[0] & 0xff;
8994 +       if (type == 0)
8995 +               return 0;
8996 +       whichfork = ((__psint_t)ktep->val[0] >> 8) & 0xff;
8997 +       line = ((__psint_t)ktep->val[0] >> 16) & 0xffff;
8998 +       qprintf("%s[%s@%d] ip 0x%p %cf cur 0x%p\n",
8999 +               (char *)ktep->val[1],
9000 +               (char *)ktep->val[2],
9001 +               line,
9002 +               (xfs_inode_t *)ktep->val[3],
9003 +               "da"[whichfork],
9004 +               (xfs_btree_cur_t *)ktep->val[4]);
9005 +       switch (type) {
9006 +       case XFS_BMBT_KTRACE_ARGBI:
9007 +               qprintf(" buf 0x%p i %ld\n",
9008 +                       (xfs_buf_t *)ktep->val[5],
9009 +                       (long)ktep->val[6]);
9010 +               break;
9011 +       case XFS_BMBT_KTRACE_ARGBII:
9012 +               qprintf(" buf 0x%p i0 %ld i1 %ld\n",
9013 +                       (xfs_buf_t *)ktep->val[5],
9014 +                       (long)ktep->val[6],
9015 +                       (long)ktep->val[7]);
9016 +               break;
9017 +       case XFS_BMBT_KTRACE_ARGFFFI:
9018 +               qprintf(" o 0x%x%08x b 0x%x%08x i 0x%x%08x j %ld\n",
9019 +                       (unsigned int)(long)ktep->val[5],
9020 +                       (unsigned int)(long)ktep->val[6],
9021 +                       (unsigned int)(long)ktep->val[7],
9022 +                       (unsigned int)(long)ktep->val[8],
9023 +                       (unsigned int)(long)ktep->val[9],
9024 +                       (unsigned int)(long)ktep->val[10],
9025 +                       (long)ktep->val[11]);
9026 +               break;
9027 +       case XFS_BMBT_KTRACE_ARGI:
9028 +               qprintf(" i 0x%lx\n",
9029 +                       (long)ktep->val[5]);
9030 +               break;
9031 +       case XFS_BMBT_KTRACE_ARGIFK:
9032 +               qprintf(" i 0x%lx f 0x%x%08x o 0x%x%08x\n",
9033 +                       (long)ktep->val[5],
9034 +                       (unsigned int)(long)ktep->val[6],
9035 +                       (unsigned int)(long)ktep->val[7],
9036 +                       (unsigned int)(long)ktep->val[8],
9037 +                       (unsigned int)(long)ktep->val[9]);
9038 +               break;
9039 +       case XFS_BMBT_KTRACE_ARGIFR:
9040 +               qprintf(" i 0x%lx f 0x%x%08x ",
9041 +                       (long)ktep->val[5],
9042 +                       (unsigned int)(long)ktep->val[6],
9043 +                       (unsigned int)(long)ktep->val[7]);
9044 +               s.br_startoff = (xfs_fileoff_t)
9045 +                       (((xfs_dfiloff_t)(unsigned long)ktep->val[8] << 32) |
9046 +                               (xfs_dfiloff_t)(unsigned long)ktep->val[9]);
9047 +               s.br_startblock = (xfs_fsblock_t)
9048 +                       (((xfs_dfsbno_t)(unsigned long)ktep->val[10] << 32) |
9049 +                               (xfs_dfsbno_t)(unsigned long)ktep->val[11]);
9050 +               s.br_blockcount = (xfs_filblks_t)
9051 +                       (((xfs_dfilblks_t)(unsigned long)ktep->val[12] << 32) |
9052 +                               (xfs_dfilblks_t)(unsigned long)ktep->val[13]);
9053 +               xfsidbg_xbirec(&s);
9054 +               break;
9055 +       case XFS_BMBT_KTRACE_ARGIK:
9056 +               qprintf(" i 0x%lx o 0x%x%08x\n",
9057 +                       (long)ktep->val[5],
9058 +                       (unsigned int)(long)ktep->val[6],
9059 +                       (unsigned int)(long)ktep->val[7]);
9060 +               break;
9061 +       case XFS_BMBT_KTRACE_CUR:
9062 +               qprintf(" nlevels %ld flags %ld allocated %ld ",
9063 +                       ((long)ktep->val[5] >> 24) & 0xff,
9064 +                       ((long)ktep->val[5] >> 16) & 0xff,
9065 +                       (long)ktep->val[5] & 0xffff);
9066 +               r.l0 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[6];
9067 +               r.l1 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[7];
9068 +               r.l2 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[8];
9069 +               r.l3 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[9];
9070 +               xfsidbg_xbrec((xfs_bmbt_rec_64_t *)&r);
9071 +               qprintf(" bufs 0x%p 0x%p 0x%p 0x%p ",
9072 +                       (xfs_buf_t *)ktep->val[10],
9073 +                       (xfs_buf_t *)ktep->val[11],
9074 +                       (xfs_buf_t *)ktep->val[12],
9075 +                       (xfs_buf_t *)ktep->val[13]);
9076 +               qprintf("ptrs %ld %ld %ld %ld\n",
9077 +                       (long)ktep->val[14] >> 16,
9078 +                       (long)ktep->val[14] & 0xffff,
9079 +                       (long)ktep->val[15] >> 16,
9080 +                       (long)ktep->val[15] & 0xffff);
9081 +               break;
9082 +       default:
9083 +               qprintf("unknown bmbt trace record\n");
9084 +               break;
9085 +       }
9086 +       return 1;
9087 +}
9088 +#endif
9089  
9090  /*
9091   * Print an xfs in-inode bmap btree root.
9092 @@ -2603,8 +3520,11 @@
9093         int i;
9094  
9095         kdb_printf("magic 0x%x level %d numrecs %d leftsib 0x%x rightsib 0x%x\n",
9096 -               INT_GET(bt->bb_magic, ARCH_CONVERT), INT_GET(bt->bb_level, ARCH_CONVERT), INT_GET(bt->bb_numrecs, ARCH_CONVERT),
9097 -               INT_GET(bt->bb_leftsib, ARCH_CONVERT), INT_GET(bt->bb_rightsib, ARCH_CONVERT));
9098 +               INT_GET(bt->bb_magic, ARCH_CONVERT),
9099 +               INT_GET(bt->bb_level, ARCH_CONVERT),
9100 +               INT_GET(bt->bb_numrecs, ARCH_CONVERT),
9101 +               INT_GET(bt->bb_leftsib, ARCH_CONVERT),
9102 +               INT_GET(bt->bb_rightsib, ARCH_CONVERT));
9103         if (INT_ISZERO(bt->bb_level, ARCH_CONVERT)) {
9104  
9105                 for (i = 1; i <= INT_GET(bt->bb_numrecs, ARCH_CONVERT); i++) {
9106 @@ -2612,7 +3532,8 @@
9107  
9108                         r = XFS_BTREE_REC_ADDR(bsz, xfs_inobt, bt, i, 0);
9109                         kdb_printf("rec %d startino 0x%x freecount %d, free %Lx\n",
9110 -                               i, INT_GET(r->ir_startino, ARCH_CONVERT), INT_GET(r->ir_freecount, ARCH_CONVERT),
9111 +                               i, INT_GET(r->ir_startino, ARCH_CONVERT),
9112 +                               INT_GET(r->ir_freecount, ARCH_CONVERT),
9113                                 INT_GET(r->ir_free, ARCH_CONVERT));
9114                 }
9115         } else {
9116 @@ -2626,7 +3547,8 @@
9117                         k = XFS_BTREE_KEY_ADDR(bsz, xfs_inobt, bt, i, mxr);
9118                         p = XFS_BTREE_PTR_ADDR(bsz, xfs_inobt, bt, i, mxr);
9119                         kdb_printf("key %d startino 0x%x ptr 0x%x\n",
9120 -                               i, INT_GET(k->ir_startino, ARCH_CONVERT), INT_GET(*p, ARCH_CONVERT));
9121 +                               i, INT_GET(k->ir_startino, ARCH_CONVERT),
9122 +                               INT_GET(*p, ARCH_CONVERT));
9123                 }
9124         }
9125  }
9126 @@ -2678,30 +3600,199 @@
9127         kdb_printf("\n");
9128  }
9129  
9130 +#ifdef XFS_BMAP_TRACE
9131 +/*
9132 + * Convert an external extent descriptor to internal form.
9133 + */
9134 +static void
9135 +xfs_convert_extent(xfs_bmbt_rec_32_t *rp, xfs_dfiloff_t *op, xfs_dfsbno_t *sp,
9136 +                  xfs_dfilblks_t *cp, int *fp)
9137 +{
9138 +       xfs_dfiloff_t o;
9139 +       xfs_dfsbno_t s;
9140 +       xfs_dfilblks_t c;
9141 +       int flag;
9142 +
9143 +       flag = (((xfs_dfiloff_t)rp->l0) >> 31) & 1;
9144 +       o = ((((xfs_dfiloff_t)rp->l0) & 0x7fffffff) << 23) |
9145 +           (((xfs_dfiloff_t)rp->l1) >> 9);
9146 +       s = (((xfs_dfsbno_t)(rp->l1 & 0x000001ff)) << 43) |
9147 +           (((xfs_dfsbno_t)rp->l2) << 11) |
9148 +           (((xfs_dfsbno_t)rp->l3) >> 21);
9149 +       c = (xfs_dfilblks_t)(rp->l3 & 0x001fffff);
9150 +       *op = o;
9151 +       *sp = s;
9152 +       *cp = c;
9153 +       *fp = flag;
9154 +}
9155 +#endif
9156 +
9157 +#ifdef XFS_RW_TRACE
9158 +/*
9159 + * Print itrunc entry trace.
9160 + */
9161 +static void
9162 +xfs_ctrunc_trace_entry(ktrace_entry_t  *ktep)
9163 +{
9164 +       qprintf("ip 0x%p cpu %ld\n",
9165 +               (xfs_inode_t *)(unsigned long)ktep->val[1], (long)ktep->val[2]);
9166 +}
9167 +#endif
9168 +
9169 +/*
9170 + * Print an xfs_da_state_path structure.
9171 + */
9172 +static void
9173 +xfs_dastate_path(xfs_da_state_path_t *p)
9174 +{
9175 +       int i;
9176 +
9177 +       kdb_printf("active %d\n", p->active);
9178 +       for (i = 0; i < XFS_DA_NODE_MAXDEPTH; i++) {
9179 +               kdb_printf(" blk %d bp 0x%p blkno 0x%x",
9180 +                       i, p->blk[i].bp, p->blk[i].blkno);
9181 +               kdb_printf(" index %d hashval 0x%x ",
9182 +                       p->blk[i].index, (uint_t)p->blk[i].hashval);
9183 +               switch(p->blk[i].magic) {
9184 +               case XFS_DA_NODE_MAGIC:         kdb_printf("NODE\n");   break;
9185 +               case XFS_DIR_LEAF_MAGIC:        kdb_printf("DIR\n");    break;
9186 +               case XFS_ATTR_LEAF_MAGIC:       kdb_printf("ATTR\n");   break;
9187 +               case XFS_DIR2_LEAFN_MAGIC:      kdb_printf("DIR2\n");   break;
9188 +               default:                        kdb_printf("type ?\n"); break;
9189 +               }
9190 +       }
9191 +}
9192 +
9193 +#ifdef XFS_DIR_TRACE
9194 +/*
9195 + * Print a xfs directory trace buffer entry.
9196 + */
9197 +static int
9198 +xfs_dir_trace_entry(ktrace_entry_t *ktep)
9199 +{
9200 +       xfs_mount_t *mp;
9201 +       __uint32_t hash;
9202 +       xfs_off_t cookie;
9203 +
9204 +       if (!ktep->val[0] || !ktep->val[1])
9205 +               return 0;
9206 +
9207 +       mp = (xfs_mount_t *)ktep->val[3];
9208 +       cookie = (__psunsigned_t)ktep->val[4];
9209 +       cookie <<= 32;
9210 +       cookie |= (__psunsigned_t)ktep->val[5];
9211 +       qprintf("%s -- dp=0x%p b/e/h=%ld/%ld/0x%08lx resid=0x%lx ",
9212 +                   (char *)ktep->val[1],
9213 +                   (xfs_inode_t *)ktep->val[2],
9214 +                   (long)XFS_DA_COOKIE_BNO(mp, cookie),
9215 +                   (long)XFS_DA_COOKIE_ENTRY(mp, cookie),
9216 +                   (unsigned long)XFS_DA_COOKIE_HASH(mp, cookie),
9217 +                   (long)ktep->val[6]);
9218 +
9219 +       switch ((__psint_t)ktep->val[0]) {
9220 +       case XFS_DIR_KTRACE_G_DU:
9221 +               break;
9222 +       case XFS_DIR_KTRACE_G_DUB:
9223 +               qprintf("bno=%ld", (long)ktep->val[7]);
9224 +               break;
9225 +       case XFS_DIR_KTRACE_G_DUN:
9226 +               qprintf("forw=%ld, cnt=%ld, 0x%08lx - 0x%08lx",
9227 +                             (long)ktep->val[7],
9228 +                             (long)ktep->val[8],
9229 +                             (unsigned long)ktep->val[9],
9230 +                             (unsigned long)ktep->val[10]);
9231 +               break;
9232 +       case XFS_DIR_KTRACE_G_DUL:
9233 +               qprintf("forw=%ld, cnt=%ld, 0x%08lx - 0x%08lx",
9234 +                             (long)ktep->val[7],
9235 +                             (long)ktep->val[8],
9236 +                             (unsigned long)ktep->val[9],
9237 +                             (unsigned long)ktep->val[10]);
9238 +               break;
9239 +       case XFS_DIR_KTRACE_G_DUE:
9240 +               qprintf("entry hashval 0x%08lx", (unsigned long)ktep->val[7]);
9241 +               break;
9242 +       case XFS_DIR_KTRACE_G_DUC:
9243 +               cookie = (__psunsigned_t)ktep->val[7];
9244 +               cookie <<= 32;
9245 +               cookie |= (__psunsigned_t)ktep->val[8];
9246 +               hash = XFS_DA_COOKIE_HASH(mp, cookie);
9247 +               qprintf("b/e/h=%ld/%ld/0x%08x",
9248 +                   (long)XFS_DA_COOKIE_BNO(mp, cookie),
9249 +                   (long)XFS_DA_COOKIE_ENTRY(mp, cookie),
9250 +                   hash);
9251 +               break;
9252 +       default:
9253 +               qprintf("unknown dir trace record format");
9254 +               break;
9255 +       }
9256 +       return 1;
9257 +}
9258 +#endif
9259 +
9260 +#ifdef XFS_DIR2_TRACE
9261  /*
9262 - * Print an xfs_da_state_path structure.
9263 + * Print a xfs v2 directory trace buffer entry.
9264   */
9265 -static void
9266 -xfs_dastate_path(xfs_da_state_path_t *p)
9267 +static int
9268 +xfs_dir2_trace_entry(ktrace_entry_t *ktep)
9269  {
9270 -       int i;
9271 +       char        *cp;
9272 +       int          i;
9273 +       int          len;
9274  
9275 -       kdb_printf("active %d\n", p->active);
9276 -       for (i = 0; i < XFS_DA_NODE_MAXDEPTH; i++) {
9277 -               kdb_printf(" blk %d bp 0x%p blkno 0x%x",
9278 -                       i, p->blk[i].bp, p->blk[i].blkno);
9279 -               kdb_printf(" index %d hashval 0x%x ",
9280 -                       p->blk[i].index, (uint_t)p->blk[i].hashval);
9281 -               switch(p->blk[i].magic) {
9282 -               case XFS_DA_NODE_MAGIC:         kdb_printf("NODE\n");   break;
9283 -               case XFS_DIR_LEAF_MAGIC:        kdb_printf("DIR\n");    break;
9284 -               case XFS_ATTR_LEAF_MAGIC:       kdb_printf("ATTR\n");   break;
9285 -               case XFS_DIR2_LEAFN_MAGIC:      kdb_printf("DIR2\n");   break;
9286 -               default:                        kdb_printf("type ??\n");        break;
9287 -               }
9288 +       if (!ktep->val[0])
9289 +               return 0;
9290 +       cp = (char *)&ktep->val[10];
9291 +       qprintf("%s: '", (char *)ktep->val[1]);
9292 +       len = min((__psint_t)ktep->val[9], (__psint_t)sizeof(ktep->val[10])*6);
9293 +       for (i = 0; i < len; i++)
9294 +               qprintf("%c", cp[i]);
9295 +       qprintf("'(%ld)", (long)ktep->val[9]);
9296 +       if ((__psunsigned_t)ktep->val[0] != XFS_DIR2_KTRACE_ARGS_BIBII)
9297 +               qprintf(" hashval 0x%llx inumber %lld dp 0x%p tp 0x%p check %d",
9298 +                       (__uint64_t)(unsigned long)ktep->val[2],
9299 +                       (__int64_t)(unsigned long)ktep->val[3],
9300 +                       ktep->val[4], ktep->val[5],
9301 +                       (int)(__psint_t)ktep->val[6]);
9302 +       switch ((__psunsigned_t)ktep->val[0]) {
9303 +       case XFS_DIR2_KTRACE_ARGS:
9304 +               break;
9305 +       case XFS_DIR2_KTRACE_ARGS_B:
9306 +               qprintf(" bp 0x%p", ktep->val[7]);
9307 +               break;
9308 +       case XFS_DIR2_KTRACE_ARGS_BB:
9309 +               qprintf(" lbp 0x%p dbp 0x%p", ktep->val[7], ktep->val[8]);
9310 +               break;
9311 +       case XFS_DIR2_KTRACE_ARGS_BIBII:
9312 +               qprintf(" dp 0x%p tp 0x%p srcbp 0x%p srci %d dstbp 0x%p dsti %d count %d",
9313 +                       ktep->val[2], ktep->val[3], ktep->val[4],
9314 +                       (int)(__psint_t)ktep->val[5], ktep->val[6],
9315 +                       (int)(__psint_t)ktep->val[7],
9316 +                       (int)(__psint_t)ktep->val[8]);
9317 +               break;
9318 +       case XFS_DIR2_KTRACE_ARGS_DB:
9319 +               qprintf(" db 0x%x bp 0x%p",
9320 +                       (xfs_dir2_db_t)(unsigned long)ktep->val[7],
9321 +                       ktep->val[8]);
9322 +               break;
9323 +       case XFS_DIR2_KTRACE_ARGS_I:
9324 +               qprintf(" i 0x%lx", (unsigned long)ktep->val[7]);
9325 +               break;
9326 +       case XFS_DIR2_KTRACE_ARGS_S:
9327 +               qprintf(" s 0x%x", (int)(__psint_t)ktep->val[7]);
9328 +               break;
9329 +       case XFS_DIR2_KTRACE_ARGS_SB:
9330 +               qprintf(" s 0x%x bp 0x%p", (int)(__psint_t)ktep->val[7],
9331 +                       ktep->val[8]);
9332 +               break;
9333 +       default:
9334 +               qprintf("unknown dirv2 trace record format");
9335 +               break;
9336         }
9337 +       return 1;
9338  }
9339 -
9340 +#endif
9341  
9342  /*
9343   * Print an efd log item.
9344 @@ -2847,19 +3938,19 @@
9345         static char rval[16];
9346  
9347         sprintf(rval, "%c%c%c%c%c%c%c%c%c%c%c%c%c",
9348 -               "?fc?dxb?r?l?S?m?"[(m & IFMT) >> 12],
9349 -               m & ISUID ? 'u' : '-',
9350 -               m & ISGID ? 'g' : '-',
9351 -               m & ISVTX ? 'v' : '-',
9352 -               m & IREAD ? 'r' : '-',
9353 -               m & IWRITE ? 'w' : '-',
9354 -               m & IEXEC ? 'x' : '-',
9355 -               m & (IREAD >> 3) ? 'r' : '-',
9356 -               m & (IWRITE >> 3) ? 'w' : '-',
9357 -               m & (IEXEC >> 3) ? 'x' : '-',
9358 -               m & (IREAD >> 6) ? 'r' : '-',
9359 -               m & (IWRITE >> 6) ? 'w' : '-',
9360 -               m & (IEXEC >> 6) ? 'x' : '-');
9361 +               "?fc?dxb?r?l?S?m?"[(m & S_IFMT) >> 12],
9362 +               m & S_ISUID ? 'u' : '-',
9363 +               m & S_ISGID ? 'g' : '-',
9364 +               m & S_ISVTX ? 'v' : '-',
9365 +               m & S_IRUSR ? 'r' : '-',
9366 +               m & S_IWUSR ? 'w' : '-',
9367 +               m & S_IXUSR ? 'x' : '-',
9368 +               m & S_IRGRP ? 'r' : '-',
9369 +               m & S_IWGRP ? 'w' : '-',
9370 +               m & S_IXGRP ? 'x' : '-',
9371 +               m & S_IROTH ? 'r' : '-',
9372 +               m & S_IWOTH ? 'w' : '-',
9373 +               m & S_IXOTH ? 'x' : '-');
9374         return rval;
9375  }
9376  
9377 @@ -2883,9 +3974,9 @@
9378  xfs_fmtuuid(uuid_t *uu)
9379  {
9380         static char rval[40];
9381 -       char        *o          = rval;
9382 -       char        *i          = (unsigned char*)uu;
9383 -       int         b;
9384 +       char    *o        = rval;
9385 +       char    *i        = (unsigned char*)uu;
9386 +       int      b;
9387  
9388         for (b=0;b<16;b++) {
9389             o+=sprintf(o, "%02x", *i++);
9390 @@ -2930,9 +4021,9 @@
9391                 kdb_printf("\n");
9392                 return;
9393         }
9394 -       kdb_printf("inode 0x%p ino 0x%llu logged %d flags: ",
9395 +       kdb_printf("inode 0x%p ino 0x%llu pushbuf %d logged %d flags: ",
9396                 ilip->ili_inode, (unsigned long long) ilip->ili_format.ilf_ino,
9397 -               ilip->ili_logged);
9398 +               ilip->ili_pushbuf_flag, ilip->ili_logged);
9399         printflags(ilip->ili_flags, ili_flags, NULL);
9400         kdb_printf("\n");
9401         kdb_printf("ilock recur %d iolock recur %d ext buf 0x%p\n",
9402 @@ -2942,10 +4033,9 @@
9403         kdb_printf("root bytes %d root orig 0x%x\n",
9404                 ilip->ili_root_size, ilip->ili_orig_root);
9405  #endif
9406 -       kdb_printf("size %d fields: ", ilip->ili_format.ilf_size);
9407 -       printflags(ilip->ili_format.ilf_fields, ilf_fields, "formatfield");
9408 -       kdb_printf(" last fields: ");
9409 -       printflags(ilip->ili_last_fields, ilf_fields, "lastfield");
9410 +       kdb_printf("size %d ", ilip->ili_format.ilf_size);
9411 +       printflags(ilip->ili_format.ilf_fields, ilf_fields, "fields:");
9412 +       printflags(ilip->ili_last_fields, ilf_fields, " last fields: ");
9413         kdb_printf("\n");
9414         kdb_printf(" flush lsn %s last lsn %s\n",
9415                 xfs_fmtlsn(&(ilip->ili_flush_lsn)),
9416 @@ -3001,6 +4091,129 @@
9417         }
9418  }
9419  
9420 +#ifdef XFS_RW_TRACE
9421 +/*
9422 + * Print iomap entry trace.
9423 + */
9424 +static void
9425 +xfs_iomap_enter_trace_entry(ktrace_entry_t *ktep)
9426 +{
9427 +       qprintf("ip 0x%p size 0x%x%x offset 0x%x%x count 0x%x\n",
9428 +               ktep->val[1],
9429 +               (unsigned int)(long)ktep->val[2],
9430 +               (unsigned int)(long)ktep->val[3],
9431 +               (unsigned int)(long)ktep->val[4],
9432 +               (unsigned int)(long)ktep->val[5],
9433 +               (unsigned int)(long)ktep->val[6]);
9434 +       qprintf("next offset 0x%x%x io offset 0x%x%x\n",
9435 +               (unsigned int)(long)ktep->val[7],
9436 +               (unsigned int)(long)ktep->val[8],
9437 +               (unsigned int)(long)ktep->val[9],
9438 +               (unsigned int)(long)ktep->val[10]);
9439 +       qprintf("io size 0x%x last req sz 0x%x new size 0x%x%x\n",
9440 +               (unsigned int)(long)ktep->val[11],
9441 +               (unsigned int)(long)ktep->val[12],
9442 +               (unsigned int)(long)ktep->val[13],
9443 +               (unsigned int)(long)ktep->val[14]);
9444 +}
9445 +
9446 +/*
9447 + * Print iomap map trace.
9448 + */
9449 +static void
9450 +xfs_iomap_map_trace_entry(ktrace_entry_t *ktep)
9451 +{
9452 +       qprintf("ip 0x%p size 0x%x%x offset 0x%x%x count 0x%x\n",
9453 +               ktep->val[1],
9454 +               (unsigned int)(long)ktep->val[2],
9455 +               (unsigned int)(long)ktep->val[3],
9456 +               (unsigned int)(long)ktep->val[4],
9457 +               (unsigned int)(long)ktep->val[5],
9458 +               (unsigned int)(long)ktep->val[6]);
9459 +       qprintf("bmap off 0x%x%x len 0x%x pboff 0x%x pbsize 0x%x bno 0x%x\n",
9460 +               (unsigned int)(long)ktep->val[7],
9461 +               (unsigned int)(long)ktep->val[8],
9462 +               (unsigned int)(long)ktep->val[9],
9463 +               (unsigned int)(long)ktep->val[10],
9464 +               (unsigned int)(long)ktep->val[11],
9465 +               (unsigned int)(long)ktep->val[12]);
9466 +       qprintf("imap off 0x%x count 0x%x block 0x%x\n",
9467 +               (unsigned int)(long)ktep->val[13],
9468 +               (unsigned int)(long)ktep->val[14],
9469 +               (unsigned int)(long)ktep->val[15]);
9470 +}
9471 +
9472 +/*
9473 + * Print itrunc entry trace.
9474 + */
9475 +static void
9476 +xfs_itrunc_trace_entry(ktrace_entry_t   *ktep)
9477 +{
9478 +       qprintf("ip 0x%p size 0x%x%x flag %ld new size 0x%x%x\n",
9479 +               ktep->val[1],
9480 +               (unsigned int)(long)ktep->val[2],
9481 +               (unsigned int)(long)ktep->val[3],
9482 +               (long)ktep->val[4],
9483 +               (unsigned int)(long)ktep->val[5],
9484 +               (unsigned int)(long)ktep->val[6]);
9485 +       qprintf("toss start 0x%x%x toss finish 0x%x%x cpu id %ld\n",
9486 +               (unsigned int)(long)ktep->val[7],
9487 +               (unsigned int)(long)ktep->val[8],
9488 +               (unsigned int)(long)ktep->val[9],
9489 +               (unsigned int)(long)ktep->val[10],
9490 +               (long)ktep->val[11]);
9491 +}
9492 +
9493 +/*
9494 + * Print bunmap entry trace.
9495 + */
9496 +static void
9497 +xfs_bunmap_trace_entry(ktrace_entry_t   *ktep)
9498 +{
9499 +       static char *bunmapi_flags[] = {
9500 +               "write",        /* 0x01 */
9501 +               "delay",        /* 0x02 */
9502 +               "entire",       /* 0x04 */
9503 +               "metadata",     /* 0x08 */
9504 +               "exact",        /* 0x10 */
9505 +               "attrfork",     /* 0x20 */
9506 +               "async",        /* 0x40 */
9507 +               "rsvblocks",    /* 0x80 */
9508 +               0
9509 +       };
9510 +
9511 +       qprintf("ip 0x%p size 0x%x%x bno 0x%x%x len 0x%x cpu id %ld\n",
9512 +               ktep->val[1],
9513 +               (unsigned int)(long)ktep->val[2],
9514 +               (unsigned int)(long)ktep->val[3],
9515 +               (unsigned int)(long)ktep->val[4],
9516 +               (unsigned int)(long)ktep->val[5],
9517 +               (unsigned int)(long)ktep->val[6],
9518 +               (long)ktep->val[8]);
9519 +       qprintf("ra 0x%p ", ktep->val[9]);
9520 +       printflags((__psint_t)ktep->val[7], bunmapi_flags, "flags");
9521 +       qprintf("\n");
9522 +}
9523 +
9524 +/*
9525 + * Print inval_cached_pages entry trace.
9526 + */
9527 +static void
9528 +xfs_inval_cached_trace_entry(ktrace_entry_t     *ktep)
9529 +{
9530 +       qprintf("ip 0x%p offset 0x%x%x len 0x%x%x first 0x%x%x last 0x%x%x\n",
9531 +               ktep->val[1],
9532 +               (unsigned int)(long)ktep->val[2],
9533 +               (unsigned int)(long)ktep->val[3],
9534 +               (unsigned int)(long)ktep->val[4],
9535 +               (unsigned int)(long)ktep->val[5],
9536 +               (unsigned int)(long)ktep->val[6],
9537 +               (unsigned int)(long)ktep->val[7],
9538 +               (unsigned int)(long)ktep->val[8],
9539 +               (unsigned int)(long)ktep->val[9]);
9540 +}
9541 +#endif
9542 +
9543  
9544  /*
9545   * Print disk inode.
9546 @@ -3047,14 +4260,14 @@
9547                 INT_GET(dip->di_gid, convert),
9548                 (uint)INT_GET(dip->di_projid, convert),
9549                 (uint)INT_GET(dip->di_flushiter, convert));
9550 -       kdb_printf("atime 0x%x:%x mtime 0x%x:%x ctime 0x%x:%x\n",
9551 +       kdb_printf("atime %u:%u mtime %ud:%u ctime %u:%u\n",
9552                 INT_GET(dip->di_atime.t_sec, convert),
9553                 INT_GET(dip->di_atime.t_nsec, convert),
9554                 INT_GET(dip->di_mtime.t_sec, convert),
9555                 INT_GET(dip->di_mtime.t_nsec, convert),
9556                 INT_GET(dip->di_ctime.t_sec, convert),
9557                 INT_GET(dip->di_ctime.t_nsec, convert));
9558 -       kdb_printf("size 0x%Lx ", INT_GET(dip->di_size, convert));
9559 +       kdb_printf("size %Ld ", INT_GET(dip->di_size, convert));
9560         kdb_printf("nblocks %Ld extsize 0x%x nextents 0x%x anextents 0x%x\n",
9561                 INT_GET(dip->di_nblocks, convert),
9562                 INT_GET(dip->di_extsize, convert),
9563 @@ -3071,6 +4284,129 @@
9564         kdb_printf("gen 0x%x\n", INT_GET(dip->di_gen, convert));
9565  }
9566  
9567 +#ifdef XFS_RW_TRACE
9568 +/*
9569 + * Print read/write entry trace.
9570 + */
9571 +static void
9572 +xfs_rw_enter_trace_entry(ktrace_entry_t *ktep)
9573 +{
9574 +       qprintf("ip 0x%p size 0x%x%x uio offset 0x%x%x uio count 0x%x\n",
9575 +               ktep->val[1],
9576 +               (unsigned int)(long)ktep->val[2],
9577 +               (unsigned int)(long)ktep->val[3],
9578 +               (unsigned int)(long)ktep->val[4],
9579 +               (unsigned int)(long)ktep->val[5],
9580 +               (unsigned int)(long)ktep->val[6]);
9581 +       qprintf("ioflags 0x%x next offset 0x%x%x io offset 0x%x%x\n",
9582 +               (unsigned int)(long)ktep->val[7],
9583 +               (unsigned int)(long)ktep->val[8],
9584 +               (unsigned int)(long)ktep->val[9],
9585 +               (unsigned int)(long)ktep->val[10],
9586 +               (unsigned int)(long)ktep->val[11]);
9587 +       qprintf("io size 0x%x last req sz 0x%x new size 0x%x%x\n",
9588 +               (unsigned int)(long)ktep->val[12],
9589 +               (unsigned int)(long)ktep->val[13],
9590 +               (unsigned int)(long)ktep->val[14],
9591 +               (unsigned int)(long)ktep->val[15]);
9592 +}
9593 +
9594 +/*
9595 + * Print read/write trace entry.
9596 + */
9597 +static int
9598 +xfs_rw_trace_entry(ktrace_entry_t *ktep)
9599 +{
9600 +       switch ( (long)ktep->val[0] ) {
9601 +       case XFS_READ_ENTER:
9602 +               qprintf("READ ENTER:\n");
9603 +               xfs_rw_enter_trace_entry(ktep);
9604 +               break;
9605 +       case XFS_WRITE_ENTER:
9606 +               qprintf("WRITE ENTER:\n");
9607 +               xfs_rw_enter_trace_entry(ktep);
9608 +               break;
9609 +       case XFS_IOMAP_READ_ENTER:
9610 +               qprintf("IOMAP READ ENTER:\n");
9611 +               xfs_iomap_enter_trace_entry(ktep);
9612 +               break;
9613 +       case XFS_IOMAP_WRITE_ENTER:
9614 +               qprintf("IOMAP WRITE ENTER:\n");
9615 +               xfs_iomap_enter_trace_entry(ktep);
9616 +               break;
9617 +       case XFS_IOMAP_WRITE_NOSPACE:
9618 +               qprintf("IOMAP WRITE NOSPACE:\n");
9619 +               xfs_iomap_enter_trace_entry(ktep);
9620 +               break;
9621 +       case XFS_IOMAP_READ_MAP:
9622 +               qprintf("IOMAP READ MAP:\n");
9623 +               xfs_iomap_map_trace_entry(ktep);
9624 +               break;
9625 +       case XFS_IOMAP_WRITE_MAP:
9626 +               qprintf("IOMAP WRITE MAP:\n");
9627 +               xfs_iomap_map_trace_entry(ktep);
9628 +               break;
9629 +       case XFS_ITRUNC_START:
9630 +               qprintf("ITRUNC START:\n");
9631 +               xfs_itrunc_trace_entry(ktep);
9632 +               break;
9633 +       case XFS_ITRUNC_FINISH1:
9634 +               qprintf("ITRUNC FINISH1:\n");
9635 +               xfs_itrunc_trace_entry(ktep);
9636 +               break;
9637 +       case XFS_ITRUNC_FINISH2:
9638 +               qprintf("ITRUNC FINISH2:\n");
9639 +               xfs_itrunc_trace_entry(ktep);
9640 +               break;
9641 +       case XFS_CTRUNC1:
9642 +               qprintf("CTRUNC1:\n");
9643 +               xfs_ctrunc_trace_entry(ktep);
9644 +               break;
9645 +       case XFS_CTRUNC2:
9646 +               qprintf("CTRUNC2:\n");
9647 +               xfs_ctrunc_trace_entry(ktep);
9648 +               break;
9649 +       case XFS_CTRUNC3:
9650 +               qprintf("CTRUNC3:\n");
9651 +               xfs_ctrunc_trace_entry(ktep);
9652 +               break;
9653 +       case XFS_CTRUNC4:
9654 +               qprintf("CTRUNC4:\n");
9655 +               xfs_ctrunc_trace_entry(ktep);
9656 +               break;
9657 +       case XFS_CTRUNC5:
9658 +               qprintf("CTRUNC5:\n");
9659 +               xfs_ctrunc_trace_entry(ktep);
9660 +               break;
9661 +       case XFS_CTRUNC6:
9662 +               qprintf("CTRUNC6:\n");
9663 +               xfs_ctrunc_trace_entry(ktep);
9664 +               break;
9665 +       case XFS_BUNMAPI:
9666 +               qprintf("BUNMAPI:\n");
9667 +               xfs_bunmap_trace_entry(ktep);
9668 +               break;
9669 +       case XFS_INVAL_CACHED:
9670 +               qprintf("INVAL CACHED:\n");
9671 +               xfs_inval_cached_trace_entry(ktep);
9672 +               break;
9673 +       case XFS_DIORD_ENTER:
9674 +               qprintf("DIORD ENTER:\n");
9675 +               xfs_rw_enter_trace_entry(ktep);
9676 +               break;
9677 +       case XFS_DIOWR_ENTER:
9678 +               qprintf("DIOWR ENTER:\n");
9679 +               xfs_rw_enter_trace_entry(ktep);
9680 +               break;
9681 +
9682 +       default:
9683 +               return 0;
9684 +       }
9685 +
9686 +       return 1;
9687 +}
9688 +#endif
9689 +
9690  /*
9691   * Print xfs extent list for a fork.
9692   */
9693 @@ -3194,6 +4530,109 @@
9694         }
9695  }
9696  
9697 +#ifdef XFS_ALLOC_TRACE
9698 +/*
9699 + * Print out the last "count" entries in the allocation trace buffer.
9700 + */
9701 +static void
9702 +xfsidbg_xalatrace(int count)
9703 +{
9704 +       ktrace_entry_t  *ktep;
9705 +       ktrace_snap_t   kts;
9706 +       int          nentries;
9707 +       int          skip_entries;
9708 +
9709 +       if (xfs_alloc_trace_buf == NULL) {
9710 +               qprintf("The xfs alloc trace buffer is not initialized\n");
9711 +               return;
9712 +       }
9713 +       nentries = ktrace_nentries(xfs_alloc_trace_buf);
9714 +       if (count == -1) {
9715 +               count = nentries;
9716 +       }
9717 +       if ((count <= 0) || (count > nentries)) {
9718 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
9719 +               return;
9720 +       }
9721 +
9722 +       ktep = ktrace_first(xfs_alloc_trace_buf, &kts);
9723 +       if (count != nentries) {
9724 +               /*
9725 +                * Skip the total minus the number to look at minus one
9726 +                * for the entry returned by ktrace_first().
9727 +                */
9728 +               skip_entries = nentries - count - 1;
9729 +               ktep = ktrace_skip(xfs_alloc_trace_buf, skip_entries, &kts);
9730 +               if (ktep == NULL) {
9731 +                       qprintf("Skipped them all\n");
9732 +                       return;
9733 +               }
9734 +       }
9735 +       while (ktep != NULL) {
9736 +               if (xfs_alloc_trace_entry(ktep))
9737 +                       qprintf("\n");
9738 +               ktep = ktrace_next(xfs_alloc_trace_buf, &kts);
9739 +       }
9740 +}
9741 +
9742 +/*
9743 + * Print out all the entries in the alloc trace buf corresponding
9744 + * to the given block number.
9745 + */
9746 +static void
9747 +xfsidbg_xalbtrace(xfs_agblock_t bno)
9748 +{
9749 +       ktrace_entry_t  *ktep;
9750 +       ktrace_snap_t   kts;
9751 +
9752 +       if (xfs_alloc_trace_buf == NULL) {
9753 +               qprintf("The xfs alloc trace buffer is not initialized\n");
9754 +               return;
9755 +       }
9756 +
9757 +       ktep = ktrace_first(xfs_alloc_trace_buf, &kts);
9758 +       while (ktep != NULL) {
9759 +               switch ((__psint_t)ktep->val[0]) {
9760 +               case XFS_ALLOC_KTRACE_ALLOC:
9761 +               case XFS_ALLOC_KTRACE_FREE:
9762 +                       if (bno >= (xfs_agblock_t)((__psint_t)ktep->val[5]) &&
9763 +                           bno < (xfs_agblock_t)((__psint_t)ktep->val[5]) +
9764 +                                 (xfs_extlen_t)((__psint_t)ktep->val[13])) {
9765 +                               (void)xfs_alloc_trace_entry(ktep);
9766 +                               qprintf("\n");
9767 +                       }
9768 +                       break;
9769 +               }
9770 +               ktep = ktrace_next(xfs_alloc_trace_buf, &kts);
9771 +       }
9772 +}
9773 +
9774 +/*
9775 + * Print out all the entries in the alloc trace buf corresponding
9776 + * to the given allocation group.
9777 + */
9778 +static void
9779 +xfsidbg_xalgtrace(xfs_agnumber_t agno)
9780 +{
9781 +       ktrace_entry_t  *ktep;
9782 +       ktrace_snap_t   kts;
9783 +
9784 +       if (xfs_alloc_trace_buf == NULL) {
9785 +               qprintf("The xfs alloc trace buffer is not initialized\n");
9786 +               return;
9787 +       }
9788 +
9789 +       ktep = ktrace_first(xfs_alloc_trace_buf, &kts);
9790 +       while (ktep != NULL) {
9791 +               if (  (__psint_t)ktep->val[0] &&
9792 +                     ((xfs_agnumber_t)((__psint_t)ktep->val[4])) == agno ) {
9793 +                       (void)xfs_alloc_trace_entry(ktep);
9794 +                       qprintf("\n");
9795 +               }
9796 +               ktep = ktrace_next(xfs_alloc_trace_buf, &kts);
9797 +       }
9798 +}
9799 +#endif
9800  
9801  /*
9802   * Print an allocation argument structure for XFS.
9803 @@ -3215,7 +4654,7 @@
9804                 args->wasfromfl, args->isfl, args->userdata);
9805  }
9806  
9807 -#ifdef DEBUG
9808 +#ifdef XFS_ALLOC_TRACE
9809  /*
9810   * Print out all the entries in the alloc trace buf corresponding
9811   * to the given mount point.
9812 @@ -3225,7 +4664,6 @@
9813  {
9814         ktrace_entry_t  *ktep;
9815         ktrace_snap_t   kts;
9816 -       extern ktrace_t *xfs_alloc_trace_buf;
9817  
9818         if (xfs_alloc_trace_buf == NULL) {
9819                 kdb_printf("The xfs alloc trace buffer is not initialized\n");
9820 @@ -3234,14 +4672,53 @@
9821  
9822         ktep = ktrace_first(xfs_alloc_trace_buf, &kts);
9823         while (ktep != NULL) {
9824 -               if ((__psint_t)ktep->val[0] && (xfs_mount_t *)ktep->val[3] == mp) {
9825 +               if ((__psint_t)ktep->val[0] &&
9826 +                   (xfs_mount_t *)ktep->val[3] == mp) {
9827                         (void)xfs_alloc_trace_entry(ktep);
9828                         kdb_printf("\n");
9829                 }
9830                 ktep = ktrace_next(xfs_alloc_trace_buf, &kts);
9831         }
9832  }
9833 -#endif /* DEBUG */
9834 +
9835 +/*
9836 + * Print out all the entries in the alloc trace buf corresponding
9837 + * to the given entry type.
9838 + */
9839 +static void
9840 +xfsidbg_xalttrace(int tag)
9841 +{
9842 +       ktrace_entry_t  *ktep;
9843 +       ktrace_snap_t   kts;
9844 +
9845 +       if (xfs_alloc_trace_buf == NULL) {
9846 +               qprintf("The xfs alloc trace buffer is not initialized\n");
9847 +               return;
9848 +       }
9849 +
9850 +       ktep = ktrace_first(xfs_alloc_trace_buf, &kts);
9851 +       while (ktep != NULL) {
9852 +               if ((__psint_t)ktep->val[0] &&
9853 +                   ((long)ktep->val[0] & 0xffffL) == (long)tag) {
9854 +                       (void)xfs_alloc_trace_entry(ktep);
9855 +                       qprintf("\n");
9856 +               }
9857 +               ktep = ktrace_next(xfs_alloc_trace_buf, &kts);
9858 +       }
9859 +}
9860 +#endif
9861 +
9862 +/*
9863 + * Set xtra argument, used by xchksum.
9864 + */
9865 +static void
9866 +xfsidbg_xarg(int xarg)
9867 +{
9868 +       if (xarg == -1)
9869 +               qprintf("xargument: %d\n", xargument);
9870 +       else
9871 +               xargument = xarg;
9872 +}       /* xfsidbg_xarg */
9873  
9874  /*
9875   * Print an attr_list() context structure.
9876 @@ -3368,41 +4845,232 @@
9877         }
9878  }
9879  
9880 -
9881 +#ifdef XFS_ATTR_TRACE
9882 +/*
9883 + * Print out the last "count" entries in the attribute trace buffer.
9884 + */
9885 +static void
9886 +xfsidbg_xattrtrace(int count)
9887 +{
9888 +       ktrace_entry_t  *ktep;
9889 +       ktrace_snap_t   kts;
9890 +       int          nentries;
9891 +       int          skip_entries;
9892 +
9893 +       if (xfs_attr_trace_buf == NULL) {
9894 +               qprintf("The xfs attribute trace buffer is not initialized\n");
9895 +               return;
9896 +       }
9897 +       nentries = ktrace_nentries(xfs_attr_trace_buf);
9898 +       if (count == -1) {
9899 +               count = nentries;
9900 +       }
9901 +       if ((count <= 0) || (count > nentries)) {
9902 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
9903 +               return;
9904 +       }
9905 +
9906 +       ktep = ktrace_first(xfs_attr_trace_buf, &kts);
9907 +       if (count != nentries) {
9908 +               /*
9909 +                * Skip the total minus the number to look at minus one
9910 +                * for the entry returned by ktrace_first().
9911 +                */
9912 +               skip_entries = nentries - count - 1;
9913 +               ktep = ktrace_skip(xfs_attr_trace_buf, skip_entries, &kts);
9914 +               if (ktep == NULL) {
9915 +                       qprintf("Skipped them all\n");
9916 +                       return;
9917 +               }
9918 +       }
9919 +       while (ktep != NULL) {
9920 +               xfs_attr_trace_entry(ktep);
9921 +               ktep = ktrace_next(xfs_attr_trace_buf, &kts);
9922 +       }
9923 +}
9924 +#endif
9925 +
9926 +/*
9927 + * Print xfs bmap internal record
9928 + */
9929 +static void
9930 +xfsidbg_xbirec(xfs_bmbt_irec_t *r)
9931 +{
9932 +       kdb_printf(
9933 +       "startoff %Ld startblock %Lx blockcount %Ld state %Ld\n",
9934 +               (__uint64_t)r->br_startoff,
9935 +               (__uint64_t)r->br_startblock,
9936 +               (__uint64_t)r->br_blockcount,
9937 +               (__uint64_t)r->br_state);
9938 +}
9939 +
9940 +#ifdef XFS_BLI_TRACE
9941 +/*
9942 + * Print out the buf log item trace for the given buf log item.
9943 + */
9944 +static void
9945 +xfsidbg_xblitrace(xfs_buf_log_item_t *bip)
9946 +{
9947 +       ktrace_entry_t  *ktep;
9948 +       ktrace_snap_t   kts;
9949 +       uint64_t        flags;
9950 +       static char *xbli_flags[] = {
9951 +               "hold",         /* 0x01 */
9952 +               "dirty",        /* 0x02 */
9953 +               "stale",        /* 0x04 */
9954 +               "logged",       /* 0x08 */
9955 +               0
9956 +               };
9957 +       static char *xli_flags[] = {
9958 +               "in ail",       /* 0x1 */
9959 +               0
9960 +               };
9961 +
9962 +       if (bip->bli_trace == NULL) {
9963 +               qprintf("The bli trace buffer is not initialized\n");
9964 +               return;
9965 +       }
9966 +
9967 +       ktep = ktrace_first(bip->bli_trace, &kts);
9968 +       while (ktep != NULL) {
9969 +               qprintf("%s bp 0x%p flags ",
9970 +                       (char *)ktep->val[0], ktep->val[1]);
9971 +               printflags((__psint_t)(ktep->val[2]), xbli_flags, "xbli");
9972 +               qprintf("\n");
9973 +               qprintf("recur %ld refcount %ld blkno 0x%lx bcount 0x%lx\n",
9974 +                       (long)ktep->val[3], (long)ktep->val[4],
9975 +                       (unsigned long)ktep->val[5],
9976 +                       (unsigned long)ktep->val[6]);
9977 +               flags = (((uint64_t)(unsigned long)ktep->val[7] << 32) &
9978 +                                       0xFFFFFFFF00000000ULL) |
9979 +                       (((uint64_t)(unsigned long)ktep->val[8]) &
9980 +                                       0x00000000FFFFFFFFULL);
9981 +               qprintf("bp flags ");
9982 +               printflags(flags, pb_flag_vals, 0);
9983 +               qprintf("\n");
9984 +               qprintf("fspriv 0x%p fspriv2 0x%p pincount %ld iodone 0x%p\n",
9985 +                       ktep->val[9], ktep->val[10],
9986 +                       (long)ktep->val[11], ktep->val[12]);
9987 +               qprintf("lockval %ld lid 0x%lx log item flags ",
9988 +                       (long)ktep->val[13], (unsigned long)ktep->val[14]);
9989 +               printflags((__psint_t)(ktep->val[15]), xli_flags, "xli");
9990 +               qprintf("\n");
9991 +
9992 +               ktep = ktrace_next(bip->bli_trace, &kts);
9993 +       }
9994 +}
9995 +#endif
9996 +
9997 +/*
9998 + * Print a bmap alloc argument structure for XFS.
9999 + */
10000 +static void
10001 +xfsidbg_xbmalla(xfs_bmalloca_t *a)
10002 +{
10003 +       kdb_printf("tp 0x%p ip 0x%p eof %d prevp 0x%p\n",
10004 +               a->tp, a->ip, a->eof, a->prevp);
10005 +       kdb_printf("gotp 0x%p firstblock %s alen %d total %d\n",
10006 +               a->gotp, xfs_fmtfsblock(a->firstblock, a->ip->i_mount),
10007 +               a->alen, a->total);
10008 +       kdb_printf("off %s wasdel %d userdata %d minlen %d\n",
10009 +               xfs_fmtfsblock(a->off, a->ip->i_mount), a->wasdel,
10010 +               a->userdata, a->minlen);
10011 +       kdb_printf("minleft %d low %d rval %s aeof %d\n",
10012 +               a->minleft, a->low, xfs_fmtfsblock(a->rval, a->ip->i_mount),
10013 +               a->aeof);
10014 +}
10015 +
10016 +#ifdef XFS_BMAP_TRACE
10017 +/*
10018 + * Print out the last "count" entries in the bmap btree trace buffer.
10019 + * The "a" is for "all" inodes.
10020 + */
10021 +static void
10022 +xfsidbg_xbmatrace(int count)
10023 +{
10024 +       ktrace_entry_t  *ktep;
10025 +       ktrace_snap_t   kts;
10026 +       int          nentries;
10027 +       int          skip_entries;
10028 +
10029 +       if (xfs_bmbt_trace_buf == NULL) {
10030 +               qprintf("The xfs bmap btree trace buffer is not initialized\n");                return;
10031 +       }
10032 +       nentries = ktrace_nentries(xfs_bmbt_trace_buf);
10033 +       if (count == -1) {
10034 +               count = nentries;
10035 +       }
10036 +       if ((count <= 0) || (count > nentries)) {
10037 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
10038 +               return;
10039 +       }
10040 +
10041 +       ktep = ktrace_first(xfs_bmbt_trace_buf, &kts);
10042 +       if (count != nentries) {
10043 +               /*
10044 +                * Skip the total minus the number to look at minus one
10045 +                * for the entry returned by ktrace_first().
10046 +                */
10047 +               skip_entries = nentries - count - 1;
10048 +               ktep = ktrace_skip(xfs_bmbt_trace_buf, skip_entries, &kts);
10049 +               if (ktep == NULL) {
10050 +                       qprintf("Skipped them all\n");
10051 +                       return;
10052 +               }
10053 +       }
10054 +       while (ktep != NULL) {
10055 +               if (xfs_bmbt_trace_entry(ktep))
10056 +                       qprintf("\n");
10057 +               ktep = ktrace_next(xfs_bmbt_trace_buf, &kts);
10058 +       }
10059 +}
10060 +
10061  /*
10062 - * Print xfs bmap internal record
10063 + * Print out the bmap btree trace buffer attached to the given inode.
10064   */
10065  static void
10066 -xfsidbg_xbirec(xfs_bmbt_irec_t *r)
10067 +xfsidbg_xbmitrace(xfs_inode_t *ip)
10068  {
10069 -       kdb_printf(
10070 -       "startoff %Ld startblock %Lx blockcount %Ld state %Ld\n",
10071 -               (__uint64_t)r->br_startoff,
10072 -               (__uint64_t)r->br_startblock,
10073 -               (__uint64_t)r->br_blockcount,
10074 -               (__uint64_t)r->br_state);
10075 -}
10076 +       ktrace_entry_t  *ktep;
10077 +       ktrace_snap_t   kts;
10078  
10079 +       if (ip->i_btrace == NULL) {
10080 +               qprintf("The inode trace buffer is not initialized\n");
10081 +               return;
10082 +       }
10083 +
10084 +       ktep = ktrace_first(ip->i_btrace, &kts);
10085 +       while (ktep != NULL) {
10086 +               if (xfs_bmbt_trace_entry(ktep))
10087 +                       qprintf("\n");
10088 +               ktep = ktrace_next(ip->i_btrace, &kts);
10089 +       }
10090 +}
10091  
10092  /*
10093 - * Print a bmap alloc argument structure for XFS.
10094 + * Print out all the entries in the bmap btree trace buf corresponding
10095 + * to the given inode.  The "s" is for "single" inode.
10096   */
10097  static void
10098 -xfsidbg_xbmalla(xfs_bmalloca_t *a)
10099 +xfsidbg_xbmstrace(xfs_inode_t *ip)
10100  {
10101 -       kdb_printf("tp 0x%p ip 0x%p eof %d prevp 0x%p\n",
10102 -               a->tp, a->ip, a->eof, a->prevp);
10103 -       kdb_printf("gotp 0x%p firstblock %s alen %d total %d\n",
10104 -               a->gotp, xfs_fmtfsblock(a->firstblock, a->ip->i_mount),
10105 -               a->alen, a->total);
10106 -       kdb_printf("off %s wasdel %d userdata %d minlen %d\n",
10107 -               xfs_fmtfsblock(a->off, a->ip->i_mount), a->wasdel,
10108 -               a->userdata, a->minlen);
10109 -       kdb_printf("minleft %d low %d rval %s aeof %d\n",
10110 -               a->minleft, a->low, xfs_fmtfsblock(a->rval, a->ip->i_mount),
10111 -               a->aeof);
10112 -}
10113 +       ktrace_entry_t  *ktep;
10114 +       ktrace_snap_t   kts;
10115  
10116 +       if (xfs_bmbt_trace_buf == NULL) {
10117 +               qprintf("The xfs bmap btree trace buffer is not initialized\n");                return;
10118 +       }
10119 +
10120 +       ktep = ktrace_first(xfs_bmbt_trace_buf, &kts);
10121 +       while (ktep != NULL) {
10122 +               if ((xfs_inode_t *)(ktep->val[2]) == ip) {
10123 +                       if (xfs_bmbt_trace_entry(ktep))
10124 +                               qprintf("\n");
10125 +               }
10126 +               ktep = ktrace_next(xfs_bmbt_trace_buf, &kts);
10127 +       }
10128 +}
10129 +#endif
10130  
10131  /*
10132   * Print xfs bmap record
10133 @@ -3667,6 +5335,286 @@
10134         }
10135  }
10136  
10137 +#ifdef XFS_BMAP_TRACE
10138 +/*
10139 + * Print out the last "count" entries in the bmap extent trace buffer.
10140 + * The "a" is for "all" inodes.
10141 + */
10142 +static void
10143 +xfsidbg_xbxatrace(int count)
10144 +{
10145 +       ktrace_entry_t  *ktep;
10146 +       ktrace_snap_t   kts;
10147 +       int          nentries;
10148 +       int          skip_entries;
10149 +
10150 +       if (xfs_bmap_trace_buf == NULL) {
10151 +               qprintf("The xfs bmap extent trace buffer is not initialized\n");
10152 +               return;
10153 +       }
10154 +       nentries = ktrace_nentries(xfs_bmap_trace_buf);
10155 +       if (count == -1) {
10156 +               count = nentries;
10157 +       }
10158 +       if ((count <= 0) || (count > nentries)) {
10159 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
10160 +               return;
10161 +       }
10162 +
10163 +       ktep = ktrace_first(xfs_bmap_trace_buf, &kts);
10164 +       if (count != nentries) {
10165 +               /*
10166 +                * Skip the total minus the number to look at minus one
10167 +                * for the entry returned by ktrace_first().
10168 +                */
10169 +               skip_entries = nentries - count - 1;
10170 +               ktep = ktrace_skip(xfs_bmap_trace_buf, skip_entries, &kts);
10171 +               if (ktep == NULL) {
10172 +                       qprintf("Skipped them all\n");
10173 +                       return;
10174 +               }
10175 +       }
10176 +       while (ktep != NULL) {
10177 +               if (xfs_bmap_trace_entry(ktep))
10178 +                       qprintf("\n");
10179 +               ktep = ktrace_next(xfs_bmap_trace_buf, &kts);
10180 +       }
10181 +}
10182 +
10183 +/*
10184 + * Print out the bmap extent trace buffer attached to the given inode.
10185 + */
10186 +static void
10187 +xfsidbg_xbxitrace(xfs_inode_t *ip)
10188 +{
10189 +       ktrace_entry_t  *ktep;
10190 +       ktrace_snap_t   kts;
10191 +       if (ip->i_xtrace == NULL) {
10192 +               qprintf("The inode trace buffer is not initialized\n");
10193 +               return;
10194 +       }
10195 +
10196 +       ktep = ktrace_first(ip->i_xtrace, &kts);
10197 +       while (ktep != NULL) {
10198 +               if (xfs_bmap_trace_entry(ktep))
10199 +                       qprintf("\n");
10200 +               ktep = ktrace_next(ip->i_xtrace, &kts);
10201 +       }
10202 +}
10203 +
10204 +/*
10205 + * Print out all the entries in the bmap extent trace buf corresponding
10206 + * to the given inode.  The "s" is for "single" inode.
10207 + */
10208 +static void
10209 +xfsidbg_xbxstrace(xfs_inode_t *ip)
10210 +{
10211 +       ktrace_entry_t  *ktep;
10212 +       ktrace_snap_t   kts;
10213 +
10214 +       if (xfs_bmap_trace_buf == NULL) {
10215 +               qprintf("The xfs bmap extent trace buffer is not initialized\n");
10216 +               return;
10217 +       }
10218 +
10219 +       ktep = ktrace_first(xfs_bmap_trace_buf, &kts);
10220 +       while (ktep != NULL) {
10221 +               if ((xfs_inode_t *)(ktep->val[3]) == ip) {
10222 +                       if (xfs_bmap_trace_entry(ktep))
10223 +                               qprintf("\n");
10224 +               }
10225 +               ktep = ktrace_next(xfs_bmap_trace_buf, &kts);
10226 +       }
10227 +}
10228 +#endif
10229 +
10230 +#ifdef XFS_ILOCK_TRACE
10231 +/*
10232 + * Print out the ilock trace buffer attached to the given inode.
10233 + */
10234 +static void
10235 +xfsidbg_xilock_trace_entry(ktrace_entry_t *ktep)
10236 +{
10237 +       static char     *xiflags[] = {
10238 +               "IOLOCK_EXCL",
10239 +               "IOLOCK_SHAR",
10240 +               "ILOCK_EXCL",
10241 +               "ILOCK_SHAR",
10242 +               "IUNLK_NONOT",
10243 +               0
10244 +       };
10245 +
10246 +       if ((__psint_t)ktep->val[0] &&
10247 +            (__psint_t)ktep->val[7] == 0) {
10248 +                printflags((__psint_t)ktep->val[2], xiflags,"Flags ");
10249 +               if ((__psint_t)ktep->val[1] == 1)
10250 +                        qprintf("LOCK\n");
10251 +               else if ((__psint_t)ktep->val[1] == 2)
10252 +                        qprintf("LOCK SHARED\n");
10253 +               else if ((__psint_t)ktep->val[1] == 3)
10254 +                        qprintf("UNLOCK\n");
10255 +               qprintf("ip 0x%p %llx %ld\n",
10256 +                       ktep->val[0],
10257 +                       (unsigned long long)((xfs_inode_t*)ktep->val[0])->i_ino,
10258 +                       (long)ktep->val[6]);
10259 +               qprintf("raddr 0x%p\n", ktep->val[3]);
10260 +               qprintf("  Pid %ld, cpu %ld\n",
10261 +                        (long)ktep->val[5],
10262 +                        (long)ktep->val[4]);
10263 +               qprintf("-----------------------\n");
10264 +
10265 +       } else if ((__psint_t)ktep->val[7] == 1) {
10266 +               if ((__psint_t)ktep->val[1] == 1)
10267 +                       qprintf("FlushLOCK ");
10268 +               else if ((__psint_t)ktep->val[1] == 2)
10269 +                       qprintf("FlushTRYLOCK %ld ",
10270 +                               (long)ktep->val[2]);
10271 +               else if ((__psint_t)ktep->val[1] == 3)
10272 +                       qprintf("FlushUNLOCK ");
10273 +               else if ((__psint_t)ktep->val[1] == 4)
10274 +                       qprintf("FlushInode 0x%p",
10275 +                               ktep->val[2]);
10276 +               else if ((__psint_t)ktep->val[1] == 5)
10277 +                       qprintf("FlushInodeInt ");
10278 +               else     qprintf("FlushUNKNOWN ");
10279 +               qprintf("ip 0x%p ino %llx @ %ld\n",
10280 +                       ktep->val[0],
10281 +                       (unsigned long long)((xfs_inode_t*)ktep->val[0])->i_ino,
10282 +                       (long)ktep->val[6]);
10283 +               qprintf("raddr 0x%p\n", ktep->val[3]);
10284 +               qprintf("  Pid %ld, cpu %ld\n",
10285 +                       (long)ktep->val[5],
10286 +                       (long)ktep->val[4]);
10287 +               qprintf("-----------------------\n");
10288 +       }
10289 +}
10290 +
10291 +static void
10292 +xfsidbg_xilock_trace(xfs_inode_t *ip)
10293 +{
10294 +       static char *xiflags[] = {
10295 +               "IOLOCK_EXCL",
10296 +               "IOLOCK_SHAR",
10297 +               "ILOCK_EXCL",
10298 +               "ILOCK_SHAR",
10299 +               "IUNLK_NONOT",
10300 +               0
10301 +       };
10302 +
10303 +       ktrace_entry_t  *ktep;
10304 +       ktrace_snap_t   kts;
10305 +       if (ip->i_lock_trace == NULL) {
10306 +               qprintf("The inode ilock trace buffer is not initialized\n");
10307 +               return;
10308 +       }
10309 +
10310 +       ktep = ktrace_first(ip->i_lock_trace, &kts);
10311 +       while (ktep != NULL) {
10312 +                if ((__psint_t)ktep->val[0] &&
10313 +                    (__psint_t)ktep->val[7] == 0) {
10314 +                        printflags((__psint_t)ktep->val[2], xiflags,"Flags ");
10315 +                        if ((__psint_t)ktep->val[1] == 1)
10316 +                                qprintf("LOCK\n");
10317 +                        else if ((__psint_t)ktep->val[1] == 2)
10318 +                                qprintf("LOCK SHARED\n");
10319 +                        else if ((__psint_t)ktep->val[1] == 3)
10320 +                                qprintf("UNLOCK\n");
10321 +                       qprintf("ip 0x%p %lld %ld\n",
10322 +                               ktep->val[0], (unsigned long long)
10323 +                               ((xfs_inode_t*)ktep->val[0])->i_ino,
10324 +                               (long)ktep->val[6]);
10325 +                        qprintf("raddr 0x%p\n", ktep->val[3]);
10326 +                        qprintf("  Pid %ld, cpu %ld\n",
10327 +                                (long)ktep->val[5],
10328 +                                (long)ktep->val[4]);
10329 +                        qprintf("-----------------------\n");
10330 +                } else if ((__psint_t)ktep->val[7] == 1) {
10331 +                       if ((__psint_t)ktep->val[1] == 1)
10332 +                               qprintf("LOCK ");
10333 +                       else if ((__psint_t)ktep->val[1] == 2)
10334 +                               qprintf("TRYLOCK %ld ",
10335 +                                       (long)ktep->val[2]);
10336 +                       else if ((__psint_t)ktep->val[1] == 3)
10337 +                               qprintf("UNLOCK ");
10338 +                       else     qprintf("UNKNOWN ");
10339 +                       qprintf("ip 0x%p %lld %ld\n",
10340 +                               ktep->val[0], (unsigned long long)
10341 +                               ((xfs_inode_t*)ktep->val[0])->i_ino,
10342 +                               (long)ktep->val[6]);
10343 +                       qprintf("raddr 0x%p\n", ktep->val[3]);
10344 +                       qprintf("  Pid %ld, cpu %ld\n",
10345 +                               (long)ktep->val[5],
10346 +                               (long)ktep->val[4]);
10347 +                       qprintf("-----------------------\n");
10348 +                }
10349 +
10350 +                ktep = ktrace_next(ip->i_lock_trace, &kts);
10351 +       }
10352 +}
10353 +
10354 +/*
10355 + * Print out the last "count" entries in the inode lock trace buffer.
10356 + * The "a" is for "all" entries.
10357 + */
10358 +static void
10359 +xfsidbg_xailock_trace(int count)
10360 +{
10361 +       ktrace_entry_t  *ktep;
10362 +       ktrace_snap_t   kts;
10363 +       int          nentries;
10364 +       int          skip_entries;
10365 +
10366 +       if (xfs_ilock_trace_buf == NULL) {
10367 +               qprintf("The xfs inode lock trace buffer is not initialized\n");                return;
10368 +       }
10369 +       nentries = ktrace_nentries(xfs_ilock_trace_buf);
10370 +       if (count == -1) {
10371 +               count = nentries;
10372 +       }
10373 +       if ((count <= 0) || (count > nentries)) {
10374 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
10375 +               return;
10376 +       }
10377 +
10378 +       ktep = ktrace_first(xfs_ilock_trace_buf, &kts);
10379 +       if (count != nentries) {
10380 +               /*
10381 +                * Skip the total minus the number to look at minus one
10382 +                * for the entry returned by ktrace_first().
10383 +                */
10384 +               skip_entries = nentries - count - 1;
10385 +               ktep = ktrace_skip(xfs_ilock_trace_buf, skip_entries, &kts);
10386 +               if (ktep == NULL) {
10387 +                       qprintf("Skipped them all\n");
10388 +                       return;
10389 +               }
10390 +       }
10391 +       while (ktep != NULL) {
10392 +               xfsidbg_xilock_trace_entry(ktep);
10393 +               ktep = ktrace_next(xfs_ilock_trace_buf, &kts);
10394 +       }
10395 +}
10396 +#endif
10397 +
10398 +/*
10399 + * Compute & print buffer's checksum.
10400 + */
10401 +static void
10402 +xfsidbg_xchksum(uint *addr)
10403 +{
10404 +       uint i, chksum = 0;
10405 +
10406 +       if (((__psint_t)addr) == ((__psint_t)-1)) {
10407 +               qprintf("USAGE xchksum <address>\n");
10408 +               qprintf("       length is set with xarg\n");
10409 +       } else {
10410 +               for (i=0; i<xargument; i++) {
10411 +                       chksum ^= *addr;
10412 +                       addr++;
10413 +               }
10414 +               qprintf("chksum (0x%x)  length (%d)\n", chksum, xargument);
10415 +       }
10416 +}       /* xfsidbg_xchksum */
10417  
10418  /*
10419   * Print an xfs_da_args structure.
10420 @@ -3740,9 +5688,8 @@
10421                 kdb_printf(" %d:0x%p", i, dabuf->bps[i]);
10422         kdb_printf("\n");
10423  #ifdef XFS_DABUF_DEBUG
10424 -       kdb_printf(" ra 0x%x prev 0x%x next 0x%x dev %s blkno 0x%x\n",
10425 -               dabuf->ra, dabuf->prev, dabuf->next,
10426 -               XFS_BUFTARG_NAME(dabuf->dev), dabuf->blkno);
10427 +       kdb_printf(" ra 0x%x prev 0x%x next 0x%x dev 0x%x blkno 0x%x\n",
10428 +               dabuf->ra, dabuf->prev, dabuf->next, dabuf->dev, dabuf->blkno);
10429  #endif
10430  }
10431  
10432 @@ -4012,6 +5959,119 @@
10433         }
10434  }
10435  
10436 +#ifdef XFS_DIR_TRACE
10437 +/*
10438 + * Print out the last "count" entries in the directory trace buffer.
10439 + */
10440 +static void
10441 +xfsidbg_xdirtrace(int count)
10442 +{
10443 +       ktrace_entry_t  *ktep;
10444 +       ktrace_snap_t   kts;
10445 +       int          nentries;
10446 +       int          skip_entries;
10447 +
10448 +       if (xfs_dir_trace_buf == NULL) {
10449 +               qprintf("The xfs directory trace buffer is not initialized\n");
10450 +               return;
10451 +       }
10452 +       nentries = ktrace_nentries(xfs_dir_trace_buf);
10453 +       if (count == -1) {
10454 +               count = nentries;
10455 +       }
10456 +       if ((count <= 0) || (count > nentries)) {
10457 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
10458 +               return;
10459 +       }
10460 +
10461 +       ktep = ktrace_first(xfs_dir_trace_buf, &kts);
10462 +       if (count != nentries) {
10463 +               /*
10464 +                * Skip the total minus the number to look at minus one
10465 +                * for the entry returned by ktrace_first().
10466 +                */
10467 +               skip_entries = nentries - count - 1;
10468 +               ktep = ktrace_skip(xfs_dir_trace_buf, skip_entries, &kts);
10469 +               if (ktep == NULL) {
10470 +                       qprintf("Skipped them all\n");
10471 +                       return;
10472 +               }
10473 +       }
10474 +       while (ktep != NULL) {
10475 +               if (xfs_dir_trace_entry(ktep))
10476 +                       qprintf("\n");
10477 +               ktep = ktrace_next(xfs_dir_trace_buf, &kts);
10478 +       }
10479 +}
10480 +#endif
10481 +
10482 +#ifdef XFS_DIR2_TRACE
10483 +/*
10484 + * Print out the last "count" entries in the directory v2 trace buffer.
10485 + */
10486 +static void
10487 +xfsidbg_xdir2atrace(int count)
10488 +{
10489 +       ktrace_entry_t  *ktep;
10490 +       ktrace_snap_t   kts;
10491 +       int          nentries;
10492 +       int          skip_entries;
10493 +
10494 +       if (xfs_dir2_trace_buf == NULL) {
10495 +               qprintf("The xfs dirv2 trace buffer is not initialized\n");
10496 +               return;
10497 +       }
10498 +       nentries = ktrace_nentries(xfs_dir2_trace_buf);
10499 +       if (count == -1) {
10500 +               count = nentries;
10501 +       }
10502 +       if ((count <= 0) || (count > nentries)) {
10503 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
10504 +               return;
10505 +       }
10506 +
10507 +       ktep = ktrace_first(xfs_dir2_trace_buf, &kts);
10508 +       if (count != nentries) {
10509 +               /*
10510 +                * Skip the total minus the number to look at minus one
10511 +                * for the entry returned by ktrace_first().
10512 +                */
10513 +               skip_entries = nentries - count - 1;
10514 +               ktep = ktrace_skip(xfs_dir2_trace_buf, skip_entries, &kts);
10515 +               if (ktep == NULL) {
10516 +                       qprintf("Skipped them all\n");
10517 +                       return;
10518 +               }
10519 +       }
10520 +       while (ktep != NULL) {
10521 +               if (xfs_dir2_trace_entry(ktep))
10522 +                       qprintf("\n");
10523 +               ktep = ktrace_next(xfs_dir2_trace_buf, &kts);
10524 +       }
10525 +}
10526 +
10527 +/*
10528 + * Print out the directory v2 trace buffer attached to the given inode.
10529 + */
10530 +static void
10531 +xfsidbg_xdir2itrace(xfs_inode_t *ip)
10532 +{
10533 +       ktrace_entry_t  *ktep;
10534 +       ktrace_snap_t   kts;
10535 +
10536 +       if (ip->i_dir_trace == NULL) {
10537 +               qprintf("The inode trace buffer is not initialized\n");
10538 +               return;
10539 +       }
10540 +
10541 +       ktep = ktrace_first(ip->i_dir_trace, &kts);
10542 +       while (ktep != NULL) {
10543 +               if (xfs_dir2_trace_entry(ktep))
10544 +                       qprintf("\n");
10545 +               ktep = ktrace_next(ip->i_dir_trace, &kts);
10546 +       }
10547 +}
10548 +#endif
10549  
10550  /*
10551   * Print xfs extent list.
10552 @@ -4095,13 +6155,18 @@
10553         kdb_printf("log: 0x%p  callb: 0x%p  callb_tail: 0x%p  roundoff: %d\n",
10554                 iclog->ic_log, iclog->ic_callback, iclog->ic_callback_tail,
10555                 iclog->ic_roundoff);
10556 -       kdb_printf("size: %d (OFFSET: %d) refcnt: %d  bwritecnt: %d",
10557 +       kdb_printf("size: %d (OFFSET: %d) trace: 0x%p refcnt: %d bwritecnt: %d",
10558                 iclog->ic_size, iclog->ic_offset,
10559 +#ifdef XFS_LOG_TRACE
10560 +               iclog->ic_trace,
10561 +#else
10562 +               NULL,
10563 +#endif
10564                 iclog->ic_refcnt, iclog->ic_bwritecnt);
10565         if (iclog->ic_state & XLOG_STATE_ALL)
10566 -               printflags(iclog->ic_state, ic_flags, "state:");
10567 +               printflags(iclog->ic_state, ic_flags, " state:");
10568         else
10569 -               kdb_printf("state: INVALID 0x%x", iclog->ic_state);
10570 +               kdb_printf(" state: INVALID 0x%x", iclog->ic_state);
10571         kdb_printf("\n");
10572  }      /* xfsidbg_xiclog */
10573  
10574 @@ -4150,6 +6215,44 @@
10575         }
10576  }
10577  
10578 +#ifdef XFS_LOG_TRACE
10579 +/*
10580 + * Print trace from incore log.
10581 + */
10582 +static void
10583 +xfsidbg_xiclogtrace(xlog_in_core_t *iclog)
10584 +{
10585 +       ktrace_entry_t  *ktep;
10586 +       ktrace_snap_t   kts;
10587 +       ktrace_t        *kt = iclog->ic_trace;
10588 +
10589 +       qprintf("iclog->ic_trace 0x%p\n", kt);
10590 +       ktep = ktrace_first(kt, &kts);
10591 +       while (ktep != NULL) {
10592 +               switch ((__psint_t)ktep->val[0]) {
10593 +                   case XLOG_TRACE_GRAB_FLUSH: {
10594 +                           qprintf("grabbing semaphore\n");
10595 +                           break;
10596 +                   }
10597 +                   case XLOG_TRACE_REL_FLUSH: {
10598 +                           qprintf("releasing semaphore\n");
10599 +                           break;
10600 +                   }
10601 +                   case XLOG_TRACE_SLEEP_FLUSH: {
10602 +                           qprintf("sleeping on semaphore\n");
10603 +                           break;
10604 +                   }
10605 +                   case XLOG_TRACE_WAKE_FLUSH: {
10606 +                           qprintf("waking up on semaphore\n");
10607 +                           break;
10608 +                   }
10609 +                   default: {
10610 +                   }
10611 +               }
10612 +               ktep = ktrace_next(kt, &kts);
10613 +       }
10614 +}       /* xfsidbg_xiclogtrace */
10615 +#endif
10616  
10617  /*
10618   * Print all of the inodes attached to the given mount structure.
10619 @@ -4270,8 +6373,8 @@
10620                         xfsidbg_get_cstate(log->l_covered_state));
10621         kdb_printf("flags: ");
10622         printflags(log->l_flags, t_flags,"log");
10623 -       kdb_printf("  dev: %s logBBstart: %lld logsize: %d logBBsize: %d\n",
10624 -               XFS_BUFTARG_NAME(log->l_targ), (long long) log->l_logBBstart,
10625 +       kdb_printf("  logBBstart: %lld logsize: %d logBBsize: %d\n",
10626 +               (long long) log->l_logBBstart,
10627                 log->l_logsize,log->l_logBBsize);
10628         kdb_printf("curr_cycle: %d  prev_cycle: %d  curr_block: %d  prev_block: %d\n",
10629              log->l_curr_cycle, log->l_prev_cycle, log->l_curr_block,
10630 @@ -4290,11 +6393,50 @@
10631                 log->l_grant_write_cycle, log->l_grant_write_bytes);
10632         rbytes = log->l_grant_reserve_bytes + log->l_roundoff;
10633         wbytes = log->l_grant_write_bytes + log->l_roundoff;
10634 -       kdb_printf("GResBlocks: %d  GResRemain: %d  GWrBlocks: %d  GWrRemain: %d\n",
10635 +       qprintf("GResBlocks: %d GResRemain: %d  GWrBlocks: %d GWrRemain: %d\n",
10636                rbytes / BBSIZE, rbytes % BBSIZE,
10637                wbytes / BBSIZE, wbytes % BBSIZE);
10638 +#ifdef XFS_LOG_TRACE
10639 +       qprintf("trace: 0x%p  grant_trace: use xlog value\n", log->l_trace);
10640 +#endif
10641  }      /* xfsidbg_xlog */
10642  
10643 +#ifdef XFS_LOG_TRACE
10644 +/*
10645 + * Print grant trace for a log.
10646 + */
10647 +static void
10648 +xfsidbg_xlog_granttrace(xlog_t *log)
10649 +{
10650 +       ktrace_entry_t  *ktep;
10651 +       ktrace_snap_t   kts;
10652 +       ktrace_t        *kt;
10653 +
10654 +       if (((__psint_t)log) == ((__psint_t)-1)) {
10655 +               qprintf("Usage: xl_grtr <log>\n");
10656 +               return;
10657 +       }
10658 +       if ((kt = log->l_grant_trace))
10659 +               qprintf("log->l_grant_trace 0x%p\n", kt);
10660 +       else {
10661 +               qprintf("log->l_grant_trace is empty!\n");
10662 +               return;
10663 +       }
10664 +       ktep = ktrace_first(kt, &kts);
10665 +       while (ktep != NULL) {
10666 +               qprintf("%s\n", (char *)ktep->val[11]);
10667 +               qprintf("  tic:0x%p resQ:0x%p wrQ:0x%p ",
10668 +                       ktep->val[0], ktep->val[1], ktep->val[2]);
10669 +               qprintf("  GrResC:%ld GrResB:%ld GrWrC:%ld GrWrB:%ld \n",
10670 +                       (long)ktep->val[3], (long)ktep->val[4],
10671 +                       (long)ktep->val[5], (long)ktep->val[6]);
10672 +               qprintf("  HeadC:%ld HeadB:%ld TailC:%ld TailB:%ld\n",
10673 +                       (long)ktep->val[7], (long)ktep->val[8],
10674 +                       (long)ktep->val[9], (long)ktep->val[10]);
10675 +               ktep = ktrace_next(kt, &kts);
10676 +       }
10677 +}       /* xfsidbg_xlog_granttrace */
10678 +#endif
10679  
10680  /*
10681   * Print out an XFS recovery transaction
10682 @@ -4488,10 +6630,10 @@
10683                 lip->li_mountp);
10684         printflags((uint)(lip->li_flags), li_flags,"log");
10685         kdb_printf("\n");
10686 -       kdb_printf("ail forw 0x%p ail back 0x%p lsn %s desc %p ops 0x%p\n",
10687 +       kdb_printf("ail forw 0x%p ail back 0x%p lsn %s\ndesc %p ops 0x%p",
10688                 lip->li_ail.ail_forw, lip->li_ail.ail_back,
10689                 xfs_fmtlsn(&(lip->li_lsn)), lip->li_desc, lip->li_ops);
10690 -       kdb_printf("iodonefunc &0x%p\n", lip->li_cb);
10691 +       kdb_printf(" iodonefunc &0x%p\n", lip->li_cb);
10692         if (lip->li_type == XFS_LI_BUF) {
10693                 bio_lip = lip->li_bio_list;
10694                 if (bio_lip != NULL) {
10695 @@ -4547,7 +6689,7 @@
10696                 "6-1-buf",      /* 7 */
10697                 "inode",        /* 8 */
10698                 "buf",          /* 9 */
10699 -               "dquot",        /* 10 */
10700 +               "dquot",        /* 10 */
10701                 0
10702                 };
10703         static char *li_flags[] = {
10704 @@ -4609,7 +6751,7 @@
10705         static char *xmount_flags[] = {
10706                 "WSYNC",        /* 0x0001 */
10707                 "INO64",        /* 0x0002 */
10708 -               "RQCHK",        /* 0x0004 */
10709 +               "RQCHK",        /* 0x0004 */
10710                 "FSCLEAN",      /* 0x0008 */
10711                 "FSSHUTDN",     /* 0x0010 */
10712                 "NOATIME",      /* 0x0020 */
10713 @@ -4646,14 +6788,11 @@
10714                 XFS_MTOVFS(mp), mp->m_tid, &mp->m_ail_lock, &mp->m_ail);
10715         kdb_printf("ail_gen 0x%x &sb 0x%p\n",
10716                 mp->m_ail_gen, &mp->m_sb);
10717 -       kdb_printf("sb_lock 0x%p sb_bp 0x%p dev %s logdev %s rtdev %s\n",
10718 +       kdb_printf("sb_lock 0x%p sb_bp 0x%p dev 0x%x logdev 0x%x rtdev 0x%x\n",
10719                 &mp->m_sb_lock, mp->m_sb_bp,
10720 -               mp->m_ddev_targp ?
10721 -                       XFS_BUFTARG_NAME(mp->m_ddev_targp) : "none",
10722 -               mp->m_logdev_targp ?
10723 -                       XFS_BUFTARG_NAME(mp->m_logdev_targp) : "none",
10724 -               mp->m_rtdev_targp ?
10725 -                       XFS_BUFTARG_NAME(mp->m_rtdev_targp) : "none");
10726 +               mp->m_ddev_targp ? mp->m_ddev_targp->pbr_dev : 0,
10727 +               mp->m_logdev_targp ? mp->m_logdev_targp->pbr_dev : 0,
10728 +               mp->m_rtdev_targp ? mp->m_rtdev_targp->pbr_dev : 0);
10729         kdb_printf("bsize %d agfrotor %d agirotor %d ihash 0x%p ihsize %d\n",
10730                 mp->m_bsize, mp->m_agfrotor, mp->m_agirotor,
10731                 mp->m_ihash, mp->m_ihsize);
10732 @@ -4825,8 +6964,8 @@
10733                 ip->i_mnext,
10734                 ip->i_mprev,
10735                 XFS_ITOV_NULL(ip));
10736 -       kdb_printf("dev %s ino %s\n",
10737 -               XFS_BUFTARG_NAME(ip->i_mount->m_ddev_targp),
10738 +       kdb_printf("dev %x ino %s\n",
10739 +               ip->i_mount->m_dev,
10740                 xfs_fmtino(ip->i_ino, ip->i_mount));
10741         kdb_printf("blkno 0x%llx len 0x%x boffset 0x%x\n",
10742                 (long long) ip->i_blkno,
10743 @@ -4835,7 +6974,7 @@
10744         kdb_printf("transp 0x%p &itemp 0x%p\n",
10745                 ip->i_transp,
10746                 ip->i_itemp);
10747 -       kdb_printf("&lock 0x%p &iolock 0x%p",
10748 +       kdb_printf("&lock 0x%p &iolock 0x%p ",
10749                 &ip->i_lock,
10750                 &ip->i_iolock);
10751         kdb_printf("&flock 0x%p (%d) pincount 0x%x\n",
10752 @@ -4843,14 +6982,29 @@
10753                 xfs_ipincount(ip));
10754         kdb_printf("udquotp 0x%p gdquotp 0x%p\n",
10755                 ip->i_udquot, ip->i_gdquot);
10756 -       kdb_printf("new_size %Lx\n", ip->i_iocore.io_new_size);
10757 +       kdb_printf("new_size %Ld\n", ip->i_iocore.io_new_size);
10758         printflags((int)ip->i_flags, tab_flags, "flags");
10759         kdb_printf("\n");
10760 -       kdb_printf("update_core 0x%x update size 0x%x\n",
10761 +       kdb_printf("update_core %d update size %d\n",
10762                 (int)(ip->i_update_core), (int) ip->i_update_size);
10763         kdb_printf("gen 0x%x delayed blks %d",
10764                 ip->i_gen,
10765                 ip->i_delayed_blks);
10766 +#ifdef XFS_BMAP_TRACE
10767 +       qprintf(" bmap_trace 0x%p\n", ip->i_xtrace);
10768 +#endif
10769 +#ifdef XFS_BMBT_TRACE
10770 +       qprintf(" bmbt trace 0x%p\n", ip->i_btrace);
10771 +#endif  
10772 +#ifdef XFS_RW_TRACE
10773 +       qprintf(" rw trace 0x%p\n", ip->i_rwtrace);
10774 +#endif  
10775 +#ifdef XFS_ILOCK_TRACE
10776 +       qprintf(" ilock trace 0x%p\n", ip->i_lock_trace);
10777 +#endif
10778 +#ifdef XFS_DIR2_TRACE
10779 +       qprintf(" dir trace 0x%p\n", ip->i_dir_trace);
10780 +#endif  
10781         kdb_printf("\n");
10782         kdb_printf("chash 0x%p cnext 0x%p cprev 0x%p\n",
10783                 ip->i_chash,
10784 @@ -5032,6 +7186,9 @@
10785                 &dqp->q_flock,
10786                 (valusema(&dqp->q_flock) <= 0) ? "LCK" : "UNLKD",
10787                 dqp->q_pincount);
10788 +#ifdef XFS_DQUOT_TRACE
10789 +       qprintf("dqtrace 0x%p\n", dqp->q_trace);
10790 +#endif
10791         kdb_printf("disk-dquot 0x%p\n", &dqp->q_core);
10792         xfsidbg_xqm_diskdq(&dqp->q_core);
10793  
10794 @@ -5076,7 +7233,7 @@
10795         kdb_printf("\nNumber of inodes with dquots attached: %d\n", n);
10796  }
10797  
10798 -#ifdef CONFIG_XFS_QUOTA
10799 +#ifdef CONFIG_XFS_QUOTA
10800  static void
10801  xfsidbg_xqm_freelist_print(xfs_frlist_t *qlist, char *title)
10802  {
10803 @@ -5130,6 +7287,80 @@
10804  }
10805  #endif
10806  
10807 +#ifdef XFS_DQUOT_TRACE
10808 +static int
10809 +xfsidbg_xqm_pr_dqentry(ktrace_entry_t *ktep)
10810 +{
10811 +       static char *xdq_flags[] = {
10812 +               "USR",    /* 0x1 */
10813 +               "PRJ",    /* 0x2 */
10814 +               "LCKD",  /* 0x4 */
10815 +               "GRP",    /* 0x8 */
10816 +               "FLOCKD",       /* 0x08 */
10817 +               "DIRTY",        /* 0x10 */
10818 +               "WANT",  /* 0x20 */
10819 +               "INACT",        /* 0x40 */
10820 +               "MARKER",       /* 0x80 */
10821 +               0
10822 +       };
10823 +
10824 +       if ((__psint_t)ktep->val[0] == 0)
10825 +               return 0;
10826 +       switch ((__psint_t)ktep->val[0]) {
10827 +             case DQUOT_KTRACE_ENTRY:
10828 +               qprintf("[%ld] %s\t",
10829 +                       (long)ktep->val[12], /* pid */
10830 +                       (char *)ktep->val[1]);
10831 +               printflags((__psint_t)ktep->val[3], xdq_flags,"flgs ");
10832 +               qprintf("\nnrefs = %u, "
10833 +                       "flags = 0x%x, "
10834 +                       "id = %d, "
10835 +                       "res_bc = 0x%x\n"
10836 +                       "bcnt = 0x%x [0x%x | 0x%x], "
10837 +                       "icnt = 0x%x [0x%x | 0x%x]\n"
10838 +                       "@ %ld\n",
10839 +                       (unsigned int)(long)ktep->val[2], /* nrefs */
10840 +                       (unsigned int)(long)ktep->val[3], /* flags */
10841 +                       (unsigned int)(long)ktep->val[11], /* ID */
10842 +                       (unsigned int)(long)ktep->val[4], /* res_bc */
10843 +                       (unsigned int)(long)ktep->val[5], /* bcnt */
10844 +                       (unsigned int)(long)ktep->val[8], /* bsoft */
10845 +                       (unsigned int)(long)ktep->val[7], /* bhard */
10846 +                       (unsigned int)(long)ktep->val[6], /* icnt */
10847 +                       (unsigned int)(long)ktep->val[10], /* isoft */
10848 +                       (unsigned int)(long)ktep->val[9], /* ihard */
10849 +                       (long) ktep->val[13] /* time */
10850 +                       );
10851 +               break;
10852 +
10853 +             default:
10854 +               qprintf("unknown dqtrace record\n");
10855 +               break;
10856 +       }
10857 +       return (1);
10858 +}
10859 +
10860 +void
10861 +xfsidbg_xqm_dqtrace(xfs_dquot_t *dqp)
10862 +{
10863 +       ktrace_entry_t  *ktep;
10864 +       ktrace_snap_t   kts;
10865 +
10866 +       if (dqp->q_trace == NULL) {
10867 +               qprintf("The xfs dquot trace buffer is not initialized\n");
10868 +               return;
10869 +       }
10870 +       qprintf("xdqtrace dquot 0x%p\n", dqp);
10871 +
10872 +       ktep = ktrace_first(dqp->q_trace, &kts);
10873 +       while (ktep != NULL) {
10874 +               if (xfsidbg_xqm_pr_dqentry(ktep))
10875 +                       qprintf("---------------------------------\n");
10876 +               ktep = ktrace_next(dqp->q_trace, &kts);
10877 +       }
10878 +}
10879 +#endif
10880 +
10881  static void
10882  xfsidbg_xqm_mplist(xfs_mount_t *mp)
10883  {
10884 @@ -5206,7 +7437,54 @@
10885  
10886  }
10887  
10888 +#ifdef XFS_RW_TRACE
10889 +/*
10890 + * Print out the read/write trace buffer attached to the given inode.
10891 + */
10892 +static void
10893 +xfsidbg_xrwtrace(xfs_inode_t *ip)
10894 +{
10895 +       ktrace_entry_t  *ktep;
10896 +       ktrace_snap_t   kts;
10897 +       int             nentries;
10898 +       int             skip_entries;
10899 +       int             count = xargument;
10900 +
10901 +       if (ip->i_rwtrace == NULL) {
10902 +               qprintf("The inode trace buffer is not initialized\n");
10903 +               return;
10904 +       }
10905 +       qprintf("i_rwtrace = 0x%p\n", ip->i_rwtrace);
10906 +
10907 +       nentries = ktrace_nentries(ip->i_rwtrace);
10908 +       if (count == -1) {
10909 +               count = nentries;
10910 +       }
10911 +       if ((count <= 0) || (count > nentries)) {
10912 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
10913 +               return;
10914 +       }
10915  
10916 +       ktep = ktrace_first(ip->i_rwtrace, &kts);
10917 +       if (count != nentries) {
10918 +               /*
10919 +                * Skip the total minus the number to look at minus one
10920 +                * for the entry returned by ktrace_first().
10921 +                */
10922 +               skip_entries = count - nentries - 1;
10923 +               ktep = ktrace_skip(ip->i_rwtrace, skip_entries, &kts);
10924 +               if (ktep == NULL) {
10925 +                       qprintf("Skipped them all\n");
10926 +                       return;
10927 +               }
10928 +       }
10929 +       while (ktep != NULL) {
10930 +               if (xfs_rw_trace_entry(ktep))
10931 +                       qprintf("\n");
10932 +               ktep = ktrace_next(ip->i_rwtrace, &kts);
10933 +       }
10934 +}
10935 +#endif
10936  
10937  /*
10938   * Print xfs superblock.
10939 @@ -5284,7 +7562,7 @@
10940                 "dirty",        /* 0x1 */
10941                 "sb_dirty",     /* 0x2 */
10942                 "perm_log_res", /* 0x4 */
10943 -               "sync",         /* 0x08 */
10944 +               "sync",          /* 0x08 */
10945                 "dq_dirty",     /* 0x10 */
10946                 0
10947                 };
10948 @@ -5298,7 +7576,7 @@
10949  
10950         kdb_printf("tp 0x%p type ", tp);
10951         switch (tp->t_type) {
10952 -       case XFS_TRANS_SETATTR_NOT_SIZE: kdb_printf("SETATTR_NOT_SIZE");        break;
10953 +       case XFS_TRANS_SETATTR_NOT_SIZE: kdb_printf("SETATTR_NOT_SIZE");break;
10954         case XFS_TRANS_SETATTR_SIZE:    kdb_printf("SETATTR_SIZE");     break;
10955         case XFS_TRANS_INACTIVE:        kdb_printf("INACTIVE");         break;
10956         case XFS_TRANS_CREATE:          kdb_printf("CREATE");           break;
10957 @@ -5310,32 +7588,31 @@
10958         case XFS_TRANS_MKDIR:           kdb_printf("MKDIR");            break;
10959         case XFS_TRANS_RMDIR:           kdb_printf("RMDIR");            break;
10960         case XFS_TRANS_SYMLINK:         kdb_printf("SYMLINK");          break;
10961 -       case XFS_TRANS_SET_DMATTRS:     kdb_printf("SET_DMATTRS");              break;
10962 +       case XFS_TRANS_SET_DMATTRS:     kdb_printf("SET_DMATTRS");      break;
10963         case XFS_TRANS_GROWFS:          kdb_printf("GROWFS");           break;
10964 -       case XFS_TRANS_STRAT_WRITE:     kdb_printf("STRAT_WRITE");              break;
10965 +       case XFS_TRANS_STRAT_WRITE:     kdb_printf("STRAT_WRITE");      break;
10966         case XFS_TRANS_DIOSTRAT:        kdb_printf("DIOSTRAT");         break;
10967 -       case XFS_TRANS_WRITE_SYNC:      kdb_printf("WRITE_SYNC");               break;
10968 +       case XFS_TRANS_WRITE_SYNC:      kdb_printf("WRITE_SYNC");       break;
10969         case XFS_TRANS_WRITEID:         kdb_printf("WRITEID");          break;
10970         case XFS_TRANS_ADDAFORK:        kdb_printf("ADDAFORK");         break;
10971 -       case XFS_TRANS_ATTRINVAL:       kdb_printf("ATTRINVAL");                break;
10972 -       case XFS_TRANS_ATRUNCATE:       kdb_printf("ATRUNCATE");                break;
10973 +       case XFS_TRANS_ATTRINVAL:       kdb_printf("ATTRINVAL");        break;
10974 +       case XFS_TRANS_ATRUNCATE:       kdb_printf("ATRUNCATE");        break;
10975         case XFS_TRANS_ATTR_SET:        kdb_printf("ATTR_SET");         break;
10976         case XFS_TRANS_ATTR_RM:         kdb_printf("ATTR_RM");          break;
10977 -       case XFS_TRANS_ATTR_FLAG:       kdb_printf("ATTR_FLAG");                break;
10978 -       case XFS_TRANS_CLEAR_AGI_BUCKET:  kdb_printf("CLEAR_AGI_BUCKET");       break;
10979 +       case XFS_TRANS_ATTR_FLAG:       kdb_printf("ATTR_FLAG");        break;
10980 +       case XFS_TRANS_CLEAR_AGI_BUCKET:kdb_printf("CLEAR_AGI_BUCKET"); break;
10981         case XFS_TRANS_QM_SBCHANGE:     kdb_printf("QM_SBCHANGE");      break;
10982         case XFS_TRANS_QM_QUOTAOFF:     kdb_printf("QM_QUOTAOFF");      break;
10983 -       case XFS_TRANS_QM_DQALLOC:      kdb_printf("QM_DQALLOC");               break;
10984 -       case XFS_TRANS_QM_SETQLIM:      kdb_printf("QM_SETQLIM");               break;
10985 +       case XFS_TRANS_QM_DQALLOC:      kdb_printf("QM_DQALLOC");       break;
10986 +       case XFS_TRANS_QM_SETQLIM:      kdb_printf("QM_SETQLIM");       break;
10987         case XFS_TRANS_QM_DQCLUSTER:    kdb_printf("QM_DQCLUSTER");     break;
10988         case XFS_TRANS_QM_QINOCREATE:   kdb_printf("QM_QINOCREATE");    break;
10989 -       case XFS_TRANS_QM_QUOTAOFF_END: kdb_printf("QM_QOFF_END");              break;
10990 +       case XFS_TRANS_QM_QUOTAOFF_END: kdb_printf("QM_QOFF_END");      break;
10991         case XFS_TRANS_SB_UNIT:         kdb_printf("SB_UNIT");          break;
10992         case XFS_TRANS_FSYNC_TS:        kdb_printf("FSYNC_TS");         break;
10993         case XFS_TRANS_GROWFSRT_ALLOC:  kdb_printf("GROWFSRT_ALLOC");   break;
10994         case XFS_TRANS_GROWFSRT_ZERO:   kdb_printf("GROWFSRT_ZERO");    break;
10995         case XFS_TRANS_GROWFSRT_FREE:   kdb_printf("GROWFSRT_FREE");    break;
10996 -
10997         default:                        kdb_printf("0x%x", tp->t_type); break;
10998         }
10999         kdb_printf(" mount 0x%p\n", tp->t_mountp);
11000 diff -urN linux.org/fs/xfs/xfs_iget.c linux/fs/xfs/xfs_iget.c
11001 --- linux.org/fs/xfs/xfs_iget.c 2003-12-31 05:48:38.000000000 +0100
11002 +++ linux/fs/xfs/xfs_iget.c     2004-01-02 04:21:44.000000000 +0100
11003 @@ -445,18 +445,17 @@
11004  retry:
11005         XFS_STATS_INC(xs_ig_attempts);
11006  
11007 -       if ((inode = iget_locked(XFS_MTOVFS(mp)->vfs_super, ino))) {
11008 +       if ((inode = VFS_GET_INODE(XFS_MTOVFS(mp), ino, 0))) {
11009                 bhv_desc_t      *bdp;
11010                 xfs_inode_t     *ip;
11011                 int             newnode;
11012  
11013 -
11014                 vp = LINVFS_GET_VP(inode);
11015                 if (inode->i_state & I_NEW) {
11016  inode_allocate:
11017                         vn_initialize(inode);
11018                         error = xfs_iget_core(vp, mp, tp, ino,
11019 -                                                       lock_flags, ipp, bno);
11020 +                                               lock_flags, ipp, bno);
11021                         if (error) {
11022                                 make_bad_inode(inode);
11023                                 if (inode->i_state & I_NEW)
11024 @@ -506,9 +505,6 @@
11025         mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
11026                      "xfsino", (long)vp->v_number);
11027         mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", vp->v_number);
11028 -#ifdef NOTYET
11029 -       mutex_init(&ip->i_range_lock.r_spinlock, MUTEX_SPIN, "xrange");
11030 -#endif /* NOTYET */
11031         init_waitqueue_head(&ip->i_ipin_wait);
11032         atomic_set(&ip->i_pincount, 0);
11033         init_sema(&ip->i_flock, 1, "xfsfino", vp->v_number);
11034 @@ -830,9 +826,7 @@
11035         } else if (lock_flags & XFS_ILOCK_SHARED) {
11036                 mraccess(&ip->i_lock);
11037         }
11038 -#ifdef XFS_ILOCK_TRACE
11039 -       xfs_ilock_trace(ip, 1, lock_flags, (inst_t *)return_address);
11040 -#endif
11041 +       xfs_ilock_trace(ip, 1, lock_flags, (inst_t *)__return_address);
11042  }
11043  
11044  /*
11045 @@ -895,9 +889,7 @@
11046                         return 0;
11047                 }
11048         }
11049 -#ifdef XFS_ILOCK_TRACE
11050         xfs_ilock_trace(ip, 2, lock_flags, (inst_t *)__return_address);
11051 -#endif
11052         return 1;
11053  }
11054  
11055 @@ -955,9 +947,7 @@
11056                                                 (xfs_log_item_t*)(ip->i_itemp));
11057                 }
11058         }
11059 -#ifdef XFS_ILOCK_TRACE
11060         xfs_ilock_trace(ip, 3, lock_flags, (inst_t *)__return_address);
11061 -#endif
11062  }
11063  
11064  /*
11065 diff -urN linux.org/fs/xfs/xfs_inode.c linux/fs/xfs/xfs_inode.c
11066 --- linux.org/fs/xfs/xfs_inode.c        2003-12-31 05:48:38.000000000 +0100
11067 +++ linux/fs/xfs/xfs_inode.c    2004-01-02 04:21:44.000000000 +0100
11068 @@ -908,9 +908,6 @@
11069  #ifdef XFS_RW_TRACE
11070         ip->i_rwtrace = ktrace_alloc(XFS_RW_KTRACE_SIZE, KM_SLEEP);
11071  #endif
11072 -#ifdef XFS_STRAT_TRACE
11073 -       ip->i_strat_trace = ktrace_alloc(XFS_STRAT_KTRACE_SIZE, KM_SLEEP);
11074 -#endif
11075  #ifdef XFS_ILOCK_TRACE
11076         ip->i_lock_trace = ktrace_alloc(XFS_ILOCK_KTRACE_SIZE, KM_SLEEP);
11077  #endif
11078 @@ -1144,8 +1141,8 @@
11079         ip->i_d.di_onlink = 0;
11080         ip->i_d.di_nlink = nlink;
11081         ASSERT(ip->i_d.di_nlink == nlink);
11082 -       ip->i_d.di_uid = current->fsuid;
11083 -       ip->i_d.di_gid = current->fsgid;
11084 +       ip->i_d.di_uid = current_fsuid(cr);
11085 +       ip->i_d.di_gid = current_fsgid(cr);
11086         ip->i_d.di_projid = prid;
11087         memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
11088  
11089 @@ -1362,16 +1359,16 @@
11090         ktrace_enter(ip->i_rwtrace,
11091                      (void*)((long)tag),
11092                      (void*)ip,
11093 -                    (void*)((ip->i_d.di_size >> 32) & 0xffffffff),
11094 -                    (void*)(ip->i_d.di_size & 0xffffffff),
11095 +                    (void*)(unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff),
11096 +                    (void*)(unsigned long)(ip->i_d.di_size & 0xffffffff),
11097                      (void*)((long)flag),
11098 -                    (void*)((new_size >> 32) & 0xffffffff),
11099 -                    (void*)(new_size & 0xffffffff),
11100 -                    (void*)((toss_start >> 32) & 0xffffffff),
11101 -                    (void*)(toss_start & 0xffffffff),
11102 -                    (void*)((toss_finish >> 32) & 0xffffffff),
11103 -                    (void*)(toss_finish & 0xffffffff),
11104 -                    (void*)((long)private.p_cpuid),
11105 +                    (void*)(unsigned long)((new_size >> 32) & 0xffffffff),
11106 +                    (void*)(unsigned long)(new_size & 0xffffffff),
11107 +                    (void*)(unsigned long)((toss_start >> 32) & 0xffffffff),
11108 +                    (void*)(unsigned long)(toss_start & 0xffffffff),
11109 +                    (void*)(unsigned long)((toss_finish >> 32) & 0xffffffff),
11110 +                    (void*)(unsigned long)(toss_finish & 0xffffffff),
11111 +                    (void*)(unsigned long)current_cpu(),
11112                      (void*)0,
11113                      (void*)0,
11114                      (void*)0,
11115 @@ -2755,17 +2752,8 @@
11116         }
11117         if (ip->i_afp)
11118                 xfs_idestroy_fork(ip, XFS_ATTR_FORK);
11119 -#ifdef NOTYET
11120 -       if (ip->i_range_lock.r_sleep != NULL) {
11121 -               freesema(ip->i_range_lock.r_sleep);
11122 -               kmem_free(ip->i_range_lock.r_sleep, sizeof(sema_t));
11123 -       }
11124 -#endif /* NOTYET */
11125         mrfree(&ip->i_lock);
11126         mrfree(&ip->i_iolock);
11127 -#ifdef NOTYET
11128 -       mutex_destroy(&ip->i_range_lock.r_spinlock);
11129 -#endif /* NOTYET */
11130         freesema(&ip->i_flock);
11131  #ifdef XFS_BMAP_TRACE
11132         ktrace_free(ip->i_xtrace);
11133 @@ -2776,9 +2764,6 @@
11134  #ifdef XFS_RW_TRACE
11135         ktrace_free(ip->i_rwtrace);
11136  #endif
11137 -#ifdef XFS_STRAT_TRACE
11138 -       ktrace_free(ip->i_strat_trace);
11139 -#endif
11140  #ifdef XFS_ILOCK_TRACE
11141         ktrace_free(ip->i_lock_trace);
11142  #endif
11143 @@ -3707,7 +3692,7 @@
11144         if ((error = _ACL_XFS_IACCESS(ip, mode, cr)) != -1)
11145                 return error ? XFS_ERROR(error) : 0;
11146  
11147 -       if (current->fsuid != ip->i_d.di_uid) {
11148 +       if (current_fsuid(cr) != ip->i_d.di_uid) {
11149                 mode >>= 3;
11150                 if (!in_group_p((gid_t)ip->i_d.di_gid))
11151                         mode >>= 3;
11152 @@ -3814,7 +3799,7 @@
11153          * We're not supposed to change timestamps in readonly-mounted
11154          * filesystems.  Throw it away if anyone asks us.
11155          */
11156 -       if (vp->v_vfsp->vfs_flag & VFS_RDONLY)
11157 +       if (unlikely(vp->v_vfsp->vfs_flag & VFS_RDONLY))
11158                 return;
11159  
11160         /*
11161 @@ -3828,17 +3813,17 @@
11162  
11163         nanotime(&tv);
11164         if (flags & XFS_ICHGTIME_MOD) {
11165 -               inode->i_mtime = tv;
11166 +               VN_MTIMESET(vp, &tv);
11167                 ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec;
11168                 ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec;
11169         }
11170         if (flags & XFS_ICHGTIME_ACC) {
11171 -               inode->i_atime  = tv;
11172 +               VN_ATIMESET(vp, &tv);
11173                 ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
11174                 ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
11175         }
11176         if (flags & XFS_ICHGTIME_CHG) {
11177 -               inode->i_ctime  = tv;
11178 +               VN_CTIMESET(vp, &tv);
11179                 ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec;
11180                 ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec;
11181         }
11182 @@ -3859,17 +3844,18 @@
11183  }
11184  
11185  #ifdef XFS_ILOCK_TRACE
11186 +ktrace_t       *xfs_ilock_trace_buf;
11187 +
11188  void
11189  xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, inst_t *ra)
11190  {
11191         ktrace_enter(ip->i_lock_trace,
11192                      (void *)ip,
11193 -                     (void *)(__psint_t)lock,          /* 1 = LOCK, 3=UNLOCK, etc */
11194 -                    (void *)(__psint_t)lockflags,      /* XFS_ILOCK_EXCL etc */
11195 -                    (void *)ra,                        /* caller of ilock */
11196 -                    (void *)(__psint_t)cpuid(),
11197 -                    (void *)(__psint_t)current_pid(),
11198 +                    (void *)(unsigned long)lock, /* 1 = LOCK, 3=UNLOCK, etc */
11199 +                    (void *)(unsigned long)lockflags, /* XFS_ILOCK_EXCL etc */
11200 +                    (void *)ra,                /* caller of ilock */
11201 +                    (void *)(unsigned long)current_cpu(),
11202 +                    (void *)(unsigned long)current_pid(),
11203                      0,0,0,0,0,0,0,0,0,0);
11204 -
11205  }
11206 -#endif /* ILOCK_TRACE */
11207 +#endif
11208 diff -urN linux.org/fs/xfs/xfs_inode.h linux/fs/xfs/xfs_inode.h
11209 --- linux.org/fs/xfs/xfs_inode.h        2003-12-31 05:48:01.000000000 +0100
11210 +++ linux/fs/xfs/xfs_inode.h    2004-01-02 04:21:44.000000000 +0100
11211 @@ -99,6 +99,13 @@
11212  struct xfs_trans;
11213  struct xfs_dquot;
11214  
11215 +#if defined(XFS_ILOCK_TRACE)
11216 +#define XFS_ILOCK_KTRACE_SIZE  32
11217 +extern ktrace_t *xfs_ilock_trace_buf;
11218 +extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *);
11219 +#else
11220 +#define        xfs_ilock_trace(i,n,f,ra)
11221 +#endif
11222  
11223  /*
11224   * This structure is used to communicate which extents of a file
11225 @@ -264,7 +271,10 @@
11226         sema_t                  i_flock;        /* inode flush lock */
11227         atomic_t                i_pincount;     /* inode pin count */
11228         wait_queue_head_t       i_ipin_wait;    /* inode pinning wait queue */
11229 -
11230 +#ifdef HAVE_REFCACHE
11231 +       struct xfs_inode        **i_refcache;   /* ptr to entry in ref cache */
11232 +       struct xfs_inode        *i_release;     /* inode to unref */
11233 +#endif
11234         /* I/O state */
11235         xfs_iocore_t            i_iocore;       /* I/O core */
11236  
11237 @@ -280,15 +290,22 @@
11238         struct xfs_inode        *i_cnext;       /* cluster hash link forward */
11239         struct xfs_inode        *i_cprev;       /* cluster hash link backward */
11240  
11241 -#ifdef DEBUG
11242         /* Trace buffers per inode. */
11243 +#ifdef XFS_BMAP_TRACE
11244         struct ktrace           *i_xtrace;      /* inode extent list trace */
11245 +#endif
11246 +#ifdef XFS_BMBT_TRACE
11247         struct ktrace           *i_btrace;      /* inode bmap btree trace */
11248 +#endif
11249 +#ifdef XFS_RW_TRACE
11250         struct ktrace           *i_rwtrace;     /* inode read/write trace */
11251 -       struct ktrace           *i_strat_trace; /* inode strat_write trace */
11252 +#endif
11253 +#ifdef XFS_ILOCK_TRACE
11254         struct ktrace           *i_lock_trace;  /* inode lock/unlock trace */
11255 +#endif
11256 +#ifdef XFS_DIR2_TRACE
11257         struct ktrace           *i_dir_trace;   /* inode directory trace */
11258 -#endif /* DEBUG */
11259 +#endif
11260  } xfs_inode_t;
11261  
11262  #endif /* __KERNEL__ */
11263 @@ -536,12 +553,6 @@
11264  extern struct kmem_zone        *xfs_ili_zone;
11265  extern struct vnodeops xfs_vnodeops;
11266  
11267 -#ifdef XFS_ILOCK_TRACE
11268 -#define XFS_ILOCK_KTRACE_SIZE  32
11269 -void   xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags,
11270 -                       inst_t *ra);
11271 -#endif
11272 -
11273  #endif /* __KERNEL__ */
11274  
11275  #endif /* __XFS_INODE_H__ */
11276 diff -urN linux.org/fs/xfs/xfs_iocore.c linux/fs/xfs/xfs_iocore.c
11277 --- linux.org/fs/xfs/xfs_iocore.c       2003-12-31 05:48:05.000000000 +0100
11278 +++ linux/fs/xfs/xfs_iocore.c   2004-01-02 04:21:44.000000000 +0100
11279 @@ -61,6 +61,7 @@
11280  #include "xfs_rw.h"
11281  #include "xfs_quota.h"
11282  #include "xfs_trans_space.h"
11283 +#include "xfs_iomap.h"
11284  
11285  
11286  STATIC xfs_fsize_t
11287 diff -urN linux.org/fs/xfs/xfs_iomap.h linux/fs/xfs/xfs_iomap.h
11288 --- linux.org/fs/xfs/xfs_iomap.h        1970-01-01 01:00:00.000000000 +0100
11289 +++ linux/fs/xfs/xfs_iomap.h    2004-01-02 04:21:44.000000000 +0100
11290 @@ -0,0 +1,107 @@
11291 +/*
11292 + * Copyright (c) 2003 Silicon Graphics, Inc.  All Rights Reserved.
11293 + *
11294 + * This program is free software; you can redistribute it and/or modify it
11295 + * under the terms of version 2 of the GNU General Public License as
11296 + * published by the Free Software Foundation.
11297 + *
11298 + * This program is distributed in the hope that it would be useful, but
11299 + * WITHOUT ANY WARRANTY; without even the implied warranty of
11300 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11301 + *
11302 + * Further, this software is distributed without any warranty that it is
11303 + * free of the rightful claim of any third person regarding infringement
11304 + * or the like.  Any license provided herein, whether implied or
11305 + * otherwise, applies only to this software file.  Patent licenses, if
11306 + * any, provided herein do not apply to combinations of this program with
11307 + * other software, or any other product whatsoever.
11308 + *
11309 + * You should have received a copy of the GNU General Public License along
11310 + * with this program; if not, write the Free Software Foundation, Inc., 59
11311 + * Temple Place - Suite 330, Boston MA 02111-1307, USA.
11312 + *
11313 + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
11314 + * Mountain View, CA  94043, or:
11315 + *
11316 + * http://www.sgi.com
11317 + *
11318 + * For further information regarding this notice, see:
11319 + *
11320 + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
11321 + */
11322 +
11323 +
11324 +
11325 +#ifndef __XFS_IOMAP_H__
11326 +#define __XFS_IOMAP_H__
11327 +
11328 +#define IOMAP_DADDR_NULL ((xfs_daddr_t) (-1LL))
11329 +
11330 +
11331 +typedef enum {                         /* iomap_flags values */
11332 +       IOMAP_EOF =             0x01,   /* mapping contains EOF   */
11333 +       IOMAP_HOLE =            0x02,   /* mapping covers a hole  */
11334 +       IOMAP_DELAY =           0x04,   /* mapping covers delalloc region  */
11335 +       IOMAP_UNWRITTEN =       0x20,   /* mapping covers allocated */
11336 +                                       /* but uninitialized file data  */
11337 +       IOMAP_NEW =             0x40    /* just allocate */
11338 +} iomap_flags_t;
11339 +
11340 +typedef enum {
11341 +       /* base extent manipulation calls */
11342 +       BMAPI_READ = (1 << 0),          /* read extents */
11343 +       BMAPI_WRITE = (1 << 1),         /* create extents */
11344 +       BMAPI_ALLOCATE = (1 << 2),      /* delayed allocate to real extents */
11345 +       BMAPI_UNWRITTEN  = (1 << 3),    /* unwritten extents to real extents */
11346 +       /* modifiers */
11347 +       BMAPI_IGNSTATE = (1 << 4),      /* ignore unwritten state on read */
11348 +       BMAPI_DIRECT = (1 << 5),                /* direct instead of buffered write */
11349 +       BMAPI_MMAP = (1 << 6),          /* allocate for mmap write */
11350 +       BMAPI_SYNC = (1 << 7),          /* sync write */
11351 +       BMAPI_TRYLOCK = (1 << 8),       /* non-blocking request */
11352 +       BMAPI_DEVICE = (1 << 9),        /* we only want to know the device */
11353 +} bmapi_flags_t;
11354 +
11355 +
11356 +/*
11357 + * xfs_iomap_t:  File system I/O map
11358 + *
11359 + * The iomap_bn, iomap_offset and iomap_length fields are expressed in disk blocks.
11360 + * The iomap_length field specifies the size of the underlying backing store
11361 + * for the particular mapping.
11362 + *
11363 + * The iomap_bsize, iomap_size and iomap_delta fields are in bytes and indicate
11364 + * the size of the mapping, the number of bytes that are valid to access
11365 + * (read or write), and the offset into the mapping, given the offset
11366 + * supplied to the file I/O map routine.  iomap_delta is the offset of the
11367 + * desired data from the beginning of the mapping.
11368 + *
11369 + * When a request is made to read beyond the logical end of the object,
11370 + * iomap_size may be set to 0, but iomap_offset and iomap_length should be set to
11371 + * the actual amount of underlying storage that has been allocated, if any.
11372 + */
11373 +
11374 +typedef struct xfs_iomap {
11375 +       xfs_daddr_t             iomap_bn;
11376 +       xfs_buftarg_t           *iomap_target;
11377 +       loff_t                  iomap_offset;
11378 +       size_t                  iomap_delta;
11379 +       size_t                  iomap_bsize;
11380 +       iomap_flags_t           iomap_flags;
11381 +} xfs_iomap_t;
11382 +
11383 +struct xfs_iocore;
11384 +struct xfs_inode;
11385 +struct xfs_bmbt_irec;
11386 +
11387 +extern int xfs_iomap(struct xfs_iocore *, xfs_off_t, ssize_t, int,
11388 +                    struct xfs_iomap *, int *);
11389 +extern int xfs_iomap_write_direct(struct xfs_inode *, loff_t, size_t,
11390 +                                 int, struct xfs_bmbt_irec *, int *, int);
11391 +extern int xfs_iomap_write_delay(struct xfs_inode *, loff_t, size_t, int,
11392 +                                struct xfs_bmbt_irec *, int *);
11393 +extern int xfs_iomap_write_allocate(struct xfs_inode *,
11394 +                               struct xfs_bmbt_irec *, int *);
11395 +extern int xfs_iomap_write_unwritten(struct xfs_inode *, loff_t, size_t);
11396 +
11397 +#endif /* __XFS_IOMAP_H__*/
11398 diff -urN linux.org/fs/xfs/xfs_itable.c linux/fs/xfs/xfs_itable.c
11399 --- linux.org/fs/xfs/xfs_itable.c       2003-12-31 05:46:26.000000000 +0100
11400 +++ linux/fs/xfs/xfs_itable.c   2004-01-02 04:21:44.000000000 +0100
11401 @@ -65,7 +65,10 @@
11402         xfs_trans_t     *tp,            /* transaction pointer */
11403         xfs_ino_t       ino,            /* inode number to get data for */
11404         void            *buffer,        /* buffer to place output in */
11405 +       int             ubsize,         /* size of buffer */
11406 +       void            *private_data,  /* my private data */
11407         xfs_daddr_t     bno,            /* starting bno of inode cluster */
11408 +       int             *ubused,        /* bytes used by me */
11409         void            *dibuff,        /* on-disk inode buffer */
11410         int             *stat)          /* BULKSTAT_RV_... */
11411  {
11412 @@ -86,6 +89,10 @@
11413                 *stat = BULKSTAT_RV_NOTHING;
11414                 return XFS_ERROR(EINVAL);
11415         }
11416 +       if (ubsize < sizeof(*buf)) {
11417 +               *stat = BULKSTAT_RV_NOTHING;
11418 +               return XFS_ERROR(ENOMEM);
11419 +       }
11420  
11421         if (dip == NULL) {
11422                 /* We're not being passed a pointer to a dinode.  This happens
11423 @@ -218,6 +225,8 @@
11424         }
11425  
11426         *stat = BULKSTAT_RV_DIDONE;
11427 +       if (ubused)
11428 +               *ubused = sizeof(*buf);
11429         return 0;
11430  }
11431  
11432 @@ -231,6 +240,7 @@
11433         xfs_ino_t               *lastinop, /* last inode returned */
11434         int                     *ubcountp, /* size of buffer/count returned */
11435         bulkstat_one_pf         formatter, /* func that'd fill a single buf */
11436 +       void                    *private_data,/* private data for formatter */
11437         size_t                  statstruct_size, /* sizeof struct filling */
11438         xfs_caddr_t             ubuffer, /* buffer with inode stats */
11439         int                     flags,  /* defined in xfs_itable.h */
11440 @@ -265,8 +275,10 @@
11441         int                     rval;   /* return value error code */
11442         int                     tmp;    /* result value from btree calls */
11443         int                     ubcount; /* size of user's buffer */
11444 -       int                     ubleft; /* spaces left in user's buffer */
11445 +       int                     ubleft; /* bytes left in user's buffer */
11446         xfs_caddr_t             ubufp;  /* current pointer into user's buffer */
11447 +       int                     ubelem; /* spaces used in user's buffer */
11448 +       int                     ubused; /* bytes used by formatter */
11449         xfs_buf_t               *bp;    /* ptr to on-disk inode cluster buf */
11450         xfs_dinode_t            *dip;   /* ptr into bp for specific inode */
11451         xfs_inode_t             *ip;    /* ptr to in-core inode struct */
11452 @@ -284,8 +296,9 @@
11453                 *ubcountp = 0;
11454                 return 0;
11455         }
11456 -       ubcount = ubleft = *ubcountp;
11457 -       *ubcountp = 0;
11458 +       ubcount = *ubcountp; /* statstruct's */
11459 +       ubleft = ubcount * statstruct_size; /* bytes */
11460 +       *ubcountp = ubelem = 0;
11461         *done = 0;
11462         fmterror = 0;
11463         ubufp = ubuffer;
11464 @@ -317,7 +330,7 @@
11465          * inode returned; 0 means start of the allocation group.
11466          */
11467         rval = 0;
11468 -       while (ubleft > 0 && agno < mp->m_sb.sb_agcount) {
11469 +       while ((ubleft/statstruct_size) > 0 && agno < mp->m_sb.sb_agcount) {
11470                 bp = NULL;
11471                 down_read(&mp->m_peraglock);
11472                 error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
11473 @@ -402,7 +415,7 @@
11474                  * Loop through inode btree records in this ag,
11475                  * until we run out of inodes or space in the buffer.
11476                  */
11477 -               while (irbp < irbufend && icount < ubcount) {
11478 +               while (irbp < irbufend && icount < (ubleft/statstruct_size)) {
11479                         /*
11480                          * Loop as long as we're unable to read the
11481                          * inode btree.
11482 @@ -453,7 +466,8 @@
11483                  * Now format all the good inodes into the user's buffer.
11484                  */
11485                 irbufend = irbp;
11486 -               for (irbp = irbuf; irbp < irbufend && ubleft > 0; irbp++) {
11487 +               for (irbp = irbuf;
11488 +                    irbp < irbufend && (ubleft/statstruct_size) > 0; irbp++) {
11489                         /*
11490                          * Read-ahead the next chunk's worth of inodes.
11491                          */
11492 @@ -561,14 +575,19 @@
11493                                  * Get the inode and fill in a single buffer.
11494                                  * BULKSTAT_FG_QUICK uses dip to fill it in.
11495                                  * BULKSTAT_FG_IGET uses igets.
11496 -                                * See: xfs_bulkstat_one & dm_bulkstat_one.
11497 +                                * See: xfs_bulkstat_one & xfs_dm_bulkstat_one.
11498                                  * This is also used to count inodes/blks, etc
11499                                  * in xfs_qm_quotacheck.
11500                                  */
11501 -                               error = formatter(mp, tp, ino, ubufp, bno, dip,
11502 -                                       &fmterror);
11503 -                               if (fmterror == BULKSTAT_RV_NOTHING)
11504 +                               ubused = statstruct_size;
11505 +                               error = formatter(mp, tp, ino, ubufp,
11506 +                                               ubleft, private_data,
11507 +                                               bno, &ubused, dip, &fmterror);
11508 +                               if (fmterror == BULKSTAT_RV_NOTHING) {
11509 +                                       if (error == ENOMEM)
11510 +                                               ubleft = 0;
11511                                         continue;
11512 +                               }
11513                                 if (fmterror == BULKSTAT_RV_GIVEUP) {
11514                                         ubleft = 0;
11515                                         ASSERT(error);
11516 @@ -576,8 +595,9 @@
11517                                         break;
11518                                 }
11519                                 if (ubufp)
11520 -                                       ubufp += statstruct_size;
11521 -                               ubleft--;
11522 +                                       ubufp += ubused;
11523 +                               ubleft -= ubused;
11524 +                               ubelem++;
11525                                 lastino = ino;
11526                         }
11527                 }
11528 @@ -605,7 +625,7 @@
11529         if (ubuffer)
11530                 unuseracc(ubuffer, ubcount * statstruct_size, (B_READ|B_PHYS));
11531  #endif
11532 -       *ubcountp = ubcount - ubleft;
11533 +       *ubcountp = ubelem;
11534         if (agno >= mp->m_sb.sb_agcount) {
11535                 /*
11536                  * If we ran out of filesystem, mark lastino as off
11537 @@ -647,7 +667,8 @@
11538          */
11539  
11540         ino = (xfs_ino_t)*lastinop;
11541 -       error = xfs_bulkstat_one(mp, NULL, ino, &bstat, 0, 0, &res);
11542 +       error = xfs_bulkstat_one(mp, NULL, ino, &bstat, sizeof(bstat),
11543 +                                NULL, 0, NULL, NULL, &res);
11544         if (error) {
11545                 /*
11546                  * Special case way failed, do it the "long" way
11547 @@ -656,6 +677,7 @@
11548                 (*lastinop)--;
11549                 count = 1;
11550                 if (xfs_bulkstat(mp, NULL, lastinop, &count, xfs_bulkstat_one,
11551 +                               NULL,
11552                                 sizeof(bstat), buffer, BULKSTAT_FG_IGET, done))
11553                         return error;
11554                 if (count == 0 || (xfs_ino_t)*lastinop != ino)
11555 diff -urN linux.org/fs/xfs/xfs_itable.h linux/fs/xfs/xfs_itable.h
11556 --- linux.org/fs/xfs/xfs_itable.h       2003-12-31 05:48:36.000000000 +0100
11557 +++ linux/fs/xfs/xfs_itable.h   2004-01-02 04:21:42.000000000 +0100
11558 @@ -36,15 +36,19 @@
11559   * xfs_bulkstat() is used to fill in xfs_bstat structures as well as dm_stat
11560   * structures (by the dmi library). This is a pointer to a formatter function
11561   * that will iget the inode and fill in the appropriate structure.
11562 - * see xfs_bulkstat_one() and dm_bulkstat_one() in dmi_xfs.c
11563 + * see xfs_bulkstat_one() and xfs_dm_bulkstat_one() in dmapi_xfs.c
11564   */
11565  typedef int (*bulkstat_one_pf)(struct xfs_mount        *mp,
11566                                struct xfs_trans *tp,
11567                                xfs_ino_t        ino,
11568                                void             *buffer,
11569 +                              int              ubsize,
11570 +                              void             *private_data,
11571                                xfs_daddr_t      bno,
11572 +                              int              *ubused,
11573                                void             *dip,
11574                                int              *stat);
11575 +
11576  /*
11577   * Values for stat return value.
11578   */
11579 @@ -69,6 +73,7 @@
11580         xfs_ino_t       *lastino,       /* last inode returned */
11581         int             *count,         /* size of buffer/count returned */
11582         bulkstat_one_pf formatter,      /* func that'd fill a single buf */
11583 +       void            *private_data,  /* private data for formatter */
11584         size_t          statstruct_size,/* sizeof struct that we're filling */
11585         xfs_caddr_t     ubuffer,        /* buffer with inode stats */
11586         int             flags,          /* flag to control access method */
11587 @@ -87,7 +92,10 @@
11588         xfs_trans_t             *tp,
11589         xfs_ino_t               ino,
11590         void                    *buffer,
11591 +       int                     ubsize,
11592 +       void                    *private_data,
11593         xfs_daddr_t             bno,
11594 +       int                     *ubused,
11595         void                    *dibuff,
11596         int                     *stat);
11597  
11598 diff -urN linux.org/fs/xfs/xfs_log.c linux/fs/xfs/xfs_log.c
11599 --- linux.org/fs/xfs/xfs_log.c  2003-12-31 05:48:47.000000000 +0100
11600 +++ linux/fs/xfs/xfs_log.c      2004-01-02 04:21:42.000000000 +0100
11601 @@ -159,11 +159,15 @@
11602  #endif
11603  
11604  #if defined(XFS_LOG_TRACE)
11605 +
11606  void
11607  xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string)
11608  {
11609 -       if (! log->l_grant_trace)
11610 -               log->l_grant_trace = ktrace_alloc(1024, KM_SLEEP);
11611 +       if (! log->l_grant_trace) {
11612 +               log->l_grant_trace = ktrace_alloc(1024, KM_NOSLEEP);
11613 +               if (! log->l_grant_trace)
11614 +                       return;
11615 +       }
11616  
11617         ktrace_enter(log->l_grant_trace,
11618                      (void *)tic,
11619 @@ -185,31 +189,6 @@
11620  }
11621  
11622  void
11623 -xlog_trace_tic(xlog_t *log, xlog_ticket_t *tic)
11624 -{
11625 -       if (! log->l_trace)
11626 -               log->l_trace = ktrace_alloc(256, KM_SLEEP);
11627 -
11628 -       ktrace_enter(log->l_trace,
11629 -                    (void *)tic,
11630 -                    (void *)((unsigned long)tic->t_curr_res),
11631 -                    (void *)((unsigned long)tic->t_unit_res),
11632 -                    (void *)((unsigned long)tic->t_ocnt),
11633 -                    (void *)((unsigned long)tic->t_cnt),
11634 -                    (void *)((unsigned long)tic->t_flags),
11635 -                    (void *)((unsigned long)7),
11636 -                    (void *)((unsigned long)8),
11637 -                    (void *)((unsigned long)9),
11638 -                    (void *)((unsigned long)10),
11639 -                    (void *)((unsigned long)11),
11640 -                    (void *)((unsigned long)12),
11641 -                    (void *)((unsigned long)13),
11642 -                    (void *)((unsigned long)14),
11643 -                    (void *)((unsigned long)15),
11644 -                    (void *)((unsigned long)16));
11645 -}
11646 -
11647 -void
11648  xlog_trace_iclog(xlog_in_core_t *iclog, uint state)
11649  {
11650         pid_t pid;
11651 @@ -1044,7 +1023,6 @@
11652   *
11653   * If the filesystem blocksize is too large, we may need to choose a
11654   * larger size since the directory code currently logs entire blocks.
11655 - * XXXmiken XXXcurtis
11656   */
11657  
11658  STATIC void
11659 @@ -1059,7 +1037,7 @@
11660          * When logbufs == 0, someone has disabled the log from the FSTAB
11661          * file.  This is not a documented feature.  We need to set xlog_debug
11662          * to zero (this deactivates the log) and set xlog_target to the
11663 -        * appropriate dev_t.  Only one filesystem may be affected as such
11664 +        * appropriate device.  Only one filesystem may be affected as such
11665          * since this is just a performance hack to test what we might be able
11666          * to get if the log were not present.
11667          */
11668 @@ -1078,7 +1056,7 @@
11669                         if (xfs_physmem <= btoc(128*1024*1024)) { 
11670                                 log->l_iclog_bufs = XLOG_MIN_ICLOGS; 
11671                         } else if (xfs_physmem <= btoc(400*1024*1024)) { 
11672 -                               log->l_iclog_bufs = XLOG_MED_ICLOGS;; 
11673 +                               log->l_iclog_bufs = XLOG_MED_ICLOGS; 
11674                         } else {
11675                                 /* 256K with 32K bufs */
11676                                 log->l_iclog_bufs = XLOG_MAX_ICLOGS;
11677 @@ -1087,9 +1065,9 @@
11678                         log->l_iclog_bufs = mp->m_logbufs;
11679  
11680  #if defined(DEBUG) || defined(XLOG_NOLOG)
11681 -               /* We are reactivating a filesystem after it was active */
11682 +               /* We are reactivating a filesystem after it was inactive */
11683                 if (log->l_targ == xlog_target) {
11684 -                       xlog_target = 1; /* XXX(hch): WTF? */
11685 +                       xlog_target = NULL;
11686                         xlog_debug = 1;
11687                 }
11688  #endif
11689 @@ -1578,7 +1556,7 @@
11690                 sv_destroy(&iclog->ic_forcesema);
11691                 sv_destroy(&iclog->ic_writesema);
11692                 xfs_buf_free(iclog->ic_bp);
11693 -#ifdef DEBUG
11694 +#ifdef XFS_LOG_TRACE
11695                 if (iclog->ic_trace != NULL) {
11696                         ktrace_free(iclog->ic_trace);
11697                 }
11698 @@ -1609,7 +1587,7 @@
11699                 }
11700         }
11701         xfs_buf_free(log->l_xbuf);
11702 -#ifdef DEBUG
11703 +#ifdef XFS_LOG_TRACE
11704         if (log->l_trace != NULL) {
11705                 ktrace_free(log->l_trace);
11706         }
11707 diff -urN linux.org/fs/xfs/xfs_log.h linux/fs/xfs/xfs_log.h
11708 --- linux.org/fs/xfs/xfs_log.h  2003-12-31 05:48:56.000000000 +0100
11709 +++ linux/fs/xfs/xfs_log.h      2004-01-02 04:21:42.000000000 +0100
11710 @@ -53,8 +53,8 @@
11711   * endian issues in treating two 32 bit numbers as one 64 bit number
11712   */
11713  static
11714 -#if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 95)
11715 -__attribute__((unused))        /* gcc 2.95 miscompiles this when inlined */
11716 +#if defined(__GNUC__) && (__GNUC__ == 2) && ( (__GNUC_MINOR__ == 95) || (__GNUC_MINOR__ == 96))
11717 +__attribute__((unused))        /* gcc 2.95, 2.96 miscompile this when inlined */
11718  #else
11719  __inline__
11720  #endif
11721 diff -urN linux.org/fs/xfs/xfs_log_priv.h linux/fs/xfs/xfs_log_priv.h
11722 --- linux.org/fs/xfs/xfs_log_priv.h     2003-12-31 05:46:29.000000000 +0100
11723 +++ linux/fs/xfs/xfs_log_priv.h 2004-01-02 04:21:42.000000000 +0100
11724 @@ -32,14 +32,6 @@
11725  #ifndef        __XFS_LOG_PRIV_H__
11726  #define __XFS_LOG_PRIV_H__
11727  
11728 -#if defined(XFS_ALL_TRACE)
11729 -#define        XFS_LOG_TRACE
11730 -#endif
11731 -
11732 -#if !defined(DEBUG)
11733 -#undef XFS_LOG_TRACE
11734 -#endif
11735 -
11736  struct xfs_buf;
11737  struct ktrace;
11738  struct log;
11739 @@ -109,6 +101,7 @@
11740  
11741  
11742  #ifdef __KERNEL__
11743 +
11744  /*
11745   * get client id from packed copy.
11746   *
11747 @@ -434,7 +427,7 @@
11748         struct log              *ic_log;
11749         xfs_log_callback_t      *ic_callback;
11750         xfs_log_callback_t      **ic_callback_tail;
11751 -#ifdef DEBUG
11752 +#ifdef XFS_LOG_TRACE
11753         struct ktrace           *ic_trace;
11754  #endif
11755         int                     ic_size;
11756 @@ -531,7 +524,7 @@
11757         int                     l_grant_write_bytes;
11758  
11759         /* The following fields don't need locking */
11760 -#ifdef DEBUG
11761 +#ifdef XFS_LOG_TRACE
11762         struct ktrace           *l_trace;
11763         struct ktrace           *l_grant_trace;
11764  #endif
11765 diff -urN linux.org/fs/xfs/xfs_mount.c linux/fs/xfs/xfs_mount.c
11766 --- linux.org/fs/xfs/xfs_mount.c        2003-12-31 05:46:55.000000000 +0100
11767 +++ linux/fs/xfs/xfs_mount.c    2004-01-02 04:21:42.000000000 +0100
11768 @@ -903,7 +903,7 @@
11769          *  File systems that don't support user level file handles (i.e.
11770          *  all of them except for XFS) will leave vfs_altfsid as NULL.
11771          */
11772 -       vfsp->vfs_altfsid = (fsid_t *)mp->m_fixedfsid;
11773 +       vfsp->vfs_altfsid = (xfs_fsid_t *)mp->m_fixedfsid;
11774         mp->m_dmevmask = 0;     /* not persistent; set after each mount */
11775  
11776         /*
11777 diff -urN linux.org/fs/xfs/xfs_qmops.c linux/fs/xfs/xfs_qmops.c
11778 --- linux.org/fs/xfs/xfs_qmops.c        2003-12-31 05:46:56.000000000 +0100
11779 +++ linux/fs/xfs/xfs_qmops.c    2004-01-02 04:21:43.000000000 +0100
11780 @@ -44,7 +44,6 @@
11781  #include "xfs_mount.h"
11782  
11783  
11784 -#ifndef CONFIG_XFS_QUOTA
11785  STATIC struct xfs_dquot *
11786  xfs_dqvopchown_default(
11787         struct xfs_trans        *tp,
11788 @@ -70,4 +69,3 @@
11789         .xfs_dqvopchown         = xfs_dqvopchown_default,
11790         .xfs_dqvopchownresv     = (xfs_dqvopchownresv_t) fs_noerr,
11791  };
11792 -#endif /* CONFIG_XFS_QUOTA */
11793 diff -urN linux.org/fs/xfs/xfs_refcache.c linux/fs/xfs/xfs_refcache.c
11794 --- linux.org/fs/xfs/xfs_refcache.c     1970-01-01 01:00:00.000000000 +0100
11795 +++ linux/fs/xfs/xfs_refcache.c 2004-01-02 04:21:43.000000000 +0100
11796 @@ -0,0 +1,439 @@
11797 +/*
11798 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
11799 + *
11800 + * This program is free software; you can redistribute it and/or modify it
11801 + * under the terms of version 2 of the GNU General Public License as
11802 + * published by the Free Software Foundation.
11803 + *
11804 + * This program is distributed in the hope that it would be useful, but
11805 + * WITHOUT ANY WARRANTY; without even the implied warranty of
11806 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11807 + *
11808 + * Further, this software is distributed without any warranty that it is
11809 + * free of the rightful claim of any third person regarding infringement
11810 + * or the like.  Any license provided herein, whether implied or
11811 + * otherwise, applies only to this software file.  Patent licenses, if
11812 + * any, provided herein do not apply to combinations of this program with
11813 + * other software, or any other product whatsoever.
11814 + *
11815 + * You should have received a copy of the GNU General Public License along
11816 + * with this program; if not, write the Free Software Foundation, Inc., 59
11817 + * Temple Place - Suite 330, Boston MA 02111-1307, USA.
11818 + *
11819 + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
11820 + * Mountain View, CA  94043, or:
11821 + *
11822 + * http://www.sgi.com
11823 + *
11824 + * For further information regarding this notice, see:
11825 + *
11826 + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
11827 + */
11828 +
11829 +#include "xfs.h"
11830 +#include "xfs_macros.h"
11831 +#include "xfs_types.h"
11832 +#include "xfs_inum.h"
11833 +#include "xfs_log.h"
11834 +#include "xfs_trans.h"
11835 +#include "xfs_sb.h"
11836 +#include "xfs_ag.h"
11837 +#include "xfs_dir.h"
11838 +#include "xfs_dir2.h"
11839 +#include "xfs_dmapi.h"
11840 +#include "xfs_mount.h"
11841 +#include "xfs_alloc_btree.h"
11842 +#include "xfs_bmap_btree.h"
11843 +#include "xfs_ialloc_btree.h"
11844 +#include "xfs_itable.h"
11845 +#include "xfs_btree.h"
11846 +#include "xfs_alloc.h"
11847 +#include "xfs_ialloc.h"
11848 +#include "xfs_attr.h"
11849 +#include "xfs_attr_sf.h"
11850 +#include "xfs_dir_sf.h"
11851 +#include "xfs_dir2_sf.h"
11852 +#include "xfs_dinode.h"
11853 +#include "xfs_inode_item.h"
11854 +#include "xfs_inode.h"
11855 +#include "xfs_bmap.h"
11856 +#include "xfs_error.h"
11857 +#include "xfs_buf_item.h"
11858 +#include "xfs_refcache.h"
11859 +
11860 +STATIC spinlock_t      xfs_refcache_lock = SPIN_LOCK_UNLOCKED;
11861 +STATIC xfs_inode_t     **xfs_refcache;
11862 +STATIC int             xfs_refcache_index;
11863 +STATIC int             xfs_refcache_busy;
11864 +STATIC int             xfs_refcache_count;
11865 +
11866 +/*
11867 + * Insert the given inode into the reference cache.
11868 + */
11869 +void
11870 +xfs_refcache_insert(
11871 +       xfs_inode_t     *ip)
11872 +{
11873 +       vnode_t         *vp;
11874 +       xfs_inode_t     *release_ip;
11875 +       xfs_inode_t     **refcache;
11876 +
11877 +       ASSERT(ismrlocked(&(ip->i_iolock), MR_UPDATE));
11878 +
11879 +       /*
11880 +        * If an unmount is busy blowing entries out of the cache,
11881 +        * then don't bother.
11882 +        */
11883 +       if (xfs_refcache_busy) {
11884 +               return;
11885 +       }
11886 +
11887 +       /*
11888 +        * If we tuned the refcache down to zero, don't do anything.
11889 +        */
11890 +        if (!xfs_refcache_size) {
11891 +               return;
11892 +       }
11893 +
11894 +       /*
11895 +        * The inode is already in the refcache, so don't bother
11896 +        * with it.
11897 +        */
11898 +       if (ip->i_refcache != NULL) {
11899 +               return;
11900 +       }
11901 +
11902 +       vp = XFS_ITOV(ip);
11903 +       /* ASSERT(vp->v_count > 0); */
11904 +       VN_HOLD(vp);
11905 +
11906 +       /*
11907 +        * We allocate the reference cache on use so that we don't
11908 +        * waste the memory on systems not being used as NFS servers.
11909 +        */
11910 +       if (xfs_refcache == NULL) {
11911 +               refcache = (xfs_inode_t **)kmem_zalloc(XFS_REFCACHE_SIZE_MAX *
11912 +                                                      sizeof(xfs_inode_t *),
11913 +                                                      KM_SLEEP);
11914 +       } else {
11915 +               refcache = NULL;
11916 +       }
11917 +
11918 +       spin_lock(&xfs_refcache_lock);
11919 +
11920 +       /*
11921 +        * If we allocated memory for the refcache above and it still
11922 +        * needs it, then use the memory we allocated.  Otherwise we'll
11923 +        * free the memory below.
11924 +        */
11925 +       if (refcache != NULL) {
11926 +               if (xfs_refcache == NULL) {
11927 +                       xfs_refcache = refcache;
11928 +                       refcache = NULL;
11929 +               }
11930 +       }
11931 +
11932 +       /*
11933 +        * If an unmount is busy clearing out the cache, don't add new
11934 +        * entries to it.
11935 +        */
11936 +       if (xfs_refcache_busy) {
11937 +               spin_unlock(&xfs_refcache_lock);
11938 +               VN_RELE(vp);
11939 +               /*
11940 +                * If we allocated memory for the refcache above but someone
11941 +                * else beat us to using it, then free the memory now.
11942 +                */
11943 +               if (refcache != NULL) {
11944 +                       kmem_free(refcache,
11945 +                                 XFS_REFCACHE_SIZE_MAX * sizeof(xfs_inode_t *));
11946 +               }
11947 +               return;
11948 +       }
11949 +       release_ip = xfs_refcache[xfs_refcache_index];
11950 +       if (release_ip != NULL) {
11951 +               release_ip->i_refcache = NULL;
11952 +               xfs_refcache_count--;
11953 +               ASSERT(xfs_refcache_count >= 0);
11954 +       }
11955 +       xfs_refcache[xfs_refcache_index] = ip;
11956 +       ASSERT(ip->i_refcache == NULL);
11957 +       ip->i_refcache = &(xfs_refcache[xfs_refcache_index]);
11958 +       xfs_refcache_count++;
11959 +       ASSERT(xfs_refcache_count <= xfs_refcache_size);
11960 +       xfs_refcache_index++;
11961 +       if (xfs_refcache_index == xfs_refcache_size) {
11962 +               xfs_refcache_index = 0;
11963 +       }
11964 +       spin_unlock(&xfs_refcache_lock);
11965 +
11966 +       /*
11967 +        * Save the pointer to the inode to be released so that we can
11968 +        * VN_RELE it once we've dropped our inode locks in xfs_rwunlock().
11969 +        * The pointer may be NULL, but that's OK.
11970 +        */
11971 +       ip->i_release = release_ip;
11972 +
11973 +       /*
11974 +        * If we allocated memory for the refcache above but someone
11975 +        * else beat us to using it, then free the memory now.
11976 +        */
11977 +       if (refcache != NULL) {
11978 +               kmem_free(refcache,
11979 +                         XFS_REFCACHE_SIZE_MAX * sizeof(xfs_inode_t *));
11980 +       }
11981 +}
11982 +
11983 +
11984 +/*
11985 + * If the given inode is in the reference cache, purge its entry and
11986 + * release the reference on the vnode.
11987 + */
11988 +void
11989 +xfs_refcache_purge_ip(
11990 +       xfs_inode_t     *ip)
11991 +{
11992 +       vnode_t *vp;
11993 +       int     error;
11994 +
11995 +       /*
11996 +        * If we're not pointing to our entry in the cache, then
11997 +        * we must not be in the cache.
11998 +        */
11999 +       if (ip->i_refcache == NULL) {
12000 +               return;
12001 +       }
12002 +
12003 +       spin_lock(&xfs_refcache_lock);
12004 +       if (ip->i_refcache == NULL) {
12005 +               spin_unlock(&xfs_refcache_lock);
12006 +               return;
12007 +       }
12008 +
12009 +       /*
12010 +        * Clear both our pointer to the cache entry and its pointer
12011 +        * back to us.
12012 +        */
12013 +       ASSERT(*(ip->i_refcache) == ip);
12014 +       *(ip->i_refcache) = NULL;
12015 +       ip->i_refcache = NULL;
12016 +       xfs_refcache_count--;
12017 +       ASSERT(xfs_refcache_count >= 0);
12018 +       spin_unlock(&xfs_refcache_lock);
12019 +
12020 +       vp = XFS_ITOV(ip);
12021 +       /* ASSERT(vp->v_count > 1); */
12022 +       VOP_RELEASE(vp, error);
12023 +       VN_RELE(vp);
12024 +}
12025 +
12026 +
12027 +/*
12028 + * This is called from the XFS unmount code to purge all entries for the
12029 + * given mount from the cache.  It uses the refcache busy counter to
12030 + * make sure that new entries are not added to the cache as we purge them.
12031 + */
12032 +void
12033 +xfs_refcache_purge_mp(
12034 +       xfs_mount_t     *mp)
12035 +{
12036 +       vnode_t         *vp;
12037 +       int             error, i;
12038 +       xfs_inode_t     *ip;
12039 +
12040 +       if (xfs_refcache == NULL) {
12041 +               return;
12042 +       }
12043 +
12044 +       spin_lock(&xfs_refcache_lock);
12045 +       /*
12046 +        * Bumping the busy counter keeps new entries from being added
12047 +        * to the cache.  We use a counter since multiple unmounts could
12048 +        * be in here simultaneously.
12049 +        */
12050 +       xfs_refcache_busy++;
12051 +
12052 +       for (i = 0; i < xfs_refcache_size; i++) {
12053 +               ip = xfs_refcache[i];
12054 +               if ((ip != NULL) && (ip->i_mount == mp)) {
12055 +                       xfs_refcache[i] = NULL;
12056 +                       ip->i_refcache = NULL;
12057 +                       xfs_refcache_count--;
12058 +                       ASSERT(xfs_refcache_count >= 0);
12059 +                       spin_unlock(&xfs_refcache_lock);
12060 +                       vp = XFS_ITOV(ip);
12061 +                       VOP_RELEASE(vp, error);
12062 +                       VN_RELE(vp);
12063 +                       spin_lock(&xfs_refcache_lock);
12064 +               }
12065 +       }
12066 +
12067 +       xfs_refcache_busy--;
12068 +       ASSERT(xfs_refcache_busy >= 0);
12069 +       spin_unlock(&xfs_refcache_lock);
12070 +}
12071 +
12072 +
12073 +/*
12074 + * This is called from the XFS sync code to ensure that the refcache
12075 + * is emptied out over time.  We purge a small number of entries with
12076 + * each call.
12077 + */
12078 +void
12079 +xfs_refcache_purge_some(xfs_mount_t *mp)
12080 +{
12081 +       int             error, i;
12082 +       xfs_inode_t     *ip;
12083 +       int             iplist_index;
12084 +       xfs_inode_t     **iplist;
12085 +
12086 +       if ((xfs_refcache == NULL) || (xfs_refcache_count == 0)) {
12087 +               return;
12088 +       }
12089 +
12090 +       iplist_index = 0;
12091 +       iplist = (xfs_inode_t **)kmem_zalloc(xfs_refcache_purge_count *
12092 +                                         sizeof(xfs_inode_t *), KM_SLEEP);
12093 +
12094 +       spin_lock(&xfs_refcache_lock);
12095 +
12096 +       /*
12097 +        * Store any inodes we find in the next several entries
12098 +        * into the iplist array to be released after dropping
12099 +        * the spinlock.  We always start looking from the currently
12100 +        * oldest place in the cache.  We move the refcache index
12101 +        * forward as we go so that we are sure to eventually clear
12102 +        * out the entire cache when the system goes idle.
12103 +        */
12104 +       for (i = 0; i < xfs_refcache_purge_count; i++) {
12105 +               ip = xfs_refcache[xfs_refcache_index];
12106 +               if (ip != NULL) {
12107 +                       xfs_refcache[xfs_refcache_index] = NULL;
12108 +                       ip->i_refcache = NULL;
12109 +                       xfs_refcache_count--;
12110 +                       ASSERT(xfs_refcache_count >= 0);
12111 +                       iplist[iplist_index] = ip;
12112 +                       iplist_index++;
12113 +               }
12114 +               xfs_refcache_index++;
12115 +               if (xfs_refcache_index == xfs_refcache_size) {
12116 +                       xfs_refcache_index = 0;
12117 +               }
12118 +       }
12119 +
12120 +       spin_unlock(&xfs_refcache_lock);
12121 +
12122 +       /*
12123 +        * Now drop the inodes we collected.
12124 +        */
12125 +       for (i = 0; i < iplist_index; i++) {
12126 +               VOP_RELEASE(XFS_ITOV(iplist[i]), error);
12127 +               VN_RELE(XFS_ITOV(iplist[i]));
12128 +       }
12129 +
12130 +       kmem_free(iplist, xfs_refcache_purge_count *
12131 +                         sizeof(xfs_inode_t *));
12132 +}
12133 +
12134 +/*
12135 + * This is called when the refcache is dynamically resized
12136 + * via a sysctl.
12137 + *
12138 + * If the new size is smaller than the old size, purge all
12139 + * entries in slots greater than the new size, and move
12140 + * the index if necessary.
12141 + *
12142 + * If the refcache hasn't even been allocated yet, or the
12143 + * new size is larger than the old size, just set the value
12144 + * of xfs_refcache_size.
12145 + */
12146 +
12147 +void
12148 +xfs_refcache_resize(int xfs_refcache_new_size)
12149 +{
12150 +       int             i;
12151 +       xfs_inode_t     *ip;
12152 +       int             iplist_index = 0;
12153 +       xfs_inode_t     **iplist;
12154 +       int             error;
12155 +
12156 +       /*
12157 +        * If the new size is smaller than the current size,
12158 +        * purge entries to create smaller cache, and
12159 +        * reposition index if necessary.
12160 +        * Don't bother if no refcache yet.
12161 +        */
12162 +       if (xfs_refcache && (xfs_refcache_new_size < xfs_refcache_size)) {
12163 +
12164 +               iplist = (xfs_inode_t **)kmem_zalloc(XFS_REFCACHE_SIZE_MAX *
12165 +                               sizeof(xfs_inode_t *), KM_SLEEP);
12166 +
12167 +               spin_lock(&xfs_refcache_lock);
12168 +
12169 +               for (i = xfs_refcache_new_size; i < xfs_refcache_size; i++) {
12170 +                       ip = xfs_refcache[i];
12171 +                       if (ip != NULL) {
12172 +                               xfs_refcache[i] = NULL;
12173 +                               ip->i_refcache = NULL;
12174 +                               xfs_refcache_count--;
12175 +                               ASSERT(xfs_refcache_count >= 0);
12176 +                               iplist[iplist_index] = ip;
12177 +                               iplist_index++;
12178 +                       }
12179 +               }
12180 +
12181 +               xfs_refcache_size = xfs_refcache_new_size;
12182 +
12183 +               /*
12184 +                * Move index to beginning of cache if it's now past the end
12185 +                */
12186 +               if (xfs_refcache_index >= xfs_refcache_new_size)
12187 +                       xfs_refcache_index = 0;
12188 +
12189 +               spin_unlock(&xfs_refcache_lock);
12190 +
12191 +               /*
12192 +                * Now drop the inodes we collected.
12193 +                */
12194 +               for (i = 0; i < iplist_index; i++) {
12195 +                       VOP_RELEASE(XFS_ITOV(iplist[i]), error);
12196 +                       VN_RELE(XFS_ITOV(iplist[i]));
12197 +               }
12198 +
12199 +               kmem_free(iplist, XFS_REFCACHE_SIZE_MAX *
12200 +                                 sizeof(xfs_inode_t *));
12201 +       } else {
12202 +               spin_lock(&xfs_refcache_lock);
12203 +               xfs_refcache_size = xfs_refcache_new_size;
12204 +               spin_unlock(&xfs_refcache_lock);
12205 +       }
12206 +}
12207 +
12208 +void
12209 +xfs_refcache_iunlock(
12210 +       xfs_inode_t     *ip,
12211 +       uint            lock_flags)
12212 +{
12213 +       xfs_inode_t     *release_ip;
12214 +       int             error;
12215 +
12216 +       release_ip = ip->i_release;
12217 +       ip->i_release = NULL;
12218 +
12219 +       xfs_iunlock(ip, lock_flags);
12220 +
12221 +       if (release_ip != NULL) {
12222 +               VOP_RELEASE(XFS_ITOV(release_ip), error);
12223 +               VN_RELE(XFS_ITOV(release_ip));
12224 +       }
12225 +}
12226 +
12227 +void
12228 +xfs_refcache_destroy(void)
12229 +{
12230 +       if (xfs_refcache) {
12231 +               kmem_free(xfs_refcache,
12232 +                       XFS_REFCACHE_SIZE_MAX * sizeof(xfs_inode_t *));
12233 +               xfs_refcache = NULL;
12234 +       }
12235 +}
12236 diff -urN linux.org/fs/xfs/xfs_refcache.h linux/fs/xfs/xfs_refcache.h
12237 --- linux.org/fs/xfs/xfs_refcache.h     1970-01-01 01:00:00.000000000 +0100
12238 +++ linux/fs/xfs/xfs_refcache.h 2004-01-02 04:21:43.000000000 +0100
12239 @@ -0,0 +1,66 @@
12240 +/*
12241 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
12242 + *
12243 + * This program is free software; you can redistribute it and/or modify it
12244 + * under the terms of version 2 of the GNU General Public License as
12245 + * published by the Free Software Foundation.
12246 + *
12247 + * This program is distributed in the hope that it would be useful, but
12248 + * WITHOUT ANY WARRANTY; without even the implied warranty of
12249 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12250 + *
12251 + * Further, this software is distributed without any warranty that it is
12252 + * free of the rightful claim of any third person regarding infringement
12253 + * or the like.  Any license provided herein, whether implied or
12254 + * otherwise, applies only to this software file.  Patent licenses, if
12255 + * any, provided herein do not apply to combinations of this program with
12256 + * other software, or any other product whatsoever.
12257 + *
12258 + * You should have received a copy of the GNU General Public License along
12259 + * with this program; if not, write the Free Software Foundation, Inc., 59
12260 + * Temple Place - Suite 330, Boston MA 02111-1307, USA.
12261 + *
12262 + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
12263 + * Mountain View, CA  94043, or:
12264 + *
12265 + * http://www.sgi.com
12266 + *
12267 + * For further information regarding this notice, see:
12268 + *
12269 + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
12270 + */
12271 +#ifndef __XFS_REFCACHE_H__
12272 +#define __XFS_REFCACHE_H__
12273 +
12274 +#ifdef HAVE_REFCACHE
12275 +/*
12276 + * Maximum size (in inodes) for the NFS reference cache
12277 + */
12278 +#define XFS_REFCACHE_SIZE_MAX  512
12279 +
12280 +struct xfs_inode;
12281 +struct xfs_mount;
12282 +
12283 +extern void xfs_refcache_insert(struct xfs_inode *);
12284 +extern void xfs_refcache_purge_ip(struct xfs_inode *);
12285 +extern void xfs_refcache_purge_mp(struct xfs_mount *);
12286 +extern void xfs_refcache_purge_some(struct xfs_mount *);
12287 +extern void xfs_refcache_resize(int);
12288 +extern void xfs_refcache_destroy(void);
12289 +
12290 +extern void xfs_refcache_iunlock(struct xfs_inode *, uint);
12291 +
12292 +#else
12293 +
12294 +#define xfs_refcache_insert(ip)                do { } while (0)
12295 +#define xfs_refcache_purge_ip(ip)      do { } while (0)
12296 +#define xfs_refcache_purge_mp(mp)      do { } while (0)
12297 +#define xfs_refcache_purge_some(mp)    do { } while (0)
12298 +#define xfs_refcache_resize(size)      do { } while (0)
12299 +#define xfs_refcache_destroy()         do { } while (0)
12300 +
12301 +#define xfs_refcache_iunlock(ip, flags)        xfs_iunlock(ip, flags)
12302 +
12303 +#endif
12304 +
12305 +#endif /* __XFS_REFCACHE_H__ */
12306 diff -urN linux.org/fs/xfs/xfs_rename.c linux/fs/xfs/xfs_rename.c
12307 --- linux.org/fs/xfs/xfs_rename.c       2003-12-31 05:47:23.000000000 +0100
12308 +++ linux/fs/xfs/xfs_rename.c   2004-01-02 04:21:43.000000000 +0100
12309 @@ -1,5 +1,5 @@
12310  /*
12311 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
12312 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
12313   *
12314   * This program is free software; you can redistribute it and/or modify it
12315   * under the terms of version 2 of the GNU General Public License as
12316 @@ -51,7 +51,7 @@
12317  #include "xfs_bmap.h"
12318  #include "xfs_error.h"
12319  #include "xfs_quota.h"
12320 -#include "xfs_rw.h"
12321 +#include "xfs_refcache.h"
12322  #include "xfs_utils.h"
12323  #include "xfs_trans_space.h"
12324  #include "xfs_da_btree.h"
12325 @@ -343,8 +343,7 @@
12326         src_is_directory = ((src_ip->i_d.di_mode & S_IFMT) == S_IFDIR);
12327  
12328         /*
12329 -        * Drop the locks on our inodes so that we can do the ancestor
12330 -        * check if necessary and start the transaction.
12331 +        * Drop the locks on our inodes so that we can start the transaction.
12332          */
12333         xfs_rename_unlock4(inodes, XFS_ILOCK_SHARED);
12334  
12335 @@ -486,7 +485,7 @@
12336                 error = xfs_droplink(tp, target_ip);
12337                 if (error) {
12338                         rename_which_error_return = __LINE__;
12339 -                       goto abort_return;;
12340 +                       goto abort_return;
12341                 }
12342                 target_ip_dropped = 1;
12343  
12344 @@ -627,6 +626,7 @@
12345          */
12346         error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);
12347         if (target_ip != NULL) {
12348 +               xfs_refcache_purge_ip(target_ip);
12349                 IRELE(target_ip);
12350         }
12351         /*
12352 diff -urN linux.org/fs/xfs/xfs_rw.c linux/fs/xfs/xfs_rw.c
12353 --- linux.org/fs/xfs/xfs_rw.c   2003-12-31 05:48:40.000000000 +0100
12354 +++ linux/fs/xfs/xfs_rw.c       2004-01-02 04:21:43.000000000 +0100
12355 @@ -1,5 +1,5 @@
12356  /*
12357 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
12358 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
12359   *
12360   * This program is free software; you can redistribute it and/or modify it
12361   * under the terms of version 2 of the GNU General Public License as
12362 @@ -149,6 +149,9 @@
12363                 xfs_cmn_err(XFS_PTAG_SHUTDOWN_CORRUPT, CE_ALERT, mp,
12364      "Corruption of in-memory data detected.  Shutting down filesystem: %s",
12365                         mp->m_fsname);
12366 +               if (XFS_ERRLEVEL_HIGH <= xfs_error_level) {
12367 +                       xfs_stack_trace();
12368 +               }
12369         } else if (!(flags & XFS_FORCE_UMOUNT)) {
12370                 if (logerror) {
12371                         xfs_cmn_err(XFS_PTAG_SHUTDOWN_LOGERROR, CE_ALERT, mp,
12372 @@ -351,54 +354,3 @@
12373         }
12374         return (error);
12375  }
12376 -
12377 -/*
12378 - * xfs_inval_cached_pages()
12379 - * This routine is responsible for keeping direct I/O and buffered I/O
12380 - * somewhat coherent.  From here we make sure that we're at least
12381 - * temporarily holding the inode I/O lock exclusively and then call
12382 - * the page cache to flush and invalidate any cached pages.  If there
12383 - * are no cached pages this routine will be very quick.
12384 - */
12385 -void
12386 -xfs_inval_cached_pages(
12387 -       vnode_t         *vp,
12388 -       xfs_iocore_t    *io,
12389 -       xfs_off_t       offset,
12390 -       int             write,
12391 -       int             relock)
12392 -{
12393 -       xfs_mount_t     *mp;
12394 -
12395 -       if (!VN_CACHED(vp)) {
12396 -               return;
12397 -       }
12398 -
12399 -       mp = io->io_mount;
12400 -
12401 -       /*
12402 -        * We need to get the I/O lock exclusively in order
12403 -        * to safely invalidate pages and mappings.
12404 -        */
12405 -       if (relock) {
12406 -               XFS_IUNLOCK(mp, io, XFS_IOLOCK_SHARED);
12407 -               XFS_ILOCK(mp, io, XFS_IOLOCK_EXCL);
12408 -       }
12409 -
12410 -       /* Writing beyond EOF creates a hole that must be zeroed */
12411 -       if (write && (offset > XFS_SIZE(mp, io))) {
12412 -               xfs_fsize_t     isize;
12413 -
12414 -               XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
12415 -               isize = XFS_SIZE(mp, io);
12416 -               if (offset > isize) {
12417 -                       xfs_zero_eof(vp, io, offset, isize, offset);
12418 -               }
12419 -               XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
12420 -       }
12421 -
12422 -       VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(offset)), -1, FI_REMAPF_LOCKED);
12423 -       if (relock) {
12424 -               XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
12425 -       }
12426 -}
12427 diff -urN linux.org/fs/xfs/xfs_rw.h linux/fs/xfs/xfs_rw.h
12428 --- linux.org/fs/xfs/xfs_rw.h   2003-12-31 05:46:29.000000000 +0100
12429 +++ linux/fs/xfs/xfs_rw.h       2004-01-02 04:21:43.000000000 +0100
12430 @@ -1,5 +1,5 @@
12431  /*
12432 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
12433 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
12434   *
12435   * This program is free software; you can redistribute it and/or modify it
12436   * under the terms of version 2 of the GNU General Public License as
12437 @@ -32,16 +32,9 @@
12438  #ifndef        __XFS_RW_H__
12439  #define        __XFS_RW_H__
12440  
12441 -struct bhv_desc;
12442 -struct bmapval;
12443  struct xfs_buf;
12444 -struct cred;
12445 -struct uio;
12446 -struct vnode;
12447  struct xfs_inode;
12448 -struct xfs_iocore;
12449  struct xfs_mount;
12450 -struct xfs_trans;
12451  
12452  /*
12453   * Maximum count of bmaps used by read and write paths.
12454 @@ -91,44 +84,6 @@
12455                  XFS_FSB_TO_DADDR((io)->io_mount, (fsb)))
12456  
12457  /*
12458 - * Defines for the trace mechanisms in xfs_rw.c.
12459 - */
12460 -#define        XFS_RW_KTRACE_SIZE      64
12461 -#define        XFS_STRAT_KTRACE_SIZE   64
12462 -#define        XFS_STRAT_GTRACE_SIZE   512
12463 -
12464 -#define        XFS_READ_ENTER          1
12465 -#define        XFS_WRITE_ENTER         2
12466 -#define XFS_IOMAP_READ_ENTER   3
12467 -#define        XFS_IOMAP_WRITE_ENTER   4
12468 -#define        XFS_IOMAP_READ_MAP      5
12469 -#define        XFS_IOMAP_WRITE_MAP     6
12470 -#define        XFS_IOMAP_WRITE_NOSPACE 7
12471 -#define        XFS_ITRUNC_START        8
12472 -#define        XFS_ITRUNC_FINISH1      9
12473 -#define        XFS_ITRUNC_FINISH2      10
12474 -#define        XFS_CTRUNC1             11
12475 -#define        XFS_CTRUNC2             12
12476 -#define        XFS_CTRUNC3             13
12477 -#define        XFS_CTRUNC4             14
12478 -#define        XFS_CTRUNC5             15
12479 -#define        XFS_CTRUNC6             16
12480 -#define        XFS_BUNMAPI             17
12481 -#define        XFS_INVAL_CACHED        18
12482 -#define        XFS_DIORD_ENTER         19
12483 -#define        XFS_DIOWR_ENTER         20
12484 -
12485 -#if defined(XFS_ALL_TRACE)
12486 -#define        XFS_RW_TRACE
12487 -#define        XFS_STRAT_TRACE
12488 -#endif
12489 -
12490 -#if !defined(DEBUG)
12491 -#undef XFS_RW_TRACE
12492 -#undef XFS_STRAT_TRACE
12493 -#endif
12494 -
12495 -/*
12496   * Prototypes for functions in xfs_rw.c.
12497   */
12498  
12499 @@ -141,14 +96,6 @@
12500         struct xfs_mount        *mp,
12501         struct xfs_buf          *bp);
12502  
12503 -void
12504 -xfs_inval_cached_pages(
12505 -       struct vnode            *vp,
12506 -       struct xfs_iocore       *io,
12507 -       xfs_off_t               offset,
12508 -       int                     write,
12509 -       int                     relock);
12510 -
12511  int
12512  xfs_bioerror(
12513         struct xfs_buf          *b);
12514 diff -urN linux.org/fs/xfs/xfs_trans.c linux/fs/xfs/xfs_trans.c
12515 --- linux.org/fs/xfs/xfs_trans.c        2003-12-31 05:47:13.000000000 +0100
12516 +++ linux/fs/xfs/xfs_trans.c    2004-01-02 04:21:43.000000000 +0100
12517 @@ -142,9 +142,9 @@
12518         uint            type)
12519  {
12520         xfs_trans_t     *tp;
12521 +
12522         ASSERT(xfs_trans_zone != NULL);
12523         tp = kmem_zone_zalloc(xfs_trans_zone, KM_SLEEP);
12524 -       tp->t_dqinfo = NULL;
12525  
12526         /*
12527          * Initialize the transaction structure.
12528 diff -urN linux.org/fs/xfs/xfs_vfsops.c linux/fs/xfs/xfs_vfsops.c
12529 --- linux.org/fs/xfs/xfs_vfsops.c       2003-12-31 05:46:41.000000000 +0100
12530 +++ linux/fs/xfs/xfs_vfsops.c   2004-01-02 04:21:43.000000000 +0100
12531 @@ -60,6 +60,7 @@
12532  #include "xfs_bmap.h"
12533  #include "xfs_da_btree.h"
12534  #include "xfs_rw.h"
12535 +#include "xfs_refcache.h"
12536  #include "xfs_buf_item.h"
12537  #include "xfs_extfree_item.h"
12538  #include "xfs_quota.h"
12539 @@ -74,24 +75,11 @@
12540  int
12541  xfs_init(void)
12542  {
12543 -       extern kmem_zone_t      *xfs_da_state_zone;
12544         extern kmem_zone_t      *xfs_bmap_free_item_zone;
12545         extern kmem_zone_t      *xfs_btree_cur_zone;
12546 -       extern kmem_zone_t      *xfs_inode_zone;
12547 -       extern kmem_zone_t      *xfs_chashlist_zone;
12548         extern kmem_zone_t      *xfs_trans_zone;
12549         extern kmem_zone_t      *xfs_buf_item_zone;
12550 -       extern kmem_zone_t      *xfs_efd_zone;
12551 -       extern kmem_zone_t      *xfs_efi_zone;
12552         extern kmem_zone_t      *xfs_dabuf_zone;
12553 -#ifdef DEBUG_NOT
12554 -       extern ktrace_t         *xfs_alloc_trace_buf;
12555 -       extern ktrace_t         *xfs_bmap_trace_buf;
12556 -       extern ktrace_t         *xfs_bmbt_trace_buf;
12557 -       extern ktrace_t         *xfs_dir_trace_buf;
12558 -       extern ktrace_t         *xfs_attr_trace_buf;
12559 -       extern ktrace_t         *xfs_dir2_trace_buf;
12560 -#endif /* DEBUG */
12561  #ifdef XFS_DABUF_DEBUG
12562         extern lock_t           xfs_dabuf_global_lock;
12563         spinlock_init(&xfs_dabuf_global_lock, "xfsda");
12564 @@ -132,14 +120,6 @@
12565                                             "xfs_chashlist");
12566         _ACL_ZONE_INIT(xfs_acl_zone, "xfs_acl");
12567  
12568 -#ifdef CONFIG_XFS_VNODE_TRACING
12569 -       ktrace_init(VNODE_TRACE_SIZE);
12570 -#else
12571 -#ifdef DEBUG
12572 -       ktrace_init(64);
12573 -#endif
12574 -#endif
12575 -
12576         /*
12577          * Allocate global trace buffers.
12578          */
12579 @@ -189,6 +169,7 @@
12580  
12581         xfs_cleanup_procfs();
12582         xfs_sysctl_unregister();
12583 +       xfs_refcache_destroy();
12584  
12585         kmem_cache_destroy(xfs_bmap_free_item_zone);
12586         kmem_cache_destroy(xfs_btree_cur_zone);
12587 @@ -203,9 +184,6 @@
12588         kmem_cache_destroy(xfs_ili_zone);
12589         kmem_cache_destroy(xfs_chashlist_zone);
12590         _ACL_ZONE_DESTROY(xfs_acl_zone);
12591 -#if  (defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
12592 -       ktrace_uninit();
12593 -#endif
12594  }
12595  
12596  /*
12597 @@ -547,6 +525,12 @@
12598                                         0 : DM_FLAGS_UNWANTED;
12599         }
12600  
12601 +       /*
12602 +        * First blow any referenced inode from this file system
12603 +        * out of the reference cache, and delete the timer.
12604 +        */
12605 +       xfs_refcache_purge_mp(mp);
12606 +
12607         XFS_bflush(mp->m_ddev_targp);
12608         error = xfs_unmount_flush(mp, 0);
12609         if (error)
12610 @@ -617,6 +601,7 @@
12611         }
12612  
12613         if (*flags & MS_RDONLY) {
12614 +               xfs_refcache_purge_mp(mp);
12615                 pagebuf_delwri_flush(mp->m_ddev_targp, 0, NULL);
12616                 xfs_finish_reclaim_all(mp, 0);
12617  
12618 @@ -758,7 +743,7 @@
12619  STATIC int
12620  xfs_statvfs(
12621         bhv_desc_t      *bdp,
12622 -       struct kstatfs  *statp,
12623 +       xfs_statfs_t    *statp,
12624         vnode_t         *vp)
12625  {
12626         __uint64_t      fakeinos;
12627 @@ -766,7 +751,6 @@
12628         xfs_mount_t     *mp;
12629         xfs_sb_t        *sbp;
12630         unsigned long   s;
12631 -       u64 id;
12632  
12633         mp = XFS_BHVTOM(bdp);
12634         sbp = &(mp->m_sb);
12635 @@ -793,9 +777,8 @@
12636         statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
12637         XFS_SB_UNLOCK(mp, s);
12638  
12639 -       id = huge_encode_dev(mp->m_dev);
12640 -       statp->f_fsid.val[0] = (u32)id;
12641 -       statp->f_fsid.val[1] = (u32)(id >> 32);
12642 +       statp->f_fsid.val[0] = mp->m_dev;
12643 +       statp->f_fsid.val[1] = 0;
12644         statp->f_namelen = MAXNAMELEN - 1;
12645  
12646         return 0;
12647 @@ -1489,8 +1472,18 @@
12648         }
12649  
12650         /*
12651 +        * If this is the periodic sync, then kick some entries out of
12652 +        * the reference cache.  This ensures that idle entries are
12653 +        * eventually kicked out of the cache.
12654 +        */
12655 +       if (flags & SYNC_REFCACHE) {
12656 +               xfs_refcache_purge_some(mp);
12657 +       }
12658 +
12659 +       /*
12660          * Now check to see if the log needs a "dummy" transaction.
12661          */
12662 +
12663         if (!(flags & SYNC_REMOUNT) && xfs_log_need_covered(mp)) {
12664                 xfs_trans_t *tp;
12665                 xfs_inode_t *ip;
12666 @@ -1784,10 +1782,14 @@
12667                 char    *str;
12668         } xfs_info[] = {
12669                 /* the few simple ones we can get from the mount struct */
12670 +               { XFS_MOUNT_WSYNC,              "," MNTOPT_WSYNC },
12671 +               { XFS_MOUNT_INO64,              "," MNTOPT_INO64 },
12672                 { XFS_MOUNT_NOALIGN,            "," MNTOPT_NOALIGN },
12673 +               { XFS_MOUNT_NOUUID,             "," MNTOPT_NOUUID },
12674                 { XFS_MOUNT_NORECOVERY,         "," MNTOPT_NORECOVERY },
12675                 { XFS_MOUNT_OSYNCISOSYNC,       "," MNTOPT_OSYNCISOSYNC },
12676 -               { XFS_MOUNT_NOUUID,             "," MNTOPT_NOUUID },
12677 +               { XFS_MOUNT_NOLOGFLUSH,         "," MNTOPT_NOLOGFLUSH },
12678 +               { XFS_MOUNT_IDELETE,            "," MNTOPT_NOIKEEP },
12679                 { 0, NULL }
12680         };
12681         struct proc_xfs_info    *xfs_infop;
12682 @@ -1823,6 +1825,9 @@
12683                 seq_printf(m, "," MNTOPT_SWIDTH "=%d",
12684                                 (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
12685  
12686 +       if (!(mp->m_flags & XFS_MOUNT_32BITINOOPT))
12687 +               seq_printf(m, "," MNTOPT_64BITINODE);
12688 +       
12689         return 0;
12690  }
12691  
12692 @@ -1840,6 +1845,7 @@
12693         .vfs_vget               = xfs_vget,
12694         .vfs_dmapiops           = (vfs_dmapiops_t)fs_nosys,
12695         .vfs_quotactl           = (vfs_quotactl_t)fs_nosys,
12696 +       .vfs_get_inode          = xfs_get_inode,
12697         .vfs_init_vnode         = xfs_initialize_vnode,
12698         .vfs_force_shutdown     = xfs_do_force_shutdown,
12699  };
12700 diff -urN linux.org/fs/xfs/xfs_vnodeops.c linux/fs/xfs/xfs_vnodeops.c
12701 --- linux.org/fs/xfs/xfs_vnodeops.c     2003-12-31 05:48:49.000000000 +0100
12702 +++ linux/fs/xfs/xfs_vnodeops.c 2004-01-02 04:21:43.000000000 +0100
12703 @@ -59,6 +59,7 @@
12704  #include "xfs_da_btree.h"
12705  #include "xfs_attr.h"
12706  #include "xfs_rw.h"
12707 +#include "xfs_refcache.h"
12708  #include "xfs_error.h"
12709  #include "xfs_bit.h"
12710  #include "xfs_rtalloc.h"
12711 @@ -77,10 +78,6 @@
12712   */
12713  #define SYMLINK_MAPS 2
12714  
12715 -extern int xfs_ioctl(bhv_desc_t *, struct inode *, struct file *,
12716 -                       int, unsigned int, unsigned long);
12717 -
12718 -
12719  /*
12720   * For xfs, we check that the file isn't too big to be opened by this kernel.
12721   * No other open action is required for regular files.  Devices are handled
12722 @@ -434,7 +431,7 @@
12723         }
12724  
12725         /* boolean: are we the file owner? */
12726 -       file_owner = (current->fsuid == ip->i_d.di_uid);
12727 +       file_owner = (current_fsuid(credp) == ip->i_d.di_uid);
12728  
12729         /*
12730          * Change various properties of a file.
12731 @@ -1660,6 +1657,12 @@
12732         if (vp->v_vfsp->vfs_flag & VFS_RDONLY)
12733                 return 0;
12734  
12735 +#ifdef HAVE_REFCACHE
12736 +       /* If we are in the NFS reference cache then don't do this now */
12737 +       if (ip->i_refcache)
12738 +               return 0;
12739 +#endif
12740 +
12741         mp = ip->i_mount;
12742  
12743         if (ip->i_d.di_nlink != 0) {
12744 @@ -2004,7 +2007,8 @@
12745         /*
12746          * Make sure that we have allocated dquot(s) on disk.
12747          */
12748 -       error = XFS_QM_DQVOPALLOC(mp, dp, current->fsuid, current->fsgid,
12749 +       error = XFS_QM_DQVOPALLOC(mp, dp,
12750 +                       current_fsuid(credp), current_fsgid(credp),
12751                         XFS_QMOPT_QUOTALL|XFS_QMOPT_INHERIT, &udqp, &gdqp);
12752         if (error)
12753                 goto std_return;
12754 @@ -2613,6 +2617,14 @@
12755                 goto std_return;
12756         }
12757  
12758 +       /*
12759 +        * Before we drop our extra reference to the inode, purge it
12760 +        * from the refcache if it is there.  By waiting until afterwards
12761 +        * to do the IRELE, we ensure that we won't go inactive in the
12762 +        * xfs_refcache_purge_ip routine (although that would be OK).
12763 +        */
12764 +       xfs_refcache_purge_ip(ip);
12765 +
12766         vn_trace_exit(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
12767  
12768         /*
12769 @@ -2652,6 +2664,14 @@
12770         cancel_flags |= XFS_TRANS_ABORT;
12771         xfs_trans_cancel(tp, cancel_flags);
12772  
12773 +       /*
12774 +        * Before we drop our extra reference to the inode, purge it
12775 +        * from the refcache if it is there.  By waiting until afterwards
12776 +        * to do the IRELE, we ensure that we won't go inactive in the
12777 +        * xfs_refcache_purge_ip routine (although that would be OK).
12778 +        */
12779 +       xfs_refcache_purge_ip(ip);
12780 +
12781         IRELE(ip);
12782  
12783         goto std_return;
12784 @@ -2899,7 +2919,8 @@
12785         /*
12786          * Make sure that we have allocated dquot(s) on disk.
12787          */
12788 -       error = XFS_QM_DQVOPALLOC(mp, dp, current->fsuid, current->fsgid,
12789 +       error = XFS_QM_DQVOPALLOC(mp, dp,
12790 +                       current_fsuid(credp), current_fsgid(credp),
12791                         XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
12792         if (error)
12793                 goto std_return;
12794 @@ -3456,7 +3477,8 @@
12795         /*
12796          * Make sure that we have allocated dquot(s) on disk.
12797          */
12798 -       error = XFS_QM_DQVOPALLOC(mp, dp, current->fsuid, current->fsgid,
12799 +       error = XFS_QM_DQVOPALLOC(mp, dp,
12800 +                       current_fsuid(credp), current_fsgid(credp),
12801                         XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
12802         if (error)
12803                 goto std_return;
12804 @@ -3743,7 +3765,14 @@
12805                 return;
12806         ip = XFS_BHVTOI(bdp);
12807         if (locktype == VRWLOCK_WRITE) {
12808 -               xfs_iunlock (ip, XFS_IOLOCK_EXCL);
12809 +               /*
12810 +                * In the write case, we may have added a new entry to
12811 +                * the reference cache.  This might store a pointer to
12812 +                * an inode to be released in this inode.  If it is there,
12813 +                * clear the pointer and release the inode after unlocking
12814 +                * this one.
12815 +                */
12816 +               xfs_refcache_iunlock(ip, XFS_IOLOCK_EXCL);
12817         } else {
12818                 ASSERT((locktype == VRWLOCK_READ) ||
12819                        (locktype == VRWLOCK_WRITE_DIRECT));
12820 @@ -4738,7 +4767,9 @@
12821         BHV_IDENTITY_INIT(VN_BHV_XFS,VNODE_POSITION_XFS),
12822         .vop_open               = xfs_open,
12823         .vop_read               = xfs_read,
12824 +#ifdef HAVE_SENDFILE
12825         .vop_sendfile           = xfs_sendfile,
12826 +#endif
12827         .vop_write              = xfs_write,
12828         .vop_ioctl              = xfs_ioctl,
12829         .vop_getattr            = xfs_getattr,
This page took 0.954659 seconds and 3 git commands to generate.