]> git.pld-linux.org Git - packages/kernel.git/blob - linux-2.6-xfs-cvs-20040102.patch
- added description of djurban's branch
[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 @@ -1395,7 +1510,6 @@
2829                         break;
2830  
2831                 offset = 0;
2832 -
2833                 sector += nbytes >> BBSHIFT;
2834                 size -= nbytes;
2835                 total_nr_pages--;
2836 @@ -1403,15 +1517,11 @@
2837  
2838  submit_io:
2839         if (likely(bio->bi_size)) {
2840 -               if (pb->pb_flags & PBF_READ) {
2841 -                       submit_bio(READ, bio);
2842 -               } else {
2843 -                       submit_bio(WRITE, bio);
2844 -               }
2845 -
2846 +               submit_bio((pb->pb_flags & PBF_READ) ? READ : WRITE, bio);
2847                 if (size)
2848                         goto next_chunk;
2849         } else {
2850 +               bio_put(bio);
2851                 pagebuf_ioerror(pb, EIO);
2852         }
2853  
2854 @@ -1444,7 +1554,7 @@
2855  pagebuf_iorequest(                     /* start real I/O               */
2856         page_buf_t              *pb)    /* buffer to convey to device   */
2857  {
2858 -       PB_TRACE(pb, PB_TRACE_REC(ioreq), 0);
2859 +       PB_TRACE(pb, "iorequest", 0);
2860  
2861         if (pb->pb_flags & PBF_DELWRI) {
2862                 pagebuf_delwri_queue(pb, 1);
2863 @@ -1480,11 +1590,11 @@
2864  pagebuf_iowait(
2865         page_buf_t              *pb)
2866  {
2867 -       PB_TRACE(pb, PB_TRACE_REC(iowait), 0);
2868 +       PB_TRACE(pb, "iowait", 0);
2869         if (atomic_read(&pb->pb_io_remaining))
2870                 blk_run_queues();
2871         down(&pb->pb_iodonesema);
2872 -       PB_TRACE(pb, PB_TRACE_REC(iowaited), (int)pb->pb_error);
2873 +       PB_TRACE(pb, "iowaited", (long)pb->pb_error);
2874         return pb->pb_error;
2875  }
2876  
2877 @@ -1575,7 +1685,7 @@
2878         page_buf_t              *pb,
2879         int                     unlock)
2880  {
2881 -       PB_TRACE(pb, PB_TRACE_REC(delwri_q), unlock);
2882 +       PB_TRACE(pb, "delwri_q", (long)unlock);
2883         spin_lock(&pbd_delwrite_lock);
2884         /* If already in the queue, dequeue and place at tail */
2885         if (!list_empty(&pb->pb_list)) {
2886 @@ -1598,7 +1708,7 @@
2887  pagebuf_delwri_dequeue(
2888         page_buf_t              *pb)
2889  {
2890 -       PB_TRACE(pb, PB_TRACE_REC(delwri_uq), 0);
2891 +       PB_TRACE(pb, "delwri_uq", 0);
2892         spin_lock(&pbd_delwrite_lock);
2893         list_del_init(&pb->pb_list);
2894         pb->pb_flags &= ~PBF_DELWRI;
2895 @@ -1665,7 +1775,7 @@
2896                 list_for_each_safe(curr, next, &pbd_delwrite_queue) {
2897                         pb = list_entry(curr, page_buf_t, pb_list);
2898  
2899 -                       PB_TRACE(pb, PB_TRACE_REC(walkq1), pagebuf_ispin(pb));
2900 +                       PB_TRACE(pb, "walkq1", (long)pagebuf_ispin(pb));
2901  
2902                         if ((pb->pb_flags & PBF_DELWRI) && !pagebuf_ispin(pb) &&
2903                             (((pb->pb_flags & _PBF_LOCKABLE) == 0) ||
2904 @@ -1738,7 +1848,7 @@
2905                         continue;
2906                 }
2907  
2908 -               PB_TRACE(pb, PB_TRACE_REC(walkq2), pagebuf_ispin(pb));
2909 +               PB_TRACE(pb, "walkq2", (long)pagebuf_ispin(pb));
2910                 if (pagebuf_ispin(pb)) {
2911                         pincount++;
2912                         continue;
2913 @@ -1839,7 +1949,7 @@
2914         int                     c, ret;
2915         int                     *valp = ctl->data;
2916  
2917 -       ret = proc_doulongvec_minmax(ctl, write, filp, buffer, lenp);
2918 +       ret = proc_dointvec_minmax(ctl, write, filp, buffer, lenp);
2919  
2920         if (!ret && write && *valp) {
2921                 printk("XFS Clearing pbstats\n");
2922 @@ -1960,11 +2070,7 @@
2923         }
2924  
2925  #ifdef PAGEBUF_TRACE
2926 -       pb_trace.buf = (pagebuf_trace_t *)kmalloc(
2927 -                       PB_TRACE_BUFSIZE * sizeof(pagebuf_trace_t), GFP_KERNEL);
2928 -       memset(pb_trace.buf, 0, PB_TRACE_BUFSIZE * sizeof(pagebuf_trace_t));
2929 -       pb_trace.start = 0;
2930 -       pb_trace.end = PB_TRACE_BUFSIZE - 1;
2931 +       pagebuf_trace_buf = ktrace_alloc(PAGEBUF_TRACE_SIZE, KM_SLEEP);
2932  #endif
2933  
2934         pagebuf_daemon_start();
2935 @@ -1996,3 +2102,6 @@
2936   *     Module management (for kernel debugger module)
2937   */
2938  EXPORT_SYMBOL(pagebuf_offset);
2939 +#ifdef DEBUG
2940 +EXPORT_SYMBOL(pbd_delwrite_queue);
2941 +#endif
2942 diff -urN linux.org/fs/xfs/pagebuf/page_buf.h linux/fs/xfs/pagebuf/page_buf.h
2943 --- linux.org/fs/xfs/pagebuf/page_buf.h 2003-12-31 05:47:38.000000000 +0100
2944 +++ linux/fs/xfs/pagebuf/page_buf.h     2004-01-02 04:21:44.000000000 +0100
2945 @@ -1,5 +1,5 @@
2946  /*
2947 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
2948 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
2949   *
2950   * This program is free software; you can redistribute it and/or modify it
2951   * under the terms of version 2 of the GNU General Public License as
2952 @@ -48,11 +48,6 @@
2953  #include <linux/uio.h>
2954  
2955  /*
2956 - * Turn this on to get pagebuf lock ownership
2957 -#define PAGEBUF_LOCK_TRACKING
2958 -*/
2959 -
2960 -/*
2961   *     Base types
2962   */
2963  
2964 @@ -61,8 +56,6 @@
2965  
2966  #define PAGE_BUF_DADDR_NULL ((page_buf_daddr_t) (-1LL))
2967  
2968 -typedef size_t page_buf_dsize_t;               /* size of buffer in blocks */
2969 -
2970  #define page_buf_ctob(pp)      ((pp) * PAGE_CACHE_SIZE)
2971  #define page_buf_btoc(dd)      (((dd) + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT)
2972  #define page_buf_btoct(dd)     ((dd) >> PAGE_CACHE_SHIFT)
2973 @@ -74,29 +67,6 @@
2974         PBRW_ZERO = 3                   /* Zero target memory */
2975  } page_buf_rw_t;
2976  
2977 -typedef enum {                         /* pbm_flags values */
2978 -       PBMF_EOF =              0x01,   /* mapping contains EOF         */
2979 -       PBMF_HOLE =             0x02,   /* mapping covers a hole        */
2980 -       PBMF_DELAY =            0x04,   /* mapping covers delalloc region  */
2981 -       PBMF_UNWRITTEN =        0x20,   /* mapping covers allocated     */
2982 -                                       /* but uninitialized file data  */
2983 -       PBMF_NEW =              0x40    /* just allocated               */
2984 -} bmap_flags_t;
2985 -
2986 -typedef enum {
2987 -       /* base extent manipulation calls */
2988 -       BMAP_READ = (1 << 0),           /* read extents */
2989 -       BMAP_WRITE = (1 << 1),          /* create extents */
2990 -       BMAP_ALLOCATE = (1 << 2),       /* delayed allocate to real extents */
2991 -       BMAP_UNWRITTEN  = (1 << 3),     /* unwritten extents to real extents */
2992 -       /* modifiers */
2993 -       BMAP_IGNSTATE = (1 << 4),       /* ignore unwritten state on read */
2994 -       BMAP_DIRECT = (1 << 5),         /* direct instead of buffered write */
2995 -       BMAP_MMAP = (1 << 6),           /* allocate for mmap write */
2996 -       BMAP_SYNC = (1 << 7),           /* sync write */
2997 -       BMAP_TRYLOCK = (1 << 8),        /* non-blocking request */
2998 -       BMAP_DEVICE = (1 << 9),         /* we only want to know the device */
2999 -} bmapi_flags_t;
3000  
3001  typedef enum page_buf_flags_e {                /* pb_flags values */
3002         PBF_READ = (1 << 0),    /* buffer intended for reading from device */
3003 @@ -123,12 +93,13 @@
3004         _PBF_PRIVATE_BH = (1 << 17), /* do not use public buffer heads     */
3005         _PBF_ALL_PAGES_MAPPED = (1 << 18), /* all pages in range mapped    */
3006         _PBF_ADDR_ALLOCATED = (1 << 19), /* pb_addr space was allocated    */
3007 -       _PBF_MEM_ALLOCATED = (1 << 20), /* pb_mem+underlying pages alloc'd */
3008 +       _PBF_MEM_ALLOCATED = (1 << 20), /* underlying pages are allocated  */
3009 +       _PBF_MEM_SLAB = (1 << 21), /* underlying pages are slab allocated  */
3010  
3011 -       PBF_FORCEIO = (1 << 21),
3012 -       PBF_FLUSH = (1 << 22),  /* flush disk write cache                  */
3013 -       PBF_READ_AHEAD = (1 << 23),
3014 -       PBF_RUN_QUEUES = (1 << 24), /* run block device task queue         */
3015 +       PBF_FORCEIO = (1 << 22), /* ignore any cache state                 */
3016 +       PBF_FLUSH = (1 << 23),  /* flush disk write cache                  */
3017 +       PBF_READ_AHEAD = (1 << 24), /* asynchronous read-ahead             */
3018 +       PBF_RUN_QUEUES = (1 << 25), /* run block device task queue         */
3019  
3020  } page_buf_flags_t;
3021  
3022 @@ -146,36 +117,6 @@
3023  } pb_target_t;
3024  
3025  /*
3026 - *     page_buf_bmap_t:  File system I/O map
3027 - *
3028 - * The pbm_bn, pbm_offset and pbm_length fields are expressed in disk blocks.
3029 - * The pbm_length field specifies the size of the underlying backing store
3030 - * for the particular mapping.
3031 - *
3032 - * The pbm_bsize, pbm_size and pbm_delta fields are in bytes and indicate
3033 - * the size of the mapping, the number of bytes that are valid to access
3034 - * (read or write), and the offset into the mapping, given the offset
3035 - * supplied to the file I/O map routine.  pbm_delta is the offset of the
3036 - * desired data from the beginning of the mapping.
3037 - *
3038 - * When a request is made to read beyond the logical end of the object,
3039 - * pbm_size may be set to 0, but pbm_offset and pbm_length should be set to
3040 - * the actual amount of underlying storage that has been allocated, if any.
3041 - */
3042 -
3043 -typedef struct page_buf_bmap_s {
3044 -       page_buf_daddr_t pbm_bn;        /* block number in file system      */
3045 -       pb_target_t     *pbm_target;    /* device to do I/O to              */
3046 -       loff_t          pbm_offset;     /* byte offset of mapping in file   */
3047 -       size_t          pbm_delta;      /* offset of request into bmap      */
3048 -       size_t          pbm_bsize;      /* size of this mapping in bytes    */
3049 -       bmap_flags_t    pbm_flags;      /* options flags for mapping        */
3050 -} page_buf_bmap_t;
3051 -
3052 -typedef page_buf_bmap_t pb_bmap_t;
3053 -
3054 -
3055 -/*
3056   *     page_buf_t:  Buffer structure for page cache-based buffers
3057   *
3058   * This buffer structure is used by the page cache buffer management routines
3059 @@ -381,4 +322,19 @@
3060  extern int pagebuf_init(void);
3061  extern void pagebuf_terminate(void);
3062  
3063 +
3064 +#ifdef PAGEBUF_TRACE
3065 +extern ktrace_t *pagebuf_trace_buf;
3066 +extern void pagebuf_trace(
3067 +               page_buf_t *,           /* buffer being traced          */
3068 +               char *,                 /* description of operation     */
3069 +               void *,                 /* arbitrary diagnostic value   */
3070 +               void *);                /* return address               */
3071 +#else
3072 +# define pagebuf_trace(pb, id, ptr, ra)        do { } while (0)
3073 +#endif
3074 +
3075 +#define pagebuf_target_name(target)    \
3076 +       ({ char __b[BDEVNAME_SIZE]; bdevname((target)->pbr_bdev, __b); __b; })
3077 +
3078  #endif /* __PAGE_BUF_H__ */
3079 diff -urN linux.org/fs/xfs/pagebuf/page_buf_internal.h linux/fs/xfs/pagebuf/page_buf_internal.h
3080 --- linux.org/fs/xfs/pagebuf/page_buf_internal.h        2003-12-31 05:47:14.000000000 +0100
3081 +++ linux/fs/xfs/pagebuf/page_buf_internal.h    1970-01-01 01:00:00.000000000 +0100
3082 @@ -1,134 +0,0 @@
3083 -/*
3084 - * Copyright (c) 2002 Silicon Graphics, Inc.  All Rights Reserved.
3085 - *
3086 - * This program is free software; you can redistribute it and/or modify it
3087 - * under the terms of version 2 of the GNU General Public License as
3088 - * published by the Free Software Foundation.
3089 - *
3090 - * This program is distributed in the hope that it would be useful, but
3091 - * WITHOUT ANY WARRANTY; without even the implied warranty of
3092 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
3093 - *
3094 - * Further, this software is distributed without any warranty that it is
3095 - * free of the rightful claim of any third person regarding infringement
3096 - * or the like.  Any license provided herein, whether implied or
3097 - * otherwise, applies only to this software file.  Patent licenses, if
3098 - * any, provided herein do not apply to combinations of this program with
3099 - * other software, or any other product whatsoever.
3100 - *
3101 - * You should have received a copy of the GNU General Public License along
3102 - * with this program; if not, write the Free Software Foundation, Inc., 59
3103 - * Temple Place - Suite 330, Boston MA 02111-1307, USA.
3104 - *
3105 - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
3106 - * Mountain View, CA  94043, or:
3107 - *
3108 - * http://www.sgi.com
3109 - *
3110 - * For further information regarding this notice, see:
3111 - *
3112 - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
3113 - */
3114 -
3115 -/*
3116 - * Written by Steve Lord at SGI
3117 - */
3118 -
3119 -#ifndef __PAGE_BUF_PRIVATE_H__
3120 -#define __PAGE_BUF_PRIVATE_H__
3121 -
3122 -#include <linux/percpu.h>
3123 -#include "page_buf.h"
3124 -
3125 -#define _PAGE_BUF_INTERNAL_
3126 -#define PB_DEFINE_TRACES
3127 -#include "page_buf_trace.h"
3128 -
3129 -#ifdef PAGEBUF_LOCK_TRACKING
3130 -#define PB_SET_OWNER(pb)       (pb->pb_last_holder = current->pid)
3131 -#define PB_CLEAR_OWNER(pb)     (pb->pb_last_holder = -1)
3132 -#define PB_GET_OWNER(pb)       (pb->pb_last_holder)
3133 -#else
3134 -#define PB_SET_OWNER(pb)
3135 -#define PB_CLEAR_OWNER(pb)
3136 -#define PB_GET_OWNER(pb)
3137 -#endif /* PAGEBUF_LOCK_TRACKING */
3138 -
3139 -/* Tracing utilities for pagebuf */
3140 -typedef struct {
3141 -       int                     event;
3142 -       unsigned long           pb;
3143 -       page_buf_flags_t        flags;
3144 -       unsigned short          hold;
3145 -       unsigned short          lock_value;
3146 -       void                    *task;
3147 -       void                    *misc;
3148 -       void                    *ra;
3149 -       loff_t                  offset;
3150 -       size_t                  size;
3151 -} pagebuf_trace_t;
3152 -
3153 -struct pagebuf_trace_buf {
3154 -       pagebuf_trace_t         *buf;
3155 -       volatile int            start;
3156 -       volatile int            end;
3157 -};
3158 -
3159 -#define PB_TRACE_BUFSIZE       1024
3160 -#define CIRC_INC(i)     (((i) + 1) & (PB_TRACE_BUFSIZE - 1))
3161 -
3162 -/*
3163 - * Tunable pagebuf parameters
3164 - */
3165 -
3166 -typedef struct pb_sysctl_val {
3167 -       int min;
3168 -       int val;
3169 -       int max;
3170 -} pb_sysctl_val_t;
3171 -
3172 -typedef struct pagebuf_param {
3173 -       pb_sysctl_val_t flush_interval; /* interval between runs of the
3174 -                                        * delwri flush daemon.  */
3175 -       pb_sysctl_val_t age_buffer;     /* time for buffer to age before
3176 -                                        * we flush it.  */
3177 -       pb_sysctl_val_t stats_clear;    /* clear the pagebuf stats */
3178 -       pb_sysctl_val_t debug;          /* debug tracing on or off */
3179 -} pagebuf_param_t;
3180 -
3181 -enum {
3182 -       PB_FLUSH_INT = 1,
3183 -       PB_FLUSH_AGE = 2,
3184 -       PB_STATS_CLEAR = 3,
3185 -       PB_DEBUG = 4
3186 -};
3187 -
3188 -extern pagebuf_param_t pb_params;
3189 -
3190 -/*
3191 - * Pagebuf statistics
3192 - */
3193 -
3194 -struct pbstats {
3195 -       u_int32_t       pb_get;
3196 -       u_int32_t       pb_create;
3197 -       u_int32_t       pb_get_locked;
3198 -       u_int32_t       pb_get_locked_waited;
3199 -       u_int32_t       pb_busy_locked;
3200 -       u_int32_t       pb_miss_locked;
3201 -       u_int32_t       pb_page_retries;
3202 -       u_int32_t       pb_page_found;
3203 -       u_int32_t       pb_get_read;
3204 -};
3205 -
3206 -DECLARE_PER_CPU(struct pbstats, pbstats);
3207 -
3208 -/* We don't disable preempt, not too worried about poking the
3209 - * wrong cpu's stat for now */
3210 -#define PB_STATS_INC(count)    (__get_cpu_var(pbstats).count++)
3211 -
3212 -#ifndef STATIC
3213 -# define STATIC        static
3214 -#endif
3215 -
3216 -#endif /* __PAGE_BUF_PRIVATE_H__ */
3217 diff -urN linux.org/fs/xfs/pagebuf/page_buf_locking.c linux/fs/xfs/pagebuf/page_buf_locking.c
3218 --- linux.org/fs/xfs/pagebuf/page_buf_locking.c 2003-12-31 05:47:32.000000000 +0100
3219 +++ linux/fs/xfs/pagebuf/page_buf_locking.c     1970-01-01 01:00:00.000000000 +0100
3220 @@ -1,139 +0,0 @@
3221 -/*
3222 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
3223 - *
3224 - * This program is free software; you can redistribute it and/or modify it
3225 - * under the terms of version 2 of the GNU General Public License as
3226 - * published by the Free Software Foundation.
3227 - *
3228 - * This program is distributed in the hope that it would be useful, but
3229 - * WITHOUT ANY WARRANTY; without even the implied warranty of
3230 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
3231 - *
3232 - * Further, this software is distributed without any warranty that it is
3233 - * free of the rightful claim of any third person regarding infringement
3234 - * or the like.  Any license provided herein, whether implied or
3235 - * otherwise, applies only to this software file.  Patent licenses, if
3236 - * any, provided herein do not apply to combinations of this program with
3237 - * other software, or any other product whatsoever.
3238 - *
3239 - * You should have received a copy of the GNU General Public License along
3240 - * with this program; if not, write the Free Software Foundation, Inc., 59
3241 - * Temple Place - Suite 330, Boston MA 02111-1307, USA.
3242 - *
3243 - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
3244 - * Mountain View, CA  94043, or:
3245 - *
3246 - * http://www.sgi.com
3247 - *
3248 - * For further information regarding this notice, see:
3249 - *
3250 - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
3251 - */
3252 -
3253 -/*
3254 - *     page_buf_locking.c
3255 - *
3256 - *     The page_buf module provides an abstract buffer cache model on top of
3257 - *     the Linux page cache.  Cached metadata blocks for a file system are
3258 - *     hashed to the inode for the block device.  The page_buf module
3259 - *     assembles buffer (page_buf_t) objects on demand to aggregate such
3260 - *     cached pages for I/O.  The page_buf_locking module adds support for
3261 - *     locking such page buffers.
3262 - *
3263 - *      Written by Steve Lord at SGI
3264 - *
3265 - */
3266 -
3267 -#include <linux/stddef.h>
3268 -#include <linux/errno.h>
3269 -#include <linux/slab.h>
3270 -#include <linux/bitops.h>
3271 -#include <linux/string.h>
3272 -#include <linux/pagemap.h>
3273 -#include <linux/init.h>
3274 -#include <linux/major.h>
3275 -
3276 -#include <support/debug.h>
3277 -
3278 -#include "page_buf_internal.h"
3279 -
3280 -/*
3281 - *     pagebuf_cond_lock
3282 - *
3283 - *     pagebuf_cond_lock locks a buffer object, if it is not already locked.
3284 - *     Note that this in no way
3285 - *     locks the underlying pages, so it is only useful for synchronizing
3286 - *     concurrent use of page buffer objects, not for synchronizing independent
3287 - *     access to the underlying pages.
3288 - */
3289 -int
3290 -pagebuf_cond_lock(                     /* lock buffer, if not locked   */
3291 -                                       /* returns -EBUSY if locked)    */
3292 -       page_buf_t              *pb)
3293 -{
3294 -       int                     locked;
3295 -
3296 -       ASSERT(pb->pb_flags & _PBF_LOCKABLE);
3297 -
3298 -       locked = down_trylock(&pb->pb_sema) == 0;
3299 -       if (locked) {
3300 -               PB_SET_OWNER(pb);
3301 -       }
3302 -
3303 -       PB_TRACE(pb, PB_TRACE_REC(condlck), locked);
3304 -
3305 -       return(locked ? 0 : -EBUSY);
3306 -}
3307 -
3308 -/*
3309 - *     pagebuf_lock_value
3310 - *
3311 - *     Return lock value for a pagebuf
3312 - */
3313 -int
3314 -pagebuf_lock_value(
3315 -       page_buf_t              *pb)
3316 -{
3317 -       ASSERT(pb->pb_flags & _PBF_LOCKABLE);
3318 -       return(atomic_read(&pb->pb_sema.count));
3319 -}
3320 -
3321 -/*
3322 - *     pagebuf_lock
3323 - *
3324 - *     pagebuf_lock locks a buffer object.  Note that this in no way
3325 - *     locks the underlying pages, so it is only useful for synchronizing
3326 - *     concurrent use of page buffer objects, not for synchronizing independent
3327 - *     access to the underlying pages.
3328 - */
3329 -int
3330 -pagebuf_lock(
3331 -       page_buf_t              *pb)
3332 -{
3333 -       ASSERT(pb->pb_flags & _PBF_LOCKABLE);
3334 -
3335 -       PB_TRACE(pb, PB_TRACE_REC(lock), 0);
3336 -       if (atomic_read(&pb->pb_io_remaining))
3337 -               blk_run_queues();
3338 -       down(&pb->pb_sema);
3339 -       PB_SET_OWNER(pb);
3340 -       PB_TRACE(pb, PB_TRACE_REC(locked), 0);
3341 -       return 0;
3342 -}
3343 -
3344 -/*
3345 - *     pagebuf_unlock
3346 - *
3347 - *     pagebuf_unlock releases the lock on the buffer object created by
3348 - *     pagebuf_lock or pagebuf_cond_lock (not any
3349 - *     pinning of underlying pages created by pagebuf_pin).
3350 - */
3351 -void
3352 -pagebuf_unlock(                                /* unlock buffer                */
3353 -       page_buf_t              *pb)    /* buffer to unlock             */
3354 -{
3355 -       ASSERT(pb->pb_flags & _PBF_LOCKABLE);
3356 -       PB_CLEAR_OWNER(pb);
3357 -       up(&pb->pb_sema);
3358 -       PB_TRACE(pb, PB_TRACE_REC(unlock), 0);
3359 -}
3360 diff -urN linux.org/fs/xfs/pagebuf/page_buf_trace.h linux/fs/xfs/pagebuf/page_buf_trace.h
3361 --- linux.org/fs/xfs/pagebuf/page_buf_trace.h   2003-12-31 05:47:37.000000000 +0100
3362 +++ linux/fs/xfs/pagebuf/page_buf_trace.h       1970-01-01 01:00:00.000000000 +0100
3363 @@ -1,95 +0,0 @@
3364 -/*
3365 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
3366 - *
3367 - * This program is free software; you can redistribute it and/or modify it
3368 - * under the terms of version 2 of the GNU General Public License as
3369 - * published by the Free Software Foundation.
3370 - *
3371 - * This program is distributed in the hope that it would be useful, but
3372 - * WITHOUT ANY WARRANTY; without even the implied warranty of
3373 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
3374 - *
3375 - * Further, this software is distributed without any warranty that it is
3376 - * free of the rightful claim of any third person regarding infringement
3377 - * or the like.  Any license provided herein, whether implied or
3378 - * otherwise, applies only to this software file.  Patent licenses, if
3379 - * any, provided herein do not apply to combinations of this program with
3380 - * other software, or any other product whatsoever.
3381 - *
3382 - * You should have received a copy of the GNU General Public License along
3383 - * with this program; if not, write the Free Software Foundation, Inc., 59
3384 - * Temple Place - Suite 330, Boston MA 02111-1307, USA.
3385 - *
3386 - * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
3387 - * Mountain View, CA  94043, or:
3388 - *
3389 - * http://www.sgi.com
3390 - *
3391 - * For further information regarding this notice, see:
3392 - *
3393 - * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
3394 - */
3395 -
3396 -#ifndef __PAGEBUF_TRACE__
3397 -#define __PAGEBUF_TRACE__
3398 -
3399 -#ifdef PB_DEFINE_TRACES
3400 -#define PB_TRACE_START typedef enum {
3401 -#define PB_TRACE_REC(x)        pb_trace_point_##x
3402 -#define PB_TRACE_END   } pb_trace_var_t;
3403 -#else
3404 -#define PB_TRACE_START static char     *event_names[] = {
3405 -#define PB_TRACE_REC(x)        #x
3406 -#define PB_TRACE_END   };
3407 -#endif
3408 -
3409 -PB_TRACE_START
3410 -PB_TRACE_REC(get),
3411 -PB_TRACE_REC(get_obj),
3412 -PB_TRACE_REC(free_obj),
3413 -PB_TRACE_REC(look_pg),
3414 -PB_TRACE_REC(get_read),
3415 -PB_TRACE_REC(no_daddr),
3416 -PB_TRACE_REC(hold),
3417 -PB_TRACE_REC(rele),
3418 -PB_TRACE_REC(done),
3419 -PB_TRACE_REC(ioerror),
3420 -PB_TRACE_REC(iostart),
3421 -PB_TRACE_REC(end_io),
3422 -PB_TRACE_REC(do_io),
3423 -PB_TRACE_REC(ioreq),
3424 -PB_TRACE_REC(iowait),
3425 -PB_TRACE_REC(iowaited),
3426 -PB_TRACE_REC(free_lk),
3427 -PB_TRACE_REC(freed_l),
3428 -PB_TRACE_REC(cmp),
3429 -PB_TRACE_REC(get_lk),
3430 -PB_TRACE_REC(got_lk),
3431 -PB_TRACE_REC(skip),
3432 -PB_TRACE_REC(lock),
3433 -PB_TRACE_REC(locked),
3434 -PB_TRACE_REC(unlock),
3435 -PB_TRACE_REC(avl_ret),
3436 -PB_TRACE_REC(condlck),
3437 -PB_TRACE_REC(avl_ins),
3438 -PB_TRACE_REC(walkq1),
3439 -PB_TRACE_REC(walkq2),
3440 -PB_TRACE_REC(walkq3),
3441 -PB_TRACE_REC(delwri_q),
3442 -PB_TRACE_REC(delwri_uq),
3443 -PB_TRACE_REC(pin),
3444 -PB_TRACE_REC(unpin),
3445 -PB_TRACE_REC(file_write),
3446 -PB_TRACE_REC(external),
3447 -PB_TRACE_END
3448 -
3449 -extern void pb_trace_func(page_buf_t *, int, void *, void *);
3450 -#ifdef PAGEBUF_TRACE
3451 -# define PB_TRACE(pb, event, misc)             \
3452 -       pb_trace_func(pb, event, (void *) misc, \
3453 -                       (void *)__builtin_return_address(0))
3454 -#else
3455 -# define PB_TRACE(pb, event, misc)     do { } while (0)
3456 -#endif
3457 -
3458 -#endif /* __PAGEBUF_TRACE__ */
3459 diff -urN linux.org/fs/xfs/quota/xfs_dquot.c linux/fs/xfs/quota/xfs_dquot.c
3460 --- linux.org/fs/xfs/quota/xfs_dquot.c  2003-12-31 05:47:13.000000000 +0100
3461 +++ linux/fs/xfs/quota/xfs_dquot.c      2004-01-02 04:21:44.000000000 +0100
3462 @@ -124,7 +124,7 @@
3463                 initnsema(&dqp->q_flock, 1, "fdq");
3464                 sv_init(&dqp->q_pinwait, SV_DEFAULT, "pdq");
3465  
3466 -#ifdef DQUOT_TRACING
3467 +#ifdef XFS_DQUOT_TRACE
3468                 dqp->q_trace = ktrace_alloc(DQUOT_TRACE_SIZE, KM_SLEEP);
3469                 xfs_dqtrace_entry(dqp, "DQINIT");
3470  #endif
3471 @@ -148,7 +148,7 @@
3472                  dqp->q_hash = 0;
3473                  ASSERT(dqp->dq_flnext == dqp->dq_flprev);
3474  
3475 -#ifdef DQUOT_TRACING
3476 +#ifdef XFS_DQUOT_TRACE
3477                  ASSERT(dqp->q_trace);
3478                  xfs_dqtrace_entry(dqp, "DQRECLAIMED_INIT");
3479  #endif
3480 @@ -173,7 +173,7 @@
3481         freesema(&dqp->q_flock);
3482         sv_destroy(&dqp->q_pinwait);
3483  
3484 -#ifdef DQUOT_TRACING
3485 +#ifdef XFS_DQUOT_TRACE
3486         if (dqp->q_trace)
3487              ktrace_free(dqp->q_trace);
3488         dqp->q_trace = NULL;
3489 @@ -201,20 +201,20 @@
3490  }
3491  
3492  
3493 -#ifdef DQUOT_TRACING
3494 +#ifdef XFS_DQUOT_TRACE
3495  /*
3496   * Dquot tracing for debugging.
3497   */
3498  /* ARGSUSED */
3499  void
3500 -xfs_dqtrace_entry__(
3501 -       xfs_dquot_t *dqp,
3502 -       char *func,
3503 -       void *retaddr,
3504 -       xfs_inode_t *ip)
3505 +__xfs_dqtrace_entry(
3506 +       xfs_dquot_t     *dqp,
3507 +       char            *func,
3508 +       void            *retaddr,
3509 +       xfs_inode_t     *ip)
3510  {
3511 -       xfs_dquot_t *udqp = NULL;
3512 -       int ino;
3513 +       xfs_dquot_t     *udqp = NULL;
3514 +       xfs_ino_t       ino = 0;
3515  
3516         ASSERT(dqp->q_trace);
3517         if (ip) {
3518 @@ -227,13 +227,19 @@
3519                      (void *)(__psint_t)dqp->q_nrefs,
3520                      (void *)(__psint_t)dqp->dq_flags,
3521                      (void *)(__psint_t)dqp->q_res_bcount,
3522 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_bcount, ARCH_CONVERT),
3523 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_icount, ARCH_CONVERT),
3524 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_hardlimit, ARCH_CONVERT),
3525 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_softlimit, ARCH_CONVERT),
3526 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_hardlimit, ARCH_CONVERT),
3527 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_softlimit, ARCH_CONVERT),
3528 -                    (void *)(__psint_t)INT_GET(dqp->q_core.d_id, ARCH_CONVERT), /* 11 */
3529 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_bcount,
3530 +                                               ARCH_CONVERT),
3531 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_icount,
3532 +                                               ARCH_CONVERT),
3533 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_hardlimit,
3534 +                                               ARCH_CONVERT),
3535 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_blk_softlimit,
3536 +                                               ARCH_CONVERT),
3537 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_hardlimit,
3538 +                                               ARCH_CONVERT),
3539 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_ino_softlimit,
3540 +                                               ARCH_CONVERT),
3541 +                    (void *)(__psint_t)INT_GET(dqp->q_core.d_id, ARCH_CONVERT),
3542                      (void *)(__psint_t)current_pid(),
3543                      (void *)(__psint_t)ino,
3544                      (void *)(__psint_t)retaddr,
3545 @@ -751,7 +757,6 @@
3546         }
3547  
3548         *O_dqpp = dqp;
3549 -       ASSERT(! XFS_DQ_IS_LOCKED(dqp));
3550         return (0);
3551  
3552   error0:
3553 @@ -1000,7 +1005,6 @@
3554         /*
3555          * Dquot lock comes after hashlock in the lock ordering
3556          */
3557 -       ASSERT(! XFS_DQ_IS_LOCKED(dqp));
3558         if (ip) {
3559                 xfs_ilock(ip, XFS_ILOCK_EXCL);
3560                 if (! XFS_IS_DQTYPE_ON(mp, type)) {
3561 @@ -1504,7 +1508,7 @@
3562          */
3563         ASSERT(XFS_DQ_IS_ON_FREELIST(dqp));
3564  
3565 -       dqp->q_mount = NULL;;
3566 +       dqp->q_mount = NULL;
3567         dqp->q_hash = NULL;
3568         dqp->dq_flags = XFS_DQ_INACTIVE;
3569         memset(&dqp->q_core, 0, sizeof(dqp->q_core));
3570 diff -urN linux.org/fs/xfs/quota/xfs_dquot.h linux/fs/xfs/quota/xfs_dquot.h
3571 --- linux.org/fs/xfs/quota/xfs_dquot.h  2003-12-31 05:48:42.000000000 +0100
3572 +++ linux/fs/xfs/quota/xfs_dquot.h      2004-01-02 04:21:44.000000000 +0100
3573 @@ -99,7 +99,7 @@
3574         sema_t           q_flock;       /* flush lock */
3575         uint             q_pincount;    /* pin count for this dquot */
3576         sv_t             q_pinwait;     /* sync var for pinning */
3577 -#ifdef DQUOT_TRACING
3578 +#ifdef XFS_DQUOT_TRACE
3579         struct ktrace   *q_trace;       /* trace header structure */
3580  #endif
3581  } xfs_dquot_t;
3582 @@ -175,23 +175,25 @@
3583  #define XFS_IS_THIS_QUOTA_OFF(d) (! (XFS_QM_ISUDQ(d) ? \
3584                                      (XFS_IS_UQUOTA_ON((d)->q_mount)) : \
3585                                      (XFS_IS_GQUOTA_ON((d)->q_mount))))
3586 -#ifdef DQUOT_TRACING
3587 +
3588 +#ifdef XFS_DQUOT_TRACE
3589  /*
3590   * Dquot Tracing stuff.
3591   */
3592  #define DQUOT_TRACE_SIZE       64
3593  #define DQUOT_KTRACE_ENTRY     1
3594  
3595 +extern void            __xfs_dqtrace_entry(xfs_dquot_t *dqp, char *func,
3596 +                                           void *, xfs_inode_t *);
3597  #define xfs_dqtrace_entry_ino(a,b,ip) \
3598 -xfs_dqtrace_entry__((a), (b), (void*)__return_address, (ip))
3599 +               __xfs_dqtrace_entry((a), (b), (void*)__return_address, (ip))
3600  #define xfs_dqtrace_entry(a,b) \
3601 -xfs_dqtrace_entry__((a), (b), (void*)__return_address, NULL)
3602 -extern void            xfs_dqtrace_entry__(xfs_dquot_t *dqp, char *func,
3603 -                                           void *, xfs_inode_t *);
3604 +               __xfs_dqtrace_entry((a), (b), (void*)__return_address, NULL)
3605  #else
3606  #define xfs_dqtrace_entry(a,b)
3607  #define xfs_dqtrace_entry_ino(a,b,ip)
3608  #endif
3609 +
3610  #ifdef QUOTADEBUG
3611  extern void            xfs_qm_dqprint(xfs_dquot_t *);
3612  #else
3613 diff -urN linux.org/fs/xfs/quota/xfs_qm.c linux/fs/xfs/quota/xfs_qm.c
3614 --- linux.org/fs/xfs/quota/xfs_qm.c     2003-12-31 05:46:24.000000000 +0100
3615 +++ linux/fs/xfs/quota/xfs_qm.c 2004-01-02 04:21:44.000000000 +0100
3616 @@ -82,6 +82,7 @@
3617  
3618  kmem_zone_t    *qm_dqzone;
3619  kmem_zone_t    *qm_dqtrxzone;
3620 +kmem_shaker_t  xfs_qm_shaker;
3621  
3622  STATIC void    xfs_qm_list_init(xfs_dqlist_t *, char *, int);
3623  STATIC void    xfs_qm_list_destroy(xfs_dqlist_t *);
3624 @@ -112,8 +113,6 @@
3625  #define XQM_LIST_PRINT(l, NXT, title) do { } while (0)
3626  #endif
3627  
3628 -struct shrinker *xfs_qm_shrinker;
3629 -
3630  /*
3631   * Initialize the XQM structure.
3632   * Note that there is not one quota manager per file system.
3633 @@ -163,7 +162,7 @@
3634         } else
3635                 xqm->qm_dqzone = qm_dqzone;
3636  
3637 -       xfs_qm_shrinker = set_shrinker(DEFAULT_SEEKS, xfs_qm_shake);
3638 +       xfs_qm_shaker = kmem_shake_register(xfs_qm_shake);
3639  
3640         /*
3641          * The t_dqinfo portion of transactions.
3642 @@ -195,8 +194,7 @@
3643  
3644         ASSERT(xqm != NULL);
3645         ASSERT(xqm->qm_nrefs == 0);
3646 -
3647 -       remove_shrinker(xfs_qm_shrinker);
3648 +       kmem_shake_deregister(xfs_qm_shaker);
3649         hsize = xqm->qm_dqhashmask + 1;
3650         for (i = 0; i < hsize; i++) {
3651                 xfs_qm_list_destroy(&(xqm->qm_usr_dqhtable[i]));
3652 @@ -806,7 +804,6 @@
3653         ASSERT(XFS_DQ_IS_LOCKED(dqp));
3654         if (! dolock) {
3655                 xfs_dqunlock(dqp);
3656 -               ASSERT(!udqhint || !XFS_DQ_IS_LOCKED(udqhint));
3657                 goto done;
3658         }
3659         if (! udqhint)
3660 @@ -814,7 +811,6 @@
3661  
3662         ASSERT(udqhint);
3663         ASSERT(dolock);
3664 -       ASSERT(! XFS_DQ_IS_LOCKED(udqhint));
3665         ASSERT(XFS_DQ_IS_LOCKED(dqp));
3666         if (! xfs_qm_dqlock_nowait(udqhint)) {
3667                 xfs_dqunlock(dqp);
3668 @@ -826,14 +822,10 @@
3669         if (udqhint) {
3670                 if (dolock)
3671                         ASSERT(XFS_DQ_IS_LOCKED(udqhint));
3672 -               else
3673 -                       ASSERT(! XFS_DQ_IS_LOCKED(udqhint));
3674         }
3675         if (! error) {
3676                 if (dolock)
3677                         ASSERT(XFS_DQ_IS_LOCKED(dqp));
3678 -               else
3679 -                       ASSERT(! XFS_DQ_IS_LOCKED(dqp));
3680         }
3681  #endif
3682         return (error);
3683 @@ -860,9 +852,6 @@
3684         if (locked) {
3685                 ASSERT(XFS_DQ_IS_LOCKED(udq));
3686                 ASSERT(XFS_DQ_IS_LOCKED(gdq));
3687 -       } else {
3688 -               ASSERT(! XFS_DQ_IS_LOCKED(udq));
3689 -               ASSERT(! XFS_DQ_IS_LOCKED(gdq));
3690         }
3691  #endif
3692         if (! locked)
3693 @@ -890,15 +879,12 @@
3694                  */
3695                 xfs_qm_dqrele(tmp);
3696  
3697 -               ASSERT(! XFS_DQ_IS_LOCKED(udq));
3698 -               ASSERT(! XFS_DQ_IS_LOCKED(gdq));
3699                 xfs_dqlock(udq);
3700                 xfs_dqlock(gdq);
3701  
3702         } else {
3703                 ASSERT(XFS_DQ_IS_LOCKED(udq));
3704                 if (! locked) {
3705 -                       ASSERT(! XFS_DQ_IS_LOCKED(gdq));
3706                         xfs_dqlock(gdq);
3707                 }
3708         }
3709 @@ -1006,14 +992,10 @@
3710                 if (ip->i_udquot) {
3711                         if (flags & XFS_QMOPT_DQLOCK)
3712                                 ASSERT(XFS_DQ_IS_LOCKED(ip->i_udquot));
3713 -                       else
3714 -                               ASSERT(! XFS_DQ_IS_LOCKED(ip->i_udquot));
3715                 }
3716                 if (ip->i_gdquot) {
3717                         if (flags & XFS_QMOPT_DQLOCK)
3718                                 ASSERT(XFS_DQ_IS_LOCKED(ip->i_gdquot));
3719 -                       else
3720 -                               ASSERT(! XFS_DQ_IS_LOCKED(ip->i_gdquot));
3721                 }
3722                 if (XFS_IS_UQUOTA_ON(mp))
3723                         ASSERT(ip->i_udquot);
3724 @@ -1756,7 +1738,10 @@
3725         xfs_trans_t     *tp,            /* transaction pointer - NULL */
3726         xfs_ino_t       ino,            /* inode number to get data for */
3727         void            *buffer,        /* not used */
3728 +       int             ubsize,         /* not used */
3729 +       void            *private_data,  /* not used */
3730         xfs_daddr_t     bno,            /* starting block of inode cluster */
3731 +       int             *ubused,        /* not used */
3732         void            *dip,           /* on-disk inode pointer (not used) */
3733         int             *res)           /* result code value */
3734  {
3735 @@ -1920,7 +1905,7 @@
3736                  * adjusting the corresponding dquot counters in core.
3737                  */
3738                 if ((error = xfs_bulkstat(mp, NULL, &lastino, &count,
3739 -                                    xfs_qm_dqusage_adjust,
3740 +                                    xfs_qm_dqusage_adjust, NULL,
3741                                      structsz, NULL,
3742                                      BULKSTAT_FG_IGET|BULKSTAT_FG_VFSLOCKED,
3743                                      &done)))
3744 @@ -2091,7 +2076,7 @@
3745                         xfs_dqunlock(dqp);
3746                         xfs_qm_freelist_unlock(xfs_Gqm);
3747                         if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
3748 -                               goto out;
3749 +                               return (nreclaimed);
3750                         XQM_STATS_INC(xqmstats.xs_qm_dqwants);
3751                         goto tryagain;
3752                 }
3753 @@ -2166,7 +2151,7 @@
3754                         XFS_DQ_HASH_UNLOCK(hash);
3755                         xfs_qm_freelist_unlock(xfs_Gqm);
3756                         if (++restarts >= XFS_QM_RECLAIM_MAX_RESTARTS)
3757 -                               goto out;
3758 +                               return (nreclaimed);
3759                         goto tryagain;
3760                 }
3761                 xfs_dqtrace_entry(dqp, "DQSHAKE: UNLINKING");
3762 @@ -2191,14 +2176,12 @@
3763                 dqp = nextdqp;
3764         }
3765         xfs_qm_freelist_unlock(xfs_Gqm);
3766 - out:
3767 -       return nreclaimed;
3768 +       return (nreclaimed);
3769  }
3770  
3771  
3772  /*
3773 - * The shake manager routine called by shaked() when memory is
3774 - * running low.
3775 + * The kmem_shake interface is invoked when memory is running low.
3776   */
3777  /* ARGSUSED */
3778  STATIC int
3779 @@ -2206,10 +2189,10 @@
3780  {
3781         int     ndqused, nfree, n;
3782  
3783 -       if (!(gfp_mask & __GFP_WAIT))
3784 -               return 0;
3785 +       if (!kmem_shake_allow(gfp_mask))
3786 +               return (0);
3787         if (!xfs_Gqm)
3788 -               return 0;
3789 +               return (0);
3790  
3791         nfree = xfs_Gqm->qm_dqfreelist.qh_nelems; /* free dquots */
3792         /* incore dquots in all f/s's */
3793 @@ -2218,7 +2201,7 @@
3794         ASSERT(ndqused >= 0);
3795  
3796         if (nfree <= ndqused && nfree < ndquot)
3797 -               return 0;
3798 +               return (0);
3799  
3800         ndqused *= xfs_Gqm->qm_dqfree_ratio;    /* target # of free dquots */
3801         n = nfree - ndqused - ndquot;           /* # over target */
3802 diff -urN linux.org/fs/xfs/quota/xfs_qm_syscalls.c linux/fs/xfs/quota/xfs_qm_syscalls.c
3803 --- linux.org/fs/xfs/quota/xfs_qm_syscalls.c    2003-12-31 05:47:47.000000000 +0100
3804 +++ linux/fs/xfs/quota/xfs_qm_syscalls.c        2004-01-02 04:21:44.000000000 +0100
3805 @@ -1301,7 +1301,10 @@
3806         xfs_trans_t     *tp,            /* transaction pointer */
3807         xfs_ino_t       ino,            /* inode number to get data for */
3808         void            *buffer,        /* not used */
3809 +       int             ubsize,         /* not used */
3810 +       void            *private_data,  /* not used */
3811         xfs_daddr_t     bno,            /* starting block of inode cluster */
3812 +       int             *ubused,        /* not used */
3813         void            *dip,           /* not used */
3814         int             *res)           /* bulkstat result code */
3815  {
3816 @@ -1403,7 +1406,7 @@
3817                  * adjusting the corresponding dquot counters
3818                  */
3819                 if ((error = xfs_bulkstat(mp, NULL, &lastino, &count,
3820 -                                xfs_qm_internalqcheck_adjust,
3821 +                                xfs_qm_internalqcheck_adjust, NULL,
3822                                  0, NULL, BULKSTAT_FG_IGET, &done))) {
3823                         break;
3824                 }
3825 diff -urN linux.org/fs/xfs/quota/xfs_trans_dquot.c linux/fs/xfs/quota/xfs_trans_dquot.c
3826 --- linux.org/fs/xfs/quota/xfs_trans_dquot.c    2003-12-31 05:46:41.000000000 +0100
3827 +++ linux/fs/xfs/quota/xfs_trans_dquot.c        2004-01-02 04:21:44.000000000 +0100
3828 @@ -835,13 +835,6 @@
3829         ASSERT(ip->i_ino != mp->m_sb.sb_uquotino);
3830         ASSERT(ip->i_ino != mp->m_sb.sb_gquotino);
3831  
3832 -#ifdef QUOTADEBUG
3833 -       if (ip->i_udquot)
3834 -               ASSERT(! XFS_DQ_IS_LOCKED(ip->i_udquot));
3835 -       if (ip->i_gdquot)
3836 -               ASSERT(! XFS_DQ_IS_LOCKED(ip->i_gdquot));
3837 -#endif
3838 -
3839         ASSERT(XFS_ISLOCKED_INODE_EXCL(ip));
3840         ASSERT(XFS_IS_QUOTA_RUNNING(ip->i_mount));
3841         ASSERT((type & ~XFS_QMOPT_FORCE_RES) == XFS_TRANS_DQ_RES_RTBLKS ||
3842 diff -urN linux.org/fs/xfs/support/debug.h linux/fs/xfs/support/debug.h
3843 --- linux.org/fs/xfs/support/debug.h    2003-12-31 05:48:49.000000000 +0100
3844 +++ linux/fs/xfs/support/debug.h        2004-01-02 04:21:44.000000000 +0100
3845 @@ -44,6 +44,10 @@
3846  extern void icmn_err(int, char *, va_list);
3847  extern void cmn_err(int, char *, ...);
3848  
3849 +#ifndef STATIC
3850 +# define STATIC static
3851 +#endif
3852 +
3853  #ifdef DEBUG
3854  # ifdef lint
3855  #  define ASSERT(EX)   ((void)0) /* avoid "constant in conditional" babble */
3856 diff -urN linux.org/fs/xfs/support/kmem.h linux/fs/xfs/support/kmem.h
3857 --- linux.org/fs/xfs/support/kmem.h     2003-12-31 05:48:56.000000000 +0100
3858 +++ linux/fs/xfs/support/kmem.h 2004-01-02 04:21:44.000000000 +0100
3859 @@ -165,4 +165,25 @@
3860         kmem_cache_free(zone, ptr);
3861  }
3862  
3863 +typedef struct shrinker *kmem_shaker_t;
3864 +typedef int (*kmem_shake_func_t)(int, unsigned int);
3865 +
3866 +static __inline kmem_shaker_t
3867 +kmem_shake_register(kmem_shake_func_t sfunc)
3868 +{
3869 +       return set_shrinker(DEFAULT_SEEKS, sfunc);
3870 +}
3871 +
3872 +static __inline void
3873 +kmem_shake_deregister(kmem_shaker_t shrinker)
3874 +{
3875 +       remove_shrinker(shrinker);
3876 +}
3877 +
3878 +static __inline int
3879 +kmem_shake_allow(unsigned int gfp_mask)
3880 +{
3881 +       return (gfp_mask & __GFP_WAIT);
3882 +}
3883 +
3884  #endif /* __XFS_SUPPORT_KMEM_H__ */
3885 diff -urN linux.org/fs/xfs/support/ktrace.c linux/fs/xfs/support/ktrace.c
3886 --- linux.org/fs/xfs/support/ktrace.c   2003-12-31 05:47:09.000000000 +0100
3887 +++ linux/fs/xfs/support/ktrace.c       2004-01-02 04:21:44.000000000 +0100
3888 @@ -1,5 +1,5 @@
3889  /*
3890 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
3891 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
3892   *
3893   * This program is free software; you can redistribute it and/or modify it
3894   * under the terms of version 2 of the GNU General Public License as
3895 @@ -40,8 +40,6 @@
3896  #include "debug.h"
3897  #include "ktrace.h"
3898  
3899 -#if    (defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
3900 -
3901  static kmem_zone_t *ktrace_hdr_zone;
3902  static kmem_zone_t *ktrace_ent_zone;
3903  static int          ktrace_zentries;
3904 @@ -121,7 +119,6 @@
3905         ktp->kt_nentries = nentries;
3906         ktp->kt_index    = 0;
3907         ktp->kt_rollover = 0;
3908 -
3909         return ktp;
3910  }
3911  
3912 @@ -182,6 +179,7 @@
3913         void            *val15)
3914  {
3915         static lock_t   wrap_lock = SPIN_LOCK_UNLOCKED;
3916 +       unsigned long   flags;
3917         int             index;
3918         ktrace_entry_t  *ktep;
3919  
3920 @@ -190,11 +188,11 @@
3921         /*
3922          * Grab an entry by pushing the index up to the next one.
3923          */
3924 -       spin_lock(&wrap_lock);
3925 +       spin_lock_irqsave(&wrap_lock, flags);
3926         index = ktp->kt_index;
3927         if (++ktp->kt_index == ktp->kt_nentries)
3928                 ktp->kt_index = 0;
3929 -       spin_unlock(&wrap_lock);
3930 +       spin_unlock_irqrestore(&wrap_lock, flags);
3931  
3932         if (!ktp->kt_rollover && index == ktp->kt_nentries - 1)
3933                 ktp->kt_rollover = 1;
3934 @@ -235,7 +233,6 @@
3935         return (ktp->kt_rollover ? ktp->kt_nentries : ktp->kt_index);
3936  }
3937  
3938 -
3939  /*
3940   * ktrace_first()
3941   *
3942 @@ -276,7 +273,7 @@
3943         }
3944         return ktep;
3945  }
3946 -
3947 +EXPORT_SYMBOL(ktrace_first);
3948  
3949  /*
3950   * ktrace_next()
3951 @@ -311,11 +308,7 @@
3952  
3953         return ktep;
3954  }
3955 -
3956 -#if    (defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
3957 -EXPORT_SYMBOL(ktrace_first);
3958  EXPORT_SYMBOL(ktrace_next);
3959 -#endif
3960  
3961  /*
3962   * ktrace_skip()
3963 @@ -323,7 +316,6 @@
3964   * Skip the next "count" entries and return the entry after that.
3965   * Return NULL if this causes us to iterate past the beginning again.
3966   */
3967 -
3968  ktrace_entry_t *
3969  ktrace_skip(
3970         ktrace_t        *ktp,
3971 @@ -362,18 +354,3 @@
3972         }
3973         return ktep;
3974  }
3975 -
3976 -#else
3977 -
3978 -ktrace_t *
3979 -ktrace_alloc(int nentries, int sleep)
3980 -{
3981 -       /*
3982 -        * KM_SLEEP callers don't expect failure.
3983 -        */
3984 -       if (sleep & KM_SLEEP)
3985 -               panic("ktrace_alloc: NULL memory on KM_SLEEP request!");
3986 -
3987 -       return NULL;
3988 -}
3989 -#endif
3990 diff -urN linux.org/fs/xfs/support/ktrace.h linux/fs/xfs/support/ktrace.h
3991 --- linux.org/fs/xfs/support/ktrace.h   2003-12-31 05:47:26.000000000 +0100
3992 +++ linux/fs/xfs/support/ktrace.h       2004-01-02 04:21:44.000000000 +0100
3993 @@ -1,5 +1,5 @@
3994  /*
3995 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
3996 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
3997   *
3998   * This program is free software; you can redistribute it and/or modify it
3999   * under the terms of version 2 of the GNU General Public License as
4000 @@ -32,6 +32,7 @@
4001  #ifndef __XFS_SUPPORT_KTRACE_H__
4002  #define __XFS_SUPPORT_KTRACE_H__
4003  
4004 +#include <support/spin.h>
4005  
4006  /*
4007   * Trace buffer entry structure.
4008 @@ -59,16 +60,13 @@
4009         int             ks_index;       /* current index */
4010  } ktrace_snap_t;
4011  
4012 -/*
4013 - * Exported interfaces.
4014 - */
4015 -extern ktrace_t *ktrace_alloc(int, int);
4016  
4017 -#if    (defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
4018 +#ifdef CONFIG_XFS_TRACE
4019  
4020  extern void ktrace_init(int zentries);
4021  extern void ktrace_uninit(void);
4022  
4023 +extern ktrace_t *ktrace_alloc(int, int);
4024  extern void ktrace_free(ktrace_t *);
4025  
4026  extern void ktrace_enter(
4027 @@ -96,10 +94,8 @@
4028  extern ktrace_entry_t   *ktrace_skip(ktrace_t *, int, ktrace_snap_t *);
4029  
4030  #else
4031 +#define ktrace_init(x) do { } while (0)
4032 +#define ktrace_uninit()        do { } while (0)
4033 +#endif /* CONFIG_XFS_TRACE */
4034  
4035 -#define        ktrace_free(ktp)
4036 -#define        ktrace_enter(ktp,v0,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15)
4037 -
4038 -#endif
4039 -
4040 -#endif /* __XFS_SUPPORT_KTRACE_H__ */
4041 +#endif /* __XFS_SUPPORT_KTRACE_H__ */
4042 diff -urN linux.org/fs/xfs/support/qsort.c linux/fs/xfs/support/qsort.c
4043 --- linux.org/fs/xfs/support/qsort.c    2003-12-31 05:48:26.000000000 +0100
4044 +++ linux/fs/xfs/support/qsort.c        2004-01-02 04:21:44.000000000 +0100
4045 @@ -1,243 +1,155 @@
4046 -/* Copyright (C) 1991, 1992, 1996, 1997, 1999 Free Software Foundation, Inc.
4047 -   This file is part of the GNU C Library.
4048 -   Written by Douglas C. Schmidt (schmidt@ics.uci.edu).
4049 -
4050 -   The GNU C Library is free software; you can redistribute it and/or
4051 -   modify it under the terms of the GNU Lesser General Public
4052 -   License as published by the Free Software Foundation; either
4053 -   version 2.1 of the License, or (at your option) any later version.
4054 -
4055 -   The GNU C Library is distributed in the hope that it will be useful,
4056 -   but WITHOUT ANY WARRANTY; without even the implied warranty of
4057 -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4058 -   Lesser General Public License for more details.
4059 -
4060 -   You should have received a copy of the GNU Lesser General Public
4061 -   License along with the GNU C Library; if not, write to the Free
4062 -   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
4063 -   02111-1307 USA.  */
4064 -
4065 -/* If you consider tuning this algorithm, you should consult first:
4066 -   Engineering a sort function; Jon Bentley and M. Douglas McIlroy;
4067 -   Software - Practice and Experience; Vol. 23 (11), 1249-1265, 1993.  */
4068 +/*
4069 + * Copyright (c) 1992, 1993
4070 + *     The Regents of the University of California.  All rights reserved.
4071 + *
4072 + * Redistribution and use in source and binary forms, with or without
4073 + * modification, are permitted provided that the following conditions
4074 + * are met:
4075 + * 1. Redistributions of source code must retain the above copyright
4076 + *    notice, this list of conditions and the following disclaimer.
4077 + * 2. Redistributions in binary form must reproduce the above copyright
4078 + *    notice, this list of conditions and the following disclaimer in the
4079 + *    documentation and/or other materials provided with the distribution.
4080 + * 3. Neither the name of the University nor the names of its contributors
4081 + *    may be used to endorse or promote products derived from this software
4082 + *    without specific prior written permission.
4083 + *
4084 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
4085 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4086 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4087 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
4088 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
4089 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
4090 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
4091 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4092 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4093 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4094 + * SUCH DAMAGE.
4095 + */
4096  
4097  #include <linux/kernel.h>
4098  #include <linux/string.h>
4099  
4100 -/* Byte-wise swap two items of size SIZE. */
4101 -#define SWAP(a, b, size)                                                     \
4102 -  do                                                                         \
4103 -    {                                                                        \
4104 -      register size_t __size = (size);                                       \
4105 -      register char *__a = (a), *__b = (b);                                  \
4106 -      do                                                                     \
4107 -       {                                                                     \
4108 -         char __tmp = *__a;                                                  \
4109 -         *__a++ = *__b;                                                      \
4110 -         *__b++ = __tmp;                                                     \
4111 -       } while (--__size > 0);                                               \
4112 -    } while (0)
4113 -
4114 -/* Discontinue quicksort algorithm when partition gets below this size.
4115 -   This particular magic number was chosen to work best on a Sun 4/260. */
4116 -#define MAX_THRESH 4
4117 -
4118 -/* Stack node declarations used to store unfulfilled partition obligations. */
4119 -typedef struct
4120 -  {
4121 -    char *lo;
4122 -    char *hi;
4123 -  } stack_node;
4124 -
4125 -/* The next 4 #defines implement a very fast in-line stack abstraction. */
4126 -/* The stack needs log (total_elements) entries (we could even subtract
4127 -   log(MAX_THRESH)).  Since total_elements has type size_t, we get as
4128 -   upper bound for log (total_elements):
4129 -   bits per byte (CHAR_BIT) * sizeof(size_t).  */
4130 -#define STACK_SIZE     (8 * sizeof(unsigned long int))
4131 -#define PUSH(low, high)        ((void) ((top->lo = (low)), (top->hi = (high)), ++top))
4132 -#define        POP(low, high)  ((void) (--top, (low = top->lo), (high = top->hi)))
4133 -#define        STACK_NOT_EMPTY (stack < top)
4134 -
4135 -
4136 -/* Order size using quicksort.  This implementation incorporates
4137 -   four optimizations discussed in Sedgewick:
4138 -
4139 -   1. Non-recursive, using an explicit stack of pointer that store the
4140 -      next array partition to sort.  To save time, this maximum amount
4141 -      of space required to store an array of SIZE_MAX is allocated on the
4142 -      stack.  Assuming a 32-bit (64 bit) integer for size_t, this needs
4143 -      only 32 * sizeof(stack_node) == 256 bytes (for 64 bit: 1024 bytes).
4144 -      Pretty cheap, actually.
4145 -
4146 -   2. Chose the pivot element using a median-of-three decision tree.
4147 -      This reduces the probability of selecting a bad pivot value and
4148 -      eliminates certain extraneous comparisons.
4149 -
4150 -   3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving
4151 -      insertion sort to order the MAX_THRESH items within each partition.
4152 -      This is a big win, since insertion sort is faster for small, mostly
4153 -      sorted array segments.
4154 -
4155 -   4. The larger of the two sub-partitions is always pushed onto the
4156 -      stack first, with the algorithm then concentrating on the
4157 -      smaller partition.  This *guarantees* no more than log (total_elems)
4158 -      stack size is needed (actually O(1) in this case)!  */
4159 +/*
4160 + * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function".
4161 + */
4162 +#define swapcode(TYPE, parmi, parmj, n) {              \
4163 +       long i = (n) / sizeof (TYPE);                   \
4164 +       register TYPE *pi = (TYPE *) (parmi);           \
4165 +       register TYPE *pj = (TYPE *) (parmj);           \
4166 +       do {                                            \
4167 +               register TYPE   t = *pi;                \
4168 +               *pi++ = *pj;                            \
4169 +               *pj++ = t;                              \
4170 +        } while (--i > 0);                             \
4171 +}
4172  
4173 -void
4174 -qsort (void *const pbase, size_t total_elems, size_t size,
4175 -       int (*cmp)(const void *, const void *))
4176 +#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
4177 +       es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
4178 +
4179 +static __inline void
4180 +swapfunc(char *a, char *b, int n, int swaptype)
4181  {
4182 -  register char *base_ptr = (char *) pbase;
4183 +       if (swaptype <= 1) 
4184 +               swapcode(long, a, b, n)
4185 +       else
4186 +               swapcode(char, a, b, n)
4187 +}
4188  
4189 -  const size_t max_thresh = MAX_THRESH * size;
4190 +#define swap(a, b)                                     \
4191 +       if (swaptype == 0) {                            \
4192 +               long t = *(long *)(a);                  \
4193 +               *(long *)(a) = *(long *)(b);            \
4194 +               *(long *)(b) = t;                       \
4195 +       } else                                          \
4196 +               swapfunc(a, b, es, swaptype)
4197  
4198 -  if (total_elems == 0)
4199 -    /* Avoid lossage with unsigned arithmetic below.  */
4200 -    return;
4201 -
4202 -  if (total_elems > MAX_THRESH)
4203 -    {
4204 -      char *lo = base_ptr;
4205 -      char *hi = &lo[size * (total_elems - 1)];
4206 -      stack_node stack[STACK_SIZE];
4207 -      stack_node *top = stack + 1;
4208 -
4209 -      while (STACK_NOT_EMPTY)
4210 -       {
4211 -         char *left_ptr;
4212 -         char *right_ptr;
4213 -
4214 -         /* Select median value from among LO, MID, and HI. Rearrange
4215 -            LO and HI so the three values are sorted. This lowers the
4216 -            probability of picking a pathological pivot value and
4217 -            skips a comparison for both the LEFT_PTR and RIGHT_PTR in
4218 -            the while loops. */
4219 -
4220 -         char *mid = lo + size * ((hi - lo) / size >> 1);
4221 -
4222 -         if ((*cmp) ((void *) mid, (void *) lo) < 0)
4223 -           SWAP (mid, lo, size);
4224 -         if ((*cmp) ((void *) hi, (void *) mid) < 0)
4225 -           SWAP (mid, hi, size);
4226 -         else
4227 -           goto jump_over;
4228 -         if ((*cmp) ((void *) mid, (void *) lo) < 0)
4229 -           SWAP (mid, lo, size);
4230 -       jump_over:;
4231 -
4232 -         left_ptr  = lo + size;
4233 -         right_ptr = hi - size;
4234 -
4235 -         /* Here's the famous ``collapse the walls'' section of quicksort.
4236 -            Gotta like those tight inner loops!  They are the main reason
4237 -            that this algorithm runs much faster than others. */
4238 -         do
4239 -           {
4240 -             while ((*cmp) ((void *) left_ptr, (void *) mid) < 0)
4241 -               left_ptr += size;
4242 -
4243 -             while ((*cmp) ((void *) mid, (void *) right_ptr) < 0)
4244 -               right_ptr -= size;
4245 -
4246 -             if (left_ptr < right_ptr)
4247 -               {
4248 -                 SWAP (left_ptr, right_ptr, size);
4249 -                 if (mid == left_ptr)
4250 -                   mid = right_ptr;
4251 -                 else if (mid == right_ptr)
4252 -                   mid = left_ptr;
4253 -                 left_ptr += size;
4254 -                 right_ptr -= size;
4255 -               }
4256 -             else if (left_ptr == right_ptr)
4257 -               {
4258 -                 left_ptr += size;
4259 -                 right_ptr -= size;
4260 -                 break;
4261 +#define vecswap(a, b, n)       if ((n) > 0) swapfunc(a, b, n, swaptype)
4262 +
4263 +static __inline char *
4264 +med3(char *a, char *b, char *c, int (*cmp)(const void *, const void *))
4265 +{
4266 +       return cmp(a, b) < 0 ?
4267 +              (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
4268 +              :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
4269 +}
4270 +
4271 +void
4272 +qsort(void *aa, size_t n, size_t es, int (*cmp)(const void *, const void *))
4273 +{
4274 +       char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
4275 +       int d, r, swaptype, swap_cnt;
4276 +       register char *a = aa;
4277 +
4278 +loop:  SWAPINIT(a, es);
4279 +       swap_cnt = 0;
4280 +       if (n < 7) {
4281 +               for (pm = (char *)a + es; pm < (char *) a + n * es; pm += es)
4282 +                       for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
4283 +                            pl -= es)
4284 +                               swap(pl, pl - es);
4285 +               return;
4286 +       }
4287 +       pm = (char *)a + (n / 2) * es;
4288 +       if (n > 7) {
4289 +               pl = (char *)a;
4290 +               pn = (char *)a + (n - 1) * es;
4291 +               if (n > 40) {
4292 +                       d = (n / 8) * es;
4293 +                       pl = med3(pl, pl + d, pl + 2 * d, cmp);
4294 +                       pm = med3(pm - d, pm, pm + d, cmp);
4295 +                       pn = med3(pn - 2 * d, pn - d, pn, cmp);
4296                 }
4297 -           }
4298 -         while (left_ptr <= right_ptr);
4299 +               pm = med3(pl, pm, pn, cmp);
4300 +       }
4301 +       swap(a, pm);
4302 +       pa = pb = (char *)a + es;
4303  
4304 -         /* Set up pointers for next iteration.  First determine whether
4305 -            left and right partitions are below the threshold size.  If so,
4306 -            ignore one or both.  Otherwise, push the larger partition's
4307 -            bounds on the stack and continue sorting the smaller one. */
4308 -
4309 -         if ((size_t) (right_ptr - lo) <= max_thresh)
4310 -           {
4311 -             if ((size_t) (hi - left_ptr) <= max_thresh)
4312 -               /* Ignore both small partitions. */
4313 -               POP (lo, hi);
4314 -             else
4315 -               /* Ignore small left partition. */
4316 -               lo = left_ptr;
4317 -           }
4318 -         else if ((size_t) (hi - left_ptr) <= max_thresh)
4319 -           /* Ignore small right partition. */
4320 -           hi = right_ptr;
4321 -         else if ((right_ptr - lo) > (hi - left_ptr))
4322 -           {
4323 -             /* Push larger left partition indices. */
4324 -             PUSH (lo, right_ptr);
4325 -             lo = left_ptr;
4326 -           }
4327 -         else
4328 -           {
4329 -             /* Push larger right partition indices. */
4330 -             PUSH (left_ptr, hi);
4331 -             hi = right_ptr;
4332 -           }
4333 +       pc = pd = (char *)a + (n - 1) * es;
4334 +       for (;;) {
4335 +               while (pb <= pc && (r = cmp(pb, a)) <= 0) {
4336 +                       if (r == 0) {
4337 +                               swap_cnt = 1;
4338 +                               swap(pa, pb);
4339 +                               pa += es;
4340 +                       }
4341 +                       pb += es;
4342 +               }
4343 +               while (pb <= pc && (r = cmp(pc, a)) >= 0) {
4344 +                       if (r == 0) {
4345 +                               swap_cnt = 1;
4346 +                               swap(pc, pd);
4347 +                               pd -= es;
4348 +                       }
4349 +                       pc -= es;
4350 +               }
4351 +               if (pb > pc)
4352 +                       break;
4353 +               swap(pb, pc);
4354 +               swap_cnt = 1;
4355 +               pb += es;
4356 +               pc -= es;
4357 +       }
4358 +       if (swap_cnt == 0) {  /* Switch to insertion sort */
4359 +               for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
4360 +                       for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; 
4361 +                            pl -= es)
4362 +                               swap(pl, pl - es);
4363 +               return;
4364         }
4365 -    }
4366  
4367 -  /* Once the BASE_PTR array is partially sorted by quicksort the rest
4368 -     is completely sorted using insertion sort, since this is efficient
4369 -     for partitions below MAX_THRESH size. BASE_PTR points to the beginning
4370 -     of the array to sort, and END_PTR points at the very last element in
4371 -     the array (*not* one beyond it!). */
4372 -  {
4373 -    char *const end_ptr = &base_ptr[size * (total_elems - 1)];
4374 -    char *tmp_ptr = base_ptr;
4375 -    char *const thresh = min_t(char *const, end_ptr, base_ptr + max_thresh);
4376 -    register char *run_ptr;
4377 -
4378 -    /* Find smallest element in first threshold and place it at the
4379 -       array's beginning.  This is the smallest array element,
4380 -       and the operation speeds up insertion sort's inner loop. */
4381 -
4382 -    for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size)
4383 -      if ((*cmp) ((void *) run_ptr, (void *) tmp_ptr) < 0)
4384 -       tmp_ptr = run_ptr;
4385 -
4386 -    if (tmp_ptr != base_ptr)
4387 -      SWAP (tmp_ptr, base_ptr, size);
4388 -
4389 -    /* Insertion sort, running from left-hand-side up to right-hand-side.  */
4390 -
4391 -    run_ptr = base_ptr + size;
4392 -    while ((run_ptr += size) <= end_ptr)
4393 -      {
4394 -       tmp_ptr = run_ptr - size;
4395 -       while ((*cmp) ((void *) run_ptr, (void *) tmp_ptr) < 0)
4396 -         tmp_ptr -= size;
4397 -
4398 -       tmp_ptr += size;
4399 -       if (tmp_ptr != run_ptr)
4400 -         {
4401 -           char *trav;
4402 -
4403 -           trav = run_ptr + size;
4404 -           while (--trav >= run_ptr)
4405 -             {
4406 -               char c = *trav;
4407 -               char *hi, *lo;
4408 -
4409 -               for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo)
4410 -                 *hi = *lo;
4411 -               *hi = c;
4412 -             }
4413 -         }
4414 -      }
4415 -  }
4416 +       pn = (char *)a + n * es;
4417 +       r = min(pa - (char *)a, pb - pa);
4418 +       vecswap(a, pb - r, r);
4419 +       r = min((long)(pd - pc), (long)(pn - pd - es));
4420 +       vecswap(pb, pn - r, r);
4421 +       if ((r = pb - pa) > es)
4422 +               qsort(a, r / es, es, cmp);
4423 +       if ((r = pd - pc) > es) { 
4424 +               /* Iterate rather than recurse to save stack space */
4425 +               a = pn - r;
4426 +               n = r / es;
4427 +               goto loop;
4428 +       }
4429 +/*             qsort(pn - r, r / es, es, cmp);*/
4430  }
4431 diff -urN linux.org/fs/xfs/xfs_acl.h linux/fs/xfs/xfs_acl.h
4432 --- linux.org/fs/xfs/xfs_acl.h  2003-12-31 05:47:08.000000000 +0100
4433 +++ linux/fs/xfs/xfs_acl.h      2004-01-02 04:21:42.000000000 +0100
4434 @@ -1,5 +1,5 @@
4435  /*
4436 - * Copyright (c) 2001-2002 Silicon Graphics, Inc.  All Rights Reserved.
4437 + * Copyright (c) 2001-2003 Silicon Graphics, Inc.  All Rights Reserved.
4438   *
4439   * This program is free software; you can redistribute it and/or modify it
4440   * under the terms of version 2 of the GNU General Public License as
4441 @@ -102,6 +102,8 @@
4442  #define xfs_acl_vset(v,p,sz,t) (-EOPNOTSUPP)
4443  #define xfs_acl_vget(v,p,sz,t) (-EOPNOTSUPP)
4444  #define xfs_acl_vremove(v,t)   (-EOPNOTSUPP)
4445 +#define xfs_acl_vhasacl_access(v)      (0)
4446 +#define xfs_acl_vhasacl_default(v)     (0)
4447  #define _ACL_DECL(a)           ((void)0)
4448  #define _ACL_ALLOC(a)          (1)     /* successfully allocate nothing */
4449  #define _ACL_FREE(a)           ((void)0)
4450 diff -urN linux.org/fs/xfs/xfs_alloc.c linux/fs/xfs/xfs_alloc.c
4451 --- linux.org/fs/xfs/xfs_alloc.c        2003-12-31 05:46:44.000000000 +0100
4452 +++ linux/fs/xfs/xfs_alloc.c    2004-01-02 04:21:42.000000000 +0100
4453 @@ -54,13 +54,6 @@
4454  #include "xfs_error.h"
4455  
4456  
4457 -#if defined(DEBUG)
4458 -/*
4459 - * Allocation tracing.
4460 - */
4461 -ktrace_t       *xfs_alloc_trace_buf;
4462 -#endif
4463 -
4464  #define XFS_ABSDIFF(a,b)       (((a) <= (b)) ? ((b) - (a)) : ((a) - (b)))
4465  
4466  #define        XFSA_FIXUP_BNO_OK       1
4467 @@ -73,6 +66,8 @@
4468                     xfs_extlen_t len);
4469  
4470  #if defined(XFS_ALLOC_TRACE)
4471 +ktrace_t *xfs_alloc_trace_buf;
4472 +
4473  #define        TRACE_ALLOC(s,a)        \
4474         xfs_alloc_trace_alloc(fname, s, a, __LINE__)
4475  #define        TRACE_FREE(s,a,b,x,f)   \
4476 @@ -85,8 +80,6 @@
4477         xfs_alloc_trace_busy(fname, s, mp, ag, -1, -1, sl, tp, XFS_ALLOC_KTRACE_UNBUSY, __LINE__)
4478  #define        TRACE_BUSYSEARCH(fname,s,ag,agb,l,sl,tp)        \
4479         xfs_alloc_trace_busy(fname, s, mp, ag, agb, l, sl, tp, XFS_ALLOC_KTRACE_BUSYSEARCH, __LINE__)
4480 -
4481 -
4482  #else
4483  #define        TRACE_ALLOC(s,a)
4484  #define        TRACE_FREE(s,a,b,x,f)
4485 diff -urN linux.org/fs/xfs/xfs_alloc.h linux/fs/xfs/xfs_alloc.h
4486 --- linux.org/fs/xfs/xfs_alloc.h        2003-12-31 05:46:56.000000000 +0100
4487 +++ linux/fs/xfs/xfs_alloc.h    2004-01-02 04:21:42.000000000 +0100
4488 @@ -95,6 +95,13 @@
4489  
4490  #ifdef __KERNEL__
4491  
4492 +#if defined(XFS_ALLOC_TRACE)
4493 +/*
4494 + * Allocation tracing buffer size.
4495 + */
4496 +#define        XFS_ALLOC_TRACE_SIZE    4096
4497 +extern ktrace_t *xfs_alloc_trace_buf;
4498 +
4499  /*
4500   * Types for alloc tracing.
4501   */
4502 @@ -104,26 +111,9 @@
4503  #define        XFS_ALLOC_KTRACE_BUSY   4
4504  #define        XFS_ALLOC_KTRACE_UNBUSY 5
4505  #define        XFS_ALLOC_KTRACE_BUSYSEARCH     6
4506 -
4507 -
4508 -/*
4509 - * Allocation tracing buffer size.
4510 - */
4511 -#define        XFS_ALLOC_TRACE_SIZE    4096
4512 -
4513 -#ifdef XFS_ALL_TRACE
4514 -#define        XFS_ALLOC_TRACE
4515 -#endif
4516 -
4517 -#if !defined(DEBUG)
4518 -#undef XFS_ALLOC_TRACE
4519  #endif
4520  
4521  /*
4522 - * Prototypes for visible xfs_alloc.c routines
4523 - */
4524 -
4525 -/*
4526   * Compute and fill in value of m_ag_maxlevels.
4527   */
4528  void
4529 diff -urN linux.org/fs/xfs/xfs_arch.h linux/fs/xfs/xfs_arch.h
4530 --- linux.org/fs/xfs/xfs_arch.h 2003-12-31 05:48:14.000000000 +0100
4531 +++ linux/fs/xfs/xfs_arch.h     2004-01-02 04:21:42.000000000 +0100
4532 @@ -53,16 +53,18 @@
4533  
4534  #define ARCH_NOCONVERT 1
4535  #if __BYTE_ORDER == __LITTLE_ENDIAN
4536 -#define ARCH_CONVERT   0
4537 +# define ARCH_CONVERT  0
4538  #else
4539 -#define ARCH_CONVERT   ARCH_NOCONVERT
4540 +# define ARCH_CONVERT  ARCH_NOCONVERT
4541  #endif
4542  
4543  /* generic swapping macros */
4544  
4545 +#ifndef HAVE_SWABMACROS
4546  #define INT_SWAP16(type,var) ((typeof(type))(__swab16((__u16)(var))))
4547  #define INT_SWAP32(type,var) ((typeof(type))(__swab32((__u32)(var))))
4548  #define INT_SWAP64(type,var) ((typeof(type))(__swab64((__u64)(var))))
4549 +#endif
4550  
4551  #define INT_SWAP(type, var) \
4552      ((sizeof(type) == 8) ? INT_SWAP64(type,var) : \
4553 diff -urN linux.org/fs/xfs/xfs_attr.c linux/fs/xfs/xfs_attr.c
4554 --- linux.org/fs/xfs/xfs_attr.c 2003-12-31 05:47:38.000000000 +0100
4555 +++ linux/fs/xfs/xfs_attr.c     2004-01-02 04:21:42.000000000 +0100
4556 @@ -1,5 +1,5 @@
4557  /*
4558 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4559 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
4560   *
4561   * This program is free software; you can redistribute it and/or modify it
4562   * under the terms of version 2 of the GNU General Public License as
4563 @@ -63,6 +63,7 @@
4564  #include "xfs_quota.h"
4565  #include "xfs_rw.h"
4566  #include "xfs_trans_space.h"
4567 +#include "xfs_acl.h"
4568  
4569  /*
4570   * xfs_attr.c
4571 @@ -2234,7 +2235,8 @@
4572                 (__psunsigned_t)context->count,
4573                 (__psunsigned_t)context->firstu,
4574                 (__psunsigned_t)
4575 -                       (context->count > 0)
4576 +                       ((context->count > 0) &&
4577 +                       !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
4578                                 ? (ATTR_ENTRY(context->alist,
4579                                               context->count-1)->a_valuelen)
4580                                 : 0,
4581 @@ -2262,7 +2264,8 @@
4582                 (__psunsigned_t)context->count,
4583                 (__psunsigned_t)context->firstu,
4584                 (__psunsigned_t)
4585 -                       (context->count > 0)
4586 +                       ((context->count > 0) &&
4587 +                       !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
4588                                 ? (ATTR_ENTRY(context->alist,
4589                                               context->count-1)->a_valuelen)
4590                                 : 0,
4591 @@ -2290,7 +2293,8 @@
4592                 (__psunsigned_t)context->count,
4593                 (__psunsigned_t)context->firstu,
4594                 (__psunsigned_t)
4595 -                       (context->count > 0)
4596 +                       ((context->count > 0) &&
4597 +                       !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
4598                                 ? (ATTR_ENTRY(context->alist,
4599                                               context->count-1)->a_valuelen)
4600                                 : 0,
4601 @@ -2318,7 +2322,8 @@
4602                 (__psunsigned_t)context->count,
4603                 (__psunsigned_t)context->firstu,
4604                 (__psunsigned_t)
4605 -                       (context->count > 0)
4606 +                       ((context->count > 0) &&
4607 +                       !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
4608                                 ? (ATTR_ENTRY(context->alist,
4609                                               context->count-1)->a_valuelen)
4610                                 : 0,
4611 @@ -2353,3 +2358,307 @@
4612                                          (void *)a14, (void *)a15);
4613  }
4614  #endif /* XFS_ATTR_TRACE */
4615 +
4616 +
4617 +/*========================================================================
4618 + * System (pseudo) namespace attribute interface routines.
4619 + *========================================================================*/
4620 +
4621 +STATIC int
4622 +posix_acl_access_set(
4623 +       vnode_t *vp, char *name, void *data, size_t size, int xflags)
4624 +{
4625 +       return xfs_acl_vset(vp, data, size, _ACL_TYPE_ACCESS);
4626 +}
4627 +
4628 +STATIC int
4629 +posix_acl_access_remove(
4630 +       struct vnode *vp, char *name, int xflags)
4631 +{
4632 +       return xfs_acl_vremove(vp, _ACL_TYPE_ACCESS);
4633 +}
4634 +
4635 +STATIC int
4636 +posix_acl_access_get(
4637 +       vnode_t *vp, char *name, void *data, size_t size, int xflags)
4638 +{
4639 +       return xfs_acl_vget(vp, data, size, _ACL_TYPE_ACCESS);
4640 +}
4641 +
4642 +STATIC int
4643 +posix_acl_access_exists(
4644 +       vnode_t *vp)
4645 +{
4646 +       return xfs_acl_vhasacl_access(vp);
4647 +}
4648 +
4649 +STATIC int
4650 +posix_acl_default_set(
4651 +       vnode_t *vp, char *name, void *data, size_t size, int xflags)
4652 +{
4653 +       return xfs_acl_vset(vp, data, size, _ACL_TYPE_DEFAULT);
4654 +}
4655 +
4656 +STATIC int
4657 +posix_acl_default_get(
4658 +       vnode_t *vp, char *name, void *data, size_t size, int xflags)
4659 +{
4660 +       return xfs_acl_vget(vp, data, size, _ACL_TYPE_DEFAULT);
4661 +}
4662 +
4663 +STATIC int
4664 +posix_acl_default_remove(
4665 +       struct vnode *vp, char *name, int xflags)
4666 +{
4667 +       return xfs_acl_vremove(vp, _ACL_TYPE_DEFAULT);
4668 +}
4669 +
4670 +STATIC int
4671 +posix_acl_default_exists(
4672 +       vnode_t *vp)
4673 +{
4674 +       return xfs_acl_vhasacl_default(vp);
4675 +}
4676 +
4677 +struct attrnames posix_acl_access = {
4678 +       .attr_name      = "posix_acl_access",
4679 +       .attr_namelen   = sizeof("posix_acl_access") - 1,
4680 +       .attr_get       = posix_acl_access_get,
4681 +       .attr_set       = posix_acl_access_set,
4682 +       .attr_remove    = posix_acl_access_remove,
4683 +       .attr_exists    = posix_acl_access_exists,
4684 +};
4685 +
4686 +struct attrnames posix_acl_default = {
4687 +       .attr_name      = "posix_acl_default",
4688 +       .attr_namelen   = sizeof("posix_acl_default") - 1,
4689 +       .attr_get       = posix_acl_default_get,
4690 +       .attr_set       = posix_acl_default_set,
4691 +       .attr_remove    = posix_acl_default_remove,
4692 +       .attr_exists    = posix_acl_default_exists,
4693 +};
4694 +
4695 +struct attrnames *attr_system_names[] =
4696 +       { &posix_acl_access, &posix_acl_default };
4697 +
4698 +
4699 +/*========================================================================
4700 + * Namespace-prefix-style attribute name interface routines.
4701 + *========================================================================*/
4702 +
4703 +STATIC int
4704 +attr_generic_set(
4705 +       struct vnode *vp, char *name, void *data, size_t size, int xflags)
4706 +{
4707 +       int     error;
4708 +
4709 +       VOP_ATTR_SET(vp, name, data, size, xflags, NULL, error);
4710 +       return -error;
4711 +}
4712 +
4713 +STATIC int
4714 +attr_generic_get(
4715 +       struct vnode *vp, char *name, void *data, size_t size, int xflags)
4716 +{
4717 +       int     error, asize = size;
4718 +
4719 +       VOP_ATTR_GET(vp, name, data, &asize, xflags, NULL, error);
4720 +       if (!error)
4721 +               return asize;
4722 +       return -error;
4723 +}
4724 +
4725 +STATIC int
4726 +attr_generic_remove(
4727 +       struct vnode *vp, char *name, int xflags)
4728 +{
4729 +       int     error;
4730 +
4731 +       VOP_ATTR_REMOVE(vp, name, xflags, NULL, error);
4732 +       return -error;
4733 +}
4734 +
4735 +STATIC int
4736 +attr_generic_listadd(
4737 +       attrnames_t             *prefix,
4738 +       attrnames_t             *namesp,
4739 +       void                    *data,
4740 +       size_t                  size,
4741 +       ssize_t                 *result)
4742 +{
4743 +       char                    *p = data + *result;
4744 +
4745 +       *result += prefix->attr_namelen;
4746 +       *result += namesp->attr_namelen + 1;
4747 +       if (!size)
4748 +               return 0;
4749 +       if (*result > size)
4750 +               return -ERANGE;
4751 +       strcpy(p, prefix->attr_name);
4752 +       p += prefix->attr_namelen;
4753 +       strcpy(p, namesp->attr_name);
4754 +       p += namesp->attr_namelen + 1;
4755 +       return 0;
4756 +}
4757 +
4758 +STATIC int
4759 +attr_system_list(
4760 +       struct vnode            *vp,
4761 +       void                    *data,
4762 +       size_t                  size,
4763 +       ssize_t                 *result)
4764 +{
4765 +       attrnames_t             *namesp;
4766 +       int                     i, error = 0;
4767 +
4768 +       for (i = 0; i < ATTR_SYSCOUNT; i++) {
4769 +               namesp = attr_system_names[i];
4770 +               if (!namesp->attr_exists || !namesp->attr_exists(vp))
4771 +                       continue;
4772 +               error = attr_generic_listadd(&attr_system, namesp,
4773 +                                               data, size, result);
4774 +               if (error)
4775 +                       break;
4776 +       }
4777 +       return error;
4778 +}
4779 +
4780 +int
4781 +attr_generic_list(
4782 +       struct vnode *vp, void *data, size_t size, int xflags, ssize_t *result)
4783 +{
4784 +       attrlist_cursor_kern_t  cursor = { 0 };
4785 +       int                     error;
4786 +
4787 +       VOP_ATTR_LIST(vp, data, size, xflags, &cursor, NULL, error);
4788 +       if (error > 0)
4789 +               return -error;
4790 +       *result = -error;
4791 +       return attr_system_list(vp, data, size, result);
4792 +}
4793 +
4794 +attrnames_t *
4795 +attr_lookup_namespace(
4796 +       char                    *name,
4797 +       struct attrnames        **names,
4798 +       int                     nnames)
4799 +{
4800 +       int                     i;
4801 +
4802 +       for (i = 0; i < nnames; i++)
4803 +               if (!strncmp(name, names[i]->attr_name, names[i]->attr_namelen))
4804 +                       return names[i];
4805 +       return NULL;
4806 +}
4807 +
4808 +/*
4809 + * Some checks to prevent people abusing EAs to get over quota:
4810 + * - Don't allow modifying user EAs on devices/symlinks;
4811 + * - Don't allow modifying user EAs if sticky bit set;
4812 + */
4813 +STATIC int
4814 +attr_user_capable(
4815 +       struct vnode    *vp,
4816 +       cred_t          *cred)
4817 +{
4818 +       struct inode    *inode = LINVFS_GET_IP(vp);
4819 +
4820 +       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
4821 +               return -EPERM;
4822 +       if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) &&
4823 +           !capable(CAP_SYS_ADMIN))
4824 +               return -EPERM;
4825 +       if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
4826 +           (current_fsuid(cred) != inode->i_uid) && !capable(CAP_FOWNER))
4827 +               return -EPERM;
4828 +       return 0;
4829 +}
4830 +
4831 +STATIC int
4832 +attr_trusted_capable(
4833 +       struct vnode    *vp,
4834 +       cred_t          *cred)
4835 +{
4836 +       struct inode    *inode = LINVFS_GET_IP(vp);
4837 +
4838 +       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
4839 +               return -EPERM;
4840 +       if (!capable(CAP_SYS_ADMIN))
4841 +               return -EPERM;
4842 +       return 0;
4843 +}
4844 +
4845 +STATIC int
4846 +attr_system_set(
4847 +       struct vnode *vp, char *name, void *data, size_t size, int xflags)
4848 +{
4849 +       attrnames_t     *namesp;
4850 +       int             error;
4851 +
4852 +       if (xflags & ATTR_CREATE)
4853 +               return -EINVAL;
4854 +
4855 +       namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
4856 +       if (!namesp)
4857 +               return -EOPNOTSUPP;
4858 +       error = namesp->attr_set(vp, name, data, size, xflags);
4859 +       if (!error)
4860 +               error = vn_revalidate(vp);
4861 +       return error;
4862 +}
4863 +
4864 +STATIC int
4865 +attr_system_get(
4866 +       struct vnode *vp, char *name, void *data, size_t size, int xflags)
4867 +{
4868 +       attrnames_t     *namesp;
4869 +
4870 +       namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
4871 +       if (!namesp)
4872 +               return -EOPNOTSUPP;
4873 +       return namesp->attr_get(vp, name, data, size, xflags);
4874 +}
4875 +
4876 +STATIC int
4877 +attr_system_remove(
4878 +       struct vnode *vp, char *name, int xflags)
4879 +{
4880 +       attrnames_t     *namesp;
4881 +
4882 +       namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
4883 +       if (!namesp)
4884 +               return -EOPNOTSUPP;
4885 +       return namesp->attr_remove(vp, name, xflags);
4886 +}
4887 +
4888 +struct attrnames attr_system = {
4889 +       .attr_name      = "system.",
4890 +       .attr_namelen   = sizeof("system.") - 1,
4891 +       .attr_flag      = ATTR_SYSTEM,
4892 +       .attr_get       = attr_system_get,
4893 +       .attr_set       = attr_system_set,
4894 +       .attr_remove    = attr_system_remove,
4895 +       .attr_capable   = (attrcapable_t)fs_noerr,
4896 +};
4897 +
4898 +struct attrnames attr_trusted = {
4899 +       .attr_name      = "trusted.",
4900 +       .attr_namelen   = sizeof("trusted.") - 1,
4901 +       .attr_flag      = ATTR_ROOT,
4902 +       .attr_get       = attr_generic_get,
4903 +       .attr_set       = attr_generic_set,
4904 +       .attr_remove    = attr_generic_remove,
4905 +       .attr_capable   = attr_trusted_capable,
4906 +};
4907 +
4908 +struct attrnames attr_user = {
4909 +       .attr_name      = "user.",
4910 +       .attr_namelen   = sizeof("user.") - 1,
4911 +       .attr_get       = attr_generic_get,
4912 +       .attr_set       = attr_generic_set,
4913 +       .attr_remove    = attr_generic_remove,
4914 +       .attr_capable   = attr_user_capable,
4915 +};
4916 +
4917 +struct attrnames *attr_namespaces[] =
4918 +       { &attr_system, &attr_trusted, &attr_user };
4919 diff -urN linux.org/fs/xfs/xfs_attr.h linux/fs/xfs/xfs_attr.h
4920 --- linux.org/fs/xfs/xfs_attr.h 2003-12-31 05:46:42.000000000 +0100
4921 +++ linux/fs/xfs/xfs_attr.h     2004-01-02 04:21:42.000000000 +0100
4922 @@ -1,5 +1,5 @@
4923  /*
4924 - * Copyright (c) 2000, 2002 Silicon Graphics, Inc.  All Rights Reserved.
4925 + * Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
4926   *
4927   * This program is free software; you can redistribute it and/or modify it
4928   * under the terms of version 2 of the GNU General Public License as
4929 @@ -45,22 +45,50 @@
4930   * as possible so as to fit into the literal area of the inode.
4931   */
4932  
4933 -#ifdef XFS_ALL_TRACE
4934 -#define        XFS_ATTR_TRACE
4935 -#endif
4936 -
4937 -#if !defined(DEBUG)
4938 -#undef XFS_ATTR_TRACE
4939 -#endif
4940 -
4941 -
4942  /*========================================================================
4943   * External interfaces
4944   *========================================================================*/
4945  
4946 -#define ATTR_ROOT      0x0002  /* use attrs in root namespace, not user */
4947 +struct cred;
4948 +struct vnode;
4949 +
4950 +typedef int (*attrset_t)(struct vnode *, char *, void *, size_t, int);
4951 +typedef int (*attrget_t)(struct vnode *, char *, void *, size_t, int);
4952 +typedef int (*attrremove_t)(struct vnode *, char *, int);
4953 +typedef int (*attrexists_t)(struct vnode *);
4954 +typedef int (*attrcapable_t)(struct vnode *, struct cred *);
4955 +
4956 +typedef struct attrnames {
4957 +       char *          attr_name;
4958 +       unsigned int    attr_namelen;
4959 +       unsigned int    attr_flag;
4960 +       attrget_t       attr_get;
4961 +       attrset_t       attr_set;
4962 +       attrremove_t    attr_remove;
4963 +       attrexists_t    attr_exists;
4964 +       attrcapable_t   attr_capable;
4965 +} attrnames_t;
4966 +
4967 +#define ATTR_NAMECOUNT 3
4968 +extern struct attrnames attr_user;
4969 +extern struct attrnames attr_system;
4970 +extern struct attrnames attr_trusted;
4971 +extern struct attrnames *attr_namespaces[ATTR_NAMECOUNT];
4972 +
4973 +#define ATTR_SYSCOUNT  2
4974 +extern struct attrnames posix_acl_access;
4975 +extern struct attrnames posix_acl_default;
4976 +extern struct attrnames *attr_system_names[ATTR_SYSCOUNT];
4977 +
4978 +extern attrnames_t *attr_lookup_namespace(char *, attrnames_t **, int);
4979 +extern int attr_generic_list(struct vnode *, void *, size_t, int, ssize_t *);
4980 +
4981 +#define ATTR_DONTFOLLOW        0x0001  /* -- unused, from IRIX -- */
4982 +#define ATTR_ROOT      0x0002  /* use attrs in root (trusted) namespace */
4983 +#define ATTR_TRUST     0x0004  /* -- unused, from IRIX -- */
4984  #define ATTR_CREATE    0x0010  /* pure create: fail if attr already exists */
4985  #define ATTR_REPLACE   0x0020  /* pure set: fail if attr does not exist */
4986 +#define ATTR_SYSTEM    0x0100  /* use attrs in system (pseudo) namespace */
4987  #define ATTR_KERNOTIME 0x1000  /* [kernel] don't update inode timestamps */
4988  #define ATTR_KERNOVAL  0x2000  /* [kernel] get attr size only, not value */
4989  #define ATTR_KERNAMELS 0x4000  /* [kernel] list attr names (simple list) */
4990 @@ -135,11 +163,8 @@
4991   * Function prototypes for the kernel.
4992   *========================================================================*/
4993  
4994 -struct cred;
4995 -struct vnode;
4996  struct xfs_inode;
4997  struct attrlist_cursor_kern;
4998 -struct xfs_ext_attr;
4999  struct xfs_da_args;
5000  
5001  /*
5002 diff -urN linux.org/fs/xfs/xfs_attr_leaf.c linux/fs/xfs/xfs_attr_leaf.c
5003 --- linux.org/fs/xfs/xfs_attr_leaf.c    2003-12-31 05:47:15.000000000 +0100
5004 +++ linux/fs/xfs/xfs_attr_leaf.c        2004-01-02 04:21:42.000000000 +0100
5005 @@ -1,5 +1,5 @@
5006  /*
5007 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
5008 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
5009   *
5010   * This program is free software; you can redistribute it and/or modify it
5011   * under the terms of version 2 of the GNU General Public License as
5012 @@ -444,8 +444,10 @@
5013                                                         < context->bufsize) {
5014                 for (i = 0, sfe = &sf->list[0];
5015                                 i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
5016 -                       int ns = (sfe->flags & XFS_ATTR_ROOT)?
5017 -                                               ROOT_NAMES : USER_NAMES;
5018 +                       attrnames_t     *namesp;
5019 +
5020 +                       namesp = (sfe->flags & XFS_ATTR_ROOT) ? &attr_trusted :
5021 +                                 &attr_user;
5022                         if (((context->flags & ATTR_ROOT) != 0) !=
5023                             ((sfe->flags & XFS_ATTR_ROOT) != 0) &&
5024                             !(context->flags & ATTR_KERNFULLS)) {
5025 @@ -454,11 +456,11 @@
5026                         }
5027                         if (context->flags & ATTR_KERNOVAL) {
5028                                 ASSERT(context->flags & ATTR_KERNAMELS);
5029 -                               context->count += xfs_namespaces[ns].namelen +
5030 +                               context->count += namesp->attr_namelen +
5031                                         INT_GET(sfe->namelen, ARCH_CONVERT) + 1;
5032                         }
5033                         else {
5034 -                               if (xfs_attr_put_listent(context, ns,
5035 +                               if (xfs_attr_put_listent(context, namesp,
5036                                                    (char *)sfe->nameval,
5037                                                    (int)sfe->namelen,
5038                                                    (int)INT_GET(sfe->valuelen,
5039 @@ -544,18 +546,22 @@
5040          * Loop putting entries into the user buffer.
5041          */
5042         for ( ; i < nsbuf; i++, sbp++) {
5043 -               int ns = (sbp->flags & XFS_ATTR_ROOT)? ROOT_NAMES:USER_NAMES;
5044 +               attrnames_t     *namesp;
5045 +
5046 +               namesp = (sfe->flags & XFS_ATTR_ROOT) ? &attr_trusted :
5047 +                         &attr_user;
5048 +
5049                 if (cursor->hashval != INT_GET(sbp->hash, ARCH_CONVERT)) {
5050                         cursor->hashval = INT_GET(sbp->hash, ARCH_CONVERT);
5051                         cursor->offset = 0;
5052                 }
5053                 if (context->flags & ATTR_KERNOVAL) {
5054                         ASSERT(context->flags & ATTR_KERNAMELS);
5055 -                       context->count += xfs_namespaces[ns].namelen
5056 -                                       + sbp->namelen + 1;
5057 +                       context->count += namesp->attr_namelen +
5058 +                                               sbp->namelen + 1;
5059                 }
5060                 else {
5061 -                       if (xfs_attr_put_listent(context, ns,
5062 +                       if (xfs_attr_put_listent(context, namesp,
5063                                         sbp->name, sbp->namelen,
5064                                         INT_GET(sbp->valuelen, ARCH_CONVERT)))
5065                                 break;
5066 @@ -2270,7 +2276,7 @@
5067         retval = 0;
5068         for (  ; (i < INT_GET(leaf->hdr.count, ARCH_CONVERT))
5069              && (retval == 0); entry++, i++) {
5070 -               int ns = (entry->flags & XFS_ATTR_ROOT)? ROOT_NAMES:USER_NAMES;
5071 +               attrnames_t     *namesp;
5072  
5073                 if (INT_GET(entry->hashval, ARCH_CONVERT) != cursor->hashval) {
5074                         cursor->hashval = INT_GET(entry->hashval, ARCH_CONVERT);
5075 @@ -2284,14 +2290,17 @@
5076                     !(context->flags & ATTR_KERNFULLS))
5077                         continue;               /* skip non-matching entries */
5078  
5079 +               namesp = (entry->flags & XFS_ATTR_ROOT) ? &attr_trusted :
5080 +                         &attr_user;
5081 +
5082                 if (entry->flags & XFS_ATTR_LOCAL) {
5083                         name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, i);
5084                         if (context->flags & ATTR_KERNOVAL) {
5085                                 ASSERT(context->flags & ATTR_KERNAMELS);
5086 -                               context->count += xfs_namespaces[ns].namelen
5087 -                                               + (int)name_loc->namelen + 1;
5088 +                               context->count += namesp->attr_namelen +
5089 +                                               (int)name_loc->namelen + 1;
5090                         } else {
5091 -                               retval = xfs_attr_put_listent(context, ns,
5092 +                               retval = xfs_attr_put_listent(context, namesp,
5093                                         (char *)name_loc->nameval,
5094                                         (int)name_loc->namelen,
5095                                         (int)INT_GET(name_loc->valuelen,
5096 @@ -2301,10 +2310,10 @@
5097                         name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
5098                         if (context->flags & ATTR_KERNOVAL) {
5099                                 ASSERT(context->flags & ATTR_KERNAMELS);
5100 -                               context->count += xfs_namespaces[ns].namelen
5101 -                                               + (int)name_rmt->namelen + 1;
5102 +                               context->count += namesp->attr_namelen +
5103 +                                               (int)name_rmt->namelen + 1;
5104                         } else {
5105 -                               retval = xfs_attr_put_listent(context, ns,
5106 +                               retval = xfs_attr_put_listent(context, namesp,
5107                                         (char *)name_rmt->name,
5108                                         (int)name_rmt->namelen,
5109                                         (int)INT_GET(name_rmt->valuelen,
5110 @@ -2333,7 +2342,7 @@
5111  /*ARGSUSED*/
5112  int
5113  xfs_attr_put_listent(xfs_attr_list_context_t *context,
5114 -                    int ns, char *name, int namelen, int valuelen)
5115 +                    attrnames_t *namesp, char *name, int namelen, int valuelen)
5116  {
5117         attrlist_ent_t *aep;
5118         int arraytop;
5119 @@ -2341,23 +2350,21 @@
5120         ASSERT(!(context->flags & ATTR_KERNOVAL));
5121         if (context->flags & ATTR_KERNAMELS) {
5122                 char *offset;
5123 -               xattr_namespace_t *nsp;
5124  
5125                 ASSERT(context->count >= 0);
5126  
5127 -               nsp = &xfs_namespaces[ns];
5128 -               arraytop = context->count + nsp->namelen + namelen+1;
5129 +               arraytop = context->count + namesp->attr_namelen + namelen + 1;
5130                 if (arraytop > context->firstu) {
5131                         context->count = -1;    /* insufficient space */
5132                         return(1);
5133                 }
5134                 offset = (char *)context->alist + context->count;
5135 -               strncpy(offset, nsp->name, nsp->namelen);       /* namespace */
5136 -               offset += nsp->namelen;
5137 +               strncpy(offset, namesp->attr_name, namesp->attr_namelen);
5138 +               offset += namesp->attr_namelen;
5139                 strncpy(offset, name, namelen);                 /* real name */
5140                 offset += namelen;
5141                 *offset = '\0';
5142 -               context->count += nsp->namelen + namelen + 1;
5143 +               context->count += namesp->attr_namelen + namelen + 1;
5144                 return(0);
5145         }
5146  
5147 diff -urN linux.org/fs/xfs/xfs_attr_leaf.h linux/fs/xfs/xfs_attr_leaf.h
5148 --- linux.org/fs/xfs/xfs_attr_leaf.h    2003-12-31 05:46:18.000000000 +0100
5149 +++ linux/fs/xfs/xfs_attr_leaf.h        2004-01-02 04:21:42.000000000 +0100
5150 @@ -1,5 +1,5 @@
5151  /*
5152 - * Copyright (c) 2000, 2002 Silicon Graphics, Inc.  All Rights Reserved.
5153 + * Copyright (c) 2000, 2002-2003 Silicon Graphics, Inc.  All Rights Reserved.
5154   *
5155   * This program is free software; you can redistribute it and/or modify it
5156   * under the terms of version 2 of the GNU General Public License as
5157 @@ -44,6 +44,7 @@
5158  
5159  struct attrlist;
5160  struct attrlist_cursor_kern;
5161 +struct attrnames;
5162  struct xfs_dabuf;
5163  struct xfs_da_args;
5164  struct xfs_da_state;
5165 @@ -128,7 +129,7 @@
5166   * on the system call, they are "or"ed together for various operations.
5167   */
5168  #define        XFS_ATTR_LOCAL_BIT      0       /* attr is stored locally */
5169 -#define        XFS_ATTR_ROOT_BIT       1       /* limit access to attr to userid 0 */
5170 +#define        XFS_ATTR_ROOT_BIT       1       /* limit access to trusted attrs */
5171  #define        XFS_ATTR_INCOMPLETE_BIT 7       /* attr in middle of create/delete */
5172  #define XFS_ATTR_LOCAL         (1 << XFS_ATTR_LOCAL_BIT)
5173  #define XFS_ATTR_ROOT          (1 << XFS_ATTR_ROOT_BIT)
5174 @@ -299,7 +300,8 @@
5175                                         int *local);
5176  int    xfs_attr_leaf_entsize(struct xfs_attr_leafblock *leaf, int index);
5177  int    xfs_attr_put_listent(struct xfs_attr_list_context *context,
5178 -                            int ns, char *name, int namelen, int valuelen);
5179 +                            struct attrnames *, char *name, int namelen,
5180 +                            int valuelen);
5181  int    xfs_attr_rolltrans(struct xfs_trans **transp, struct xfs_inode *dp);
5182  
5183  #endif /* __XFS_ATTR_LEAF_H__ */
5184 diff -urN linux.org/fs/xfs/xfs_attr_sf.h linux/fs/xfs/xfs_attr_sf.h
5185 --- linux.org/fs/xfs/xfs_attr_sf.h      2003-12-31 05:46:54.000000000 +0100
5186 +++ linux/fs/xfs/xfs_attr_sf.h  2004-01-02 04:21:42.000000000 +0100
5187 @@ -104,14 +104,7 @@
5188         (INT_GET(((xfs_attr_shortform_t *)((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT))
5189  #endif
5190  
5191 -#ifdef XFS_ALL_TRACE
5192 -#define        XFS_ATTR_TRACE
5193 -#endif
5194 -
5195 -#if !defined(DEBUG)
5196 -#undef XFS_ATTR_TRACE
5197 -#endif
5198 -
5199 +#if defined(XFS_ATTR_TRACE)
5200  /*
5201   * Kernel tracing support for attribute lists
5202   */
5203 @@ -121,6 +114,7 @@
5204  struct xfs_attr_leafblock;
5205  
5206  #define        XFS_ATTR_TRACE_SIZE     4096    /* size of global trace buffer */
5207 +extern ktrace_t        *xfs_attr_trace_buf;
5208  
5209  /*
5210   * Trace record types.
5211 @@ -130,8 +124,6 @@
5212  #define        XFS_ATTR_KTRACE_L_CB    3       /* context, btree */
5213  #define        XFS_ATTR_KTRACE_L_CL    4       /* context, leaf */
5214  
5215 -#if defined(XFS_ATTR_TRACE)
5216 -
5217  void xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context);
5218  void xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
5219                               struct xfs_da_intnode *node);
5220 diff -urN linux.org/fs/xfs/xfs_bmap_btree.c linux/fs/xfs/xfs_bmap_btree.c
5221 --- linux.org/fs/xfs/xfs_bmap_btree.c   2003-12-31 05:47:31.000000000 +0100
5222 +++ linux/fs/xfs/xfs_bmap_btree.c       2004-01-02 04:21:42.000000000 +0100
5223 @@ -81,6 +81,13 @@
5224  
5225  
5226  #if defined(XFS_BMBT_TRACE)
5227 +
5228 +static char    ARGS[] = "args";
5229 +static char    ENTRY[] = "entry";
5230 +static char    ERROR[] = "error";
5231 +#undef EXIT
5232 +static char    EXIT[] = "exit";
5233 +
5234  /*
5235   * Add a trace buffer entry for the arguments given to the routine,
5236   * generic form.
5237 @@ -305,11 +312,6 @@
5238         xfs_bmbt_trace_argik(fname, c, i, k, __LINE__)
5239  #define        XFS_BMBT_TRACE_CURSOR(c,s)      \
5240         xfs_bmbt_trace_cursor(fname, c, s, __LINE__)
5241 -static char    ARGS[] = "args";
5242 -static char    ENTRY[] = "entry";
5243 -static char    ERROR[] = "error";
5244 -#undef EXIT
5245 -static char    EXIT[] = "exit";
5246  #else
5247  #define        XFS_BMBT_TRACE_ARGBI(c,b,i)
5248  #define        XFS_BMBT_TRACE_ARGBII(c,b,i,j)
5249 diff -urN linux.org/fs/xfs/xfs_bmap_btree.h linux/fs/xfs/xfs_bmap_btree.h
5250 --- linux.org/fs/xfs/xfs_bmap_btree.h   2003-12-31 05:47:25.000000000 +0100
5251 +++ linux/fs/xfs/xfs_bmap_btree.h       2004-01-02 04:21:43.000000000 +0100
5252 @@ -435,6 +435,10 @@
5253          INT_GET((bb)->bb_numrecs, ARCH_CONVERT) <= (mp)->m_bmap_dmxr[(level) != 0])
5254  #endif
5255  
5256 +
5257 +#ifdef __KERNEL__
5258 +
5259 +#if defined(XFS_BMBT_TRACE)
5260  /*
5261   * Trace buffer entry types.
5262   */
5263 @@ -449,18 +453,9 @@
5264  
5265  #define XFS_BMBT_TRACE_SIZE    4096    /* size of global trace buffer */
5266  #define XFS_BMBT_KTRACE_SIZE   32      /* size of per-inode trace buffer */
5267 -
5268 -#if defined(XFS_ALL_TRACE)
5269 -#define XFS_BMBT_TRACE
5270 +extern ktrace_t        *xfs_bmbt_trace_buf;
5271  #endif
5272  
5273 -#if !defined(DEBUG)
5274 -#undef XFS_BMBT_TRACE
5275 -#endif
5276 -
5277 -
5278 -#ifdef __KERNEL__
5279 -
5280  /*
5281   * Prototypes for xfs_bmap.c to call.
5282   */
5283 diff -urN linux.org/fs/xfs/xfs_bmap.c linux/fs/xfs/xfs_bmap.c
5284 --- linux.org/fs/xfs/xfs_bmap.c 2003-12-31 05:48:24.000000000 +0100
5285 +++ linux/fs/xfs/xfs_bmap.c     2004-01-02 04:21:42.000000000 +0100
5286 @@ -68,9 +68,6 @@
5287  #include "xfs_trans_space.h"
5288  #include "xfs_buf_item.h"
5289  
5290 -#ifdef DEBUG
5291 -ktrace_t       *xfs_bmap_trace_buf;
5292 -#endif
5293  
5294  #ifdef XFSDEBUG
5295  STATIC void
5296 @@ -404,7 +401,7 @@
5297  #define        xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
5298  #endif /* DEBUG */
5299  
5300 -#if defined(DEBUG) && defined(XFS_RW_TRACE)
5301 +#if defined(XFS_RW_TRACE)
5302  STATIC void
5303  xfs_bunmap_trace(
5304         xfs_inode_t             *ip,
5305 @@ -414,7 +411,7 @@
5306         inst_t                  *ra);
5307  #else
5308  #define        xfs_bunmap_trace(ip, bno, len, flags, ra)
5309 -#endif /* DEBUG && XFS_RW_TRACE */
5310 +#endif /* XFS_RW_TRACE */
5311  
5312  STATIC int
5313  xfs_bmap_count_tree(
5314 @@ -3543,6 +3540,8 @@
5315  
5316  
5317  #ifdef XFS_BMAP_TRACE
5318 +ktrace_t       *xfs_bmap_trace_buf;
5319 +
5320  /*
5321   * Add a bmap trace buffer entry.  Base routine for the others.
5322   */
5323 @@ -3575,14 +3574,14 @@
5324                 (void *)(__psint_t)cnt,
5325                 (void *)(__psunsigned_t)(ip->i_ino >> 32),
5326                 (void *)(__psunsigned_t)(unsigned)ip->i_ino,
5327 -               (void *)(__psunsigned_t)(INT_GET(r1->l0, ARCH_CONVERT) >> 32),
5328 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r1->l0, ARCH_CONVERT)),
5329 -               (void *)(__psunsigned_t)(INT_GET(r1->l1, ARCH_CONVERT) >> 32),
5330 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r1->l1, ARCH_CONVERT)),
5331 -               (void *)(__psunsigned_t)(INT_GET(r2->l0, ARCH_CONVERT) >> 32),
5332 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r2->l0, ARCH_CONVERT)),
5333 -               (void *)(__psunsigned_t)(INT_GET(r2->l1, ARCH_CONVERT) >> 32),
5334 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r2->l1, ARCH_CONVERT))
5335 +               (void *)(__psunsigned_t)(r1->l0 >> 32),
5336 +               (void *)(__psunsigned_t)(unsigned)(r1->l0),
5337 +               (void *)(__psunsigned_t)(r1->l1 >> 32),
5338 +               (void *)(__psunsigned_t)(unsigned)(r1->l1),
5339 +               (void *)(__psunsigned_t)(r2->l0 >> 32),
5340 +               (void *)(__psunsigned_t)(unsigned)(r2->l0),
5341 +               (void *)(__psunsigned_t)(r2->l1 >> 32),
5342 +               (void *)(__psunsigned_t)(unsigned)(r2->l1)
5343                 );
5344         ASSERT(ip->i_xtrace);
5345         ktrace_enter(ip->i_xtrace,
5346 @@ -3592,14 +3591,14 @@
5347                 (void *)(__psint_t)cnt,
5348                 (void *)(__psunsigned_t)(ip->i_ino >> 32),
5349                 (void *)(__psunsigned_t)(unsigned)ip->i_ino,
5350 -               (void *)(__psunsigned_t)(INT_GET(r1->l0, ARCH_CONVERT) >> 32),
5351 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r1->l0, ARCH_CONVERT)),
5352 -               (void *)(__psunsigned_t)(INT_GET(r1->l1, ARCH_CONVERT) >> 32),
5353 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r1->l1, ARCH_CONVERT)),
5354 -               (void *)(__psunsigned_t)(INT_GET(r2->l0, ARCH_CONVERT) >> 32),
5355 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r2->l0, ARCH_CONVERT)),
5356 -               (void *)(__psunsigned_t)(INT_GET(r2->l1, ARCH_CONVERT) >> 32),
5357 -               (void *)(__psunsigned_t)(unsigned)(INT_GET(r2->l1, ARCH_CONVERT))
5358 +               (void *)(__psunsigned_t)(r1->l0 >> 32),
5359 +               (void *)(__psunsigned_t)(unsigned)(r1->l0),
5360 +               (void *)(__psunsigned_t)(r1->l1 >> 32),
5361 +               (void *)(__psunsigned_t)(unsigned)(r1->l1),
5362 +               (void *)(__psunsigned_t)(r2->l0 >> 32),
5363 +               (void *)(__psunsigned_t)(unsigned)(r2->l0),
5364 +               (void *)(__psunsigned_t)(r2->l1 >> 32),
5365 +               (void *)(__psunsigned_t)(unsigned)(r2->l1)
5366                 );
5367  }
5368  
5369 @@ -3722,7 +3721,7 @@
5370         return rval;
5371  }
5372  
5373 -#if defined(DEBUG) && defined(XFS_RW_TRACE)
5374 +#if defined(XFS_RW_TRACE)
5375  STATIC void
5376  xfs_bunmap_trace(
5377         xfs_inode_t             *ip,
5378 @@ -3742,7 +3741,7 @@
5379                 (void *)(__psint_t)((xfs_dfiloff_t)bno & 0xffffffff),
5380                 (void *)(__psint_t)len,
5381                 (void *)(__psint_t)flags,
5382 -               (void *)(__psint_t)private.p_cpuid,
5383 +               (void *)(unsigned long)current_cpu(),
5384                 (void *)ra,
5385                 (void *)0,
5386                 (void *)0,
5387 diff -urN linux.org/fs/xfs/xfs_bmap.h linux/fs/xfs/xfs_bmap.h
5388 --- linux.org/fs/xfs/xfs_bmap.h 2003-12-31 05:46:44.000000000 +0100
5389 +++ linux/fs/xfs/xfs_bmap.h     2004-01-02 04:21:42.000000000 +0100
5390 @@ -90,26 +90,6 @@
5391  #define        DELAYSTARTBLOCK         ((xfs_fsblock_t)-1LL)
5392  #define        HOLESTARTBLOCK          ((xfs_fsblock_t)-2LL)
5393  
5394 -/*
5395 - * Trace operations for bmap extent tracing
5396 - */
5397 -#define        XFS_BMAP_KTRACE_DELETE  1
5398 -#define        XFS_BMAP_KTRACE_INSERT  2
5399 -#define        XFS_BMAP_KTRACE_PRE_UP  3
5400 -#define        XFS_BMAP_KTRACE_POST_UP 4
5401 -
5402 -#define        XFS_BMAP_TRACE_SIZE     4096    /* size of global trace buffer */
5403 -#define        XFS_BMAP_KTRACE_SIZE    32      /* size of per-inode trace buffer */
5404 -
5405 -#if defined(XFS_ALL_TRACE)
5406 -#define        XFS_BMAP_TRACE
5407 -#endif
5408 -
5409 -#if !defined(DEBUG)
5410 -#undef XFS_BMAP_TRACE
5411 -#endif
5412 -
5413 -
5414  #if XFS_WANT_FUNCS || (XFS_WANT_SPACE && XFSSO_XFS_BMAP_INIT)
5415  void xfs_bmap_init(xfs_bmap_free_t *flp, xfs_fsblock_t *fbp);
5416  #define        XFS_BMAP_INIT(flp,fbp)  xfs_bmap_init(flp,fbp)
5417 @@ -142,6 +122,33 @@
5418  } xfs_bmalloca_t;
5419  
5420  #ifdef __KERNEL__
5421 +
5422 +#if defined(XFS_BMAP_TRACE)
5423 +/*
5424 + * Trace operations for bmap extent tracing
5425 + */
5426 +#define        XFS_BMAP_KTRACE_DELETE  1
5427 +#define        XFS_BMAP_KTRACE_INSERT  2
5428 +#define        XFS_BMAP_KTRACE_PRE_UP  3
5429 +#define        XFS_BMAP_KTRACE_POST_UP 4
5430 +
5431 +#define        XFS_BMAP_TRACE_SIZE     4096    /* size of global trace buffer */
5432 +#define        XFS_BMAP_KTRACE_SIZE    32      /* size of per-inode trace buffer */
5433 +extern ktrace_t        *xfs_bmap_trace_buf;
5434 +
5435 +/*
5436 + * Add bmap trace insert entries for all the contents of the extent list.
5437 + */
5438 +void
5439 +xfs_bmap_trace_exlist(
5440 +       char                    *fname,         /* function name */
5441 +       struct xfs_inode        *ip,            /* incore inode pointer */
5442 +       xfs_extnum_t            cnt,            /* count of entries in list */
5443 +       int                     whichfork);     /* data or attr fork */
5444 +#else
5445 +#define        xfs_bmap_trace_exlist(f,ip,c,w)
5446 +#endif
5447 +
5448  /*
5449   * Convert inode from non-attributed to attributed.
5450   * Must not be in a transaction, ip must not be locked.
5451 @@ -260,20 +267,6 @@
5452         struct xfs_inode        *ip,            /* incore inode */
5453         int                     whichfork);     /* data or attr fork */
5454  
5455 -#if defined(XFS_BMAP_TRACE)
5456 -/*
5457 - * Add bmap trace insert entries for all the contents of the extent list.
5458 - */
5459 -void
5460 -xfs_bmap_trace_exlist(
5461 -       char                    *fname,         /* function name */
5462 -       struct xfs_inode        *ip,            /* incore inode pointer */
5463 -       xfs_extnum_t            cnt,            /* count of entries in list */
5464 -       int                     whichfork);     /* data or attr fork */
5465 -#else
5466 -#define        xfs_bmap_trace_exlist(f,ip,c,w)
5467 -#endif
5468 -
5469  /*
5470   * Map file blocks to filesystem blocks.
5471   * File range is given by the bno/len pair.
5472 @@ -375,7 +368,7 @@
5473  int
5474  xfs_bmap_count_blocks(
5475         xfs_trans_t             *tp,
5476 -       xfs_inode_t             *ip,
5477 +       struct xfs_inode        *ip,
5478         int                     whichfork,
5479         int                     *count);
5480  
5481 diff -urN linux.org/fs/xfs/xfs_buf.h linux/fs/xfs/xfs_buf.h
5482 --- linux.org/fs/xfs/xfs_buf.h  2003-12-31 05:48:37.000000000 +0100
5483 +++ linux/fs/xfs/xfs_buf.h      2004-01-02 04:21:43.000000000 +0100
5484 @@ -181,7 +181,7 @@
5485  #define XFS_BUF_SET_VTYPE(bp, type)
5486  #define XFS_BUF_SET_REF(bp, ref)
5487  
5488 -#define XFS_BUF_ISPINNED(bp)   pagebuf_ispin(bp)
5489 +#define XFS_BUF_ISPINNED(bp)   pagebuf_ispin(bp)
5490  
5491  #define XFS_BUF_VALUSEMA(bp)   pagebuf_lock_value(bp)
5492  #define XFS_BUF_CPSEMA(bp)     (pagebuf_cond_lock(bp) == 0)
5493 @@ -191,13 +191,11 @@
5494  
5495  /* setup the buffer target from a buftarg structure */
5496  #define XFS_BUF_SET_TARGET(bp, target) \
5497 -       (bp)->pb_target = (target)
5498 -
5499 +               (bp)->pb_target = (target)
5500  #define XFS_BUF_TARGET(bp)     ((bp)->pb_target)
5501 +#define XFS_BUFTARG_NAME(target)       \
5502 +               pagebuf_target_name(target)
5503  
5504 -#define XFS_BUFTARG_NAME(target) \
5505 -       ({ char __b[BDEVNAME_SIZE]; bdevname((target->pbr_bdev), __b); __b; })
5506 -       
5507  #define XFS_BUF_SET_VTYPE_REF(bp, type, ref)
5508  #define XFS_BUF_SET_VTYPE(bp, type)
5509  #define XFS_BUF_SET_REF(bp, ref)
5510 @@ -231,18 +229,11 @@
5511         pagebuf_rele(bp);
5512  }
5513  
5514 -
5515  #define xfs_bpin(bp)           pagebuf_pin(bp)
5516  #define xfs_bunpin(bp)         pagebuf_unpin(bp)
5517  
5518 -#ifdef PAGEBUF_TRACE
5519 -# define PB_DEFINE_TRACES
5520 -# include <pagebuf/page_buf_trace.h>
5521 -# define xfs_buftrace(id, bp)  PB_TRACE(bp, PB_TRACE_REC(external), (void *)id)
5522 -#else
5523 -# define xfs_buftrace(id, bp)  do { } while (0)
5524 -#endif
5525 -
5526 +#define xfs_buftrace(id, bp)   \
5527 +           pagebuf_trace(bp, id, NULL, (void *)__builtin_return_address(0))
5528  
5529  #define xfs_biodone(pb)                    \
5530             pagebuf_iodone(pb, (pb->pb_flags & PBF_FS_DATAIOD), 0)
5531 diff -urN linux.org/fs/xfs/xfs_buf_item.c linux/fs/xfs/xfs_buf_item.c
5532 --- linux.org/fs/xfs/xfs_buf_item.c     2003-12-31 05:46:23.000000000 +0100
5533 +++ linux/fs/xfs/xfs_buf_item.c 2004-01-02 04:21:43.000000000 +0100
5534 @@ -1207,13 +1207,14 @@
5535                      (void *)((unsigned long)bip->bli_flags),
5536                      (void *)((unsigned long)bip->bli_recur),
5537                      (void *)((unsigned long)atomic_read(&bip->bli_refcount)),
5538 -                    (void *)XFS_BUF_ADDR(bp),
5539 +                    (void *)((unsigned long)
5540 +                               (0xFFFFFFFF & XFS_BUF_ADDR(bp) >> 32)),
5541 +                    (void *)((unsigned long)(0xFFFFFFFF & XFS_BUF_ADDR(bp))),
5542                      (void *)((unsigned long)XFS_BUF_COUNT(bp)),
5543 -                    (void *)((unsigned long)(0xFFFFFFFF & (XFS_BFLAGS(bp) >> 32))),
5544 -                    (void *)((unsigned long)(0xFFFFFFFF & XFS_BFLAGS(bp))),
5545 +                    (void *)((unsigned long)XFS_BUF_BFLAGS(bp)),
5546                      XFS_BUF_FSPRIVATE(bp, void *),
5547                      XFS_BUF_FSPRIVATE2(bp, void *),
5548 -                    (void *)((unsigned long)bp->b_pincount),
5549 +                    (void *)(unsigned long)XFS_BUF_ISPINNED(bp),
5550                      (void *)XFS_BUF_IODONE_FUNC(bp),
5551                      (void *)((unsigned long)(XFS_BUF_VALUSEMA(bp))),
5552                      (void *)bip->bli_item.li_desc,
5553 diff -urN linux.org/fs/xfs/xfs_buf_item.h linux/fs/xfs/xfs_buf_item.h
5554 --- linux.org/fs/xfs/xfs_buf_item.h     2003-12-31 05:48:00.000000000 +0100
5555 +++ linux/fs/xfs/xfs_buf_item.h 2004-01-02 04:21:43.000000000 +0100
5556 @@ -104,6 +104,15 @@
5557  struct xfs_buf;
5558  struct ktrace;
5559  struct xfs_mount;
5560 +struct xfs_buf_log_item;
5561 +
5562 +#if defined(XFS_BLI_TRACE)
5563 +#define        XFS_BLI_TRACE_SIZE      32
5564 +
5565 +void   xfs_buf_item_trace(char *, struct xfs_buf_log_item *);
5566 +#else
5567 +#define        xfs_buf_item_trace(id, bip)
5568 +#endif
5569  
5570  /*
5571   * This is the in core log item structure used to track information
5572 @@ -116,7 +125,7 @@
5573         unsigned int            bli_flags;      /* misc flags */
5574         unsigned int            bli_recur;      /* lock recursion count */
5575         atomic_t                bli_refcount;   /* cnt of tp refs */
5576 -#ifdef DEBUG
5577 +#ifdef XFS_BLI_TRACE
5578         struct ktrace           *bli_trace;     /* event trace buf */
5579  #endif
5580  #ifdef XFS_TRANS_DEBUG
5581 @@ -137,23 +146,6 @@
5582         struct xfs_buf_cancel   *bc_next;
5583  } xfs_buf_cancel_t;
5584  
5585 -#define        XFS_BLI_TRACE_SIZE      32
5586 -
5587 -
5588 -#if defined(XFS_ALL_TRACE)
5589 -#define        XFS_BLI_TRACE
5590 -#endif
5591 -
5592 -#if !defined(DEBUG)
5593 -#undef XFS_BLI_TRACE
5594 -#endif
5595 -
5596 -#if defined(XFS_BLI_TRACE)
5597 -void   xfs_buf_item_trace(char *, xfs_buf_log_item_t *);
5598 -#else
5599 -#define        xfs_buf_item_trace(id, bip)
5600 -#endif
5601 -
5602  void   xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);
5603  void   xfs_buf_item_relse(struct xfs_buf *);
5604  void   xfs_buf_item_log(xfs_buf_log_item_t *, uint, uint);
5605 diff -urN linux.org/fs/xfs/xfs_da_btree.c linux/fs/xfs/xfs_da_btree.c
5606 --- linux.org/fs/xfs/xfs_da_btree.c     2003-12-31 05:48:06.000000000 +0100
5607 +++ linux/fs/xfs/xfs_da_btree.c 2004-01-02 04:21:43.000000000 +0100
5608 @@ -66,13 +66,6 @@
5609  #include "xfs_error.h"
5610  #include "xfs_bit.h"
5611  
5612 -#if defined(XFSDEBUG) && defined(CONFIG_KDB)
5613 -#undef xfs_buftrace
5614 -#define xfs_buftrace(A,B) \
5615 -       printk("    xfs_buftrace : %s (0x%p)\n", A, B); \
5616 -       BUG();
5617 -#endif
5618 -
5619  /*
5620   * xfs_da_btree.c
5621   *
5622 diff -urN linux.org/fs/xfs/xfs_dfrag.c linux/fs/xfs/xfs_dfrag.c
5623 --- linux.org/fs/xfs/xfs_dfrag.c        2003-12-31 05:46:28.000000000 +0100
5624 +++ linux/fs/xfs/xfs_dfrag.c    2004-01-02 04:21:43.000000000 +0100
5625 @@ -153,12 +153,12 @@
5626         if ((error = _MAC_XFS_IACCESS(tip, MACWRITE, NULL))) {
5627                 goto error0;
5628         }
5629 -       if ((current->fsuid != ip->i_d.di_uid) &&
5630 +       if ((current_fsuid(cred) != ip->i_d.di_uid) &&
5631             (error = xfs_iaccess(ip, S_IWUSR, NULL)) &&
5632             !capable_cred(NULL, CAP_FOWNER)) {
5633                 goto error0;
5634         }
5635 -       if ((current->fsuid != tip->i_d.di_uid) &&
5636 +       if ((current_fsuid(cred) != tip->i_d.di_uid) &&
5637             (error = xfs_iaccess(tip, S_IWUSR, NULL)) &&
5638             !capable_cred(NULL, CAP_FOWNER)) {
5639                 goto error0;
5640 diff -urN linux.org/fs/xfs/xfs_dir2_trace.c linux/fs/xfs/xfs_dir2_trace.c
5641 --- linux.org/fs/xfs/xfs_dir2_trace.c   2003-12-31 05:48:09.000000000 +0100
5642 +++ linux/fs/xfs/xfs_dir2_trace.c       2004-01-02 04:21:44.000000000 +0100
5643 @@ -1,5 +1,5 @@
5644  /*
5645 - * Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
5646 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
5647   *
5648   * This program is free software; you can redistribute it and/or modify it
5649   * under the terms of version 2 of the GNU General Public License as
5650 @@ -64,36 +64,37 @@
5651         char            *where,
5652         char            *name,
5653         int             namelen,
5654 -       __psunsigned_t  a0,
5655 -       __psunsigned_t  a1,
5656 -       __psunsigned_t  a2,
5657 -       __psunsigned_t  a3,
5658 -       __psunsigned_t  a4,
5659 -       __psunsigned_t  a5,
5660 -       __psunsigned_t  a6)
5661 +       void            *a0,
5662 +       void            *a1,
5663 +       void            *a2,
5664 +       void            *a3,
5665 +       void            *a4,
5666 +       void            *a5,
5667 +       void            *a6,
5668 +       void            *a7)
5669  {
5670 -       __psunsigned_t  n[6];
5671 +       void            *n[5];
5672  
5673         ASSERT(xfs_dir2_trace_buf);
5674         ASSERT(dp->i_dir_trace);
5675         if (name)
5676 -               memcpy(n, name, min(sizeof(n), namelen));
5677 +               memcpy(n, name, min((int)sizeof(n), namelen));
5678         else
5679                 memset((char *)n, 0, sizeof(n));
5680         ktrace_enter(xfs_dir2_trace_buf,
5681 -               (void *)(__psunsigned_t)type, (void *)where,
5682 +               (void *)(long)type, (void *)where,
5683                 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
5684 -               (void *)a4, (void *)a5, (void *)a6,
5685 -               (void *)(__psunsigned_t)namelen,
5686 +               (void *)a4, (void *)a5, (void *)a6, (void *)a7,
5687 +               (void *)(long)namelen,
5688                 (void *)n[0], (void *)n[1], (void *)n[2],
5689 -               (void *)n[3], (void *)n[4], (void *)n[5]);
5690 +               (void *)n[3], (void *)n[4]);
5691         ktrace_enter(dp->i_dir_trace,
5692 -               (void *)(__psunsigned_t)type, (void *)where,
5693 +               (void *)(long)type, (void *)where,
5694                 (void *)a0, (void *)a1, (void *)a2, (void *)a3,
5695 -               (void *)a4, (void *)a5, (void *)a6,
5696 -               (void *)(__psunsigned_t)namelen,
5697 +               (void *)a4, (void *)a5, (void *)a6, (void *)a7,
5698 +               (void *)(long)namelen,
5699                 (void *)n[0], (void *)n[1], (void *)n[2],
5700 -               (void *)n[3], (void *)n[4], (void *)n[5]);
5701 +               (void *)n[3], (void *)n[4]);
5702  }
5703  
5704  void
5705 @@ -103,9 +104,11 @@
5706  {
5707         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS, where,
5708                 (char *)args->name, (int)args->namelen,
5709 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5710 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5711 -               (__psunsigned_t)args->justcheck, 0, 0);
5712 +               (void *)(unsigned long)args->hashval,
5713 +               (void *)((unsigned long)(args->inumber >> 32)),
5714 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5715 +               (void *)args->dp, (void *)args->trans,
5716 +               (void *)(unsigned long)args->justcheck, NULL, NULL);
5717  }
5718  
5719  void
5720 @@ -116,10 +119,12 @@
5721  {
5722         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_B, where,
5723                 (char *)args->name, (int)args->namelen,
5724 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5725 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5726 -               (__psunsigned_t)args->justcheck,
5727 -               (__psunsigned_t)(bp ? bp->bps[0] : NULL), 0);
5728 +               (void *)(unsigned long)args->hashval,
5729 +               (void *)((unsigned long)(args->inumber >> 32)),
5730 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5731 +               (void *)args->dp, (void *)args->trans,
5732 +               (void *)(unsigned long)args->justcheck,
5733 +               (void *)(bp ? bp->bps[0] : NULL), NULL);
5734  }
5735  
5736  void
5737 @@ -131,11 +136,13 @@
5738  {
5739         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BB, where,
5740                 (char *)args->name, (int)args->namelen,
5741 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5742 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5743 -               (__psunsigned_t)args->justcheck,
5744 -               (__psunsigned_t)(lbp ? lbp->bps[0] : NULL),
5745 -               (__psunsigned_t)(dbp ? dbp->bps[0] : NULL));
5746 +               (void *)(unsigned long)args->hashval,
5747 +               (void *)((unsigned long)(args->inumber >> 32)),
5748 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5749 +               (void *)args->dp, (void *)args->trans,
5750 +               (void *)(unsigned long)args->justcheck,
5751 +               (void *)(lbp ? lbp->bps[0] : NULL),
5752 +               (void *)(dbp ? dbp->bps[0] : NULL));
5753  }
5754  
5755  void
5756 @@ -148,12 +155,14 @@
5757         int             sd,
5758         int             c)
5759  {
5760 +       xfs_buf_t       *bpbs = bs ? bs->bps[0] : NULL;
5761 +       xfs_buf_t       *bpbd = bd ? bd->bps[0] : NULL;
5762 +
5763         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_BIBII, where,
5764                 (char *)args->name, (int)args->namelen,
5765 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5766 -               (__psunsigned_t)(bs ? bs->bps[0] : NULL), (__psunsigned_t)ss,
5767 -               (__psunsigned_t)(bd ? bd->bps[0] : NULL), (__psunsigned_t)sd,
5768 -               (__psunsigned_t)c);
5769 +               (void *)args->dp, (void *)args->trans,
5770 +               (void *)bpbs, (void *)(long)ss, (void *)bpbd, (void *)(long)sd,
5771 +               (void *)(long)c, NULL);
5772  }
5773  
5774  void
5775 @@ -163,12 +172,16 @@
5776         xfs_dir2_db_t   db,
5777         xfs_dabuf_t     *bp)
5778  {
5779 +       xfs_buf_t       *dbp = bp ? bp->bps[0] : NULL;
5780 +
5781         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_DB, where,
5782                 (char *)args->name, (int)args->namelen,
5783 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5784 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5785 -               (__psunsigned_t)args->justcheck, (__psunsigned_t)db,
5786 -               (__psunsigned_t)(bp ? bp->bps[0] : NULL));
5787 +               (void *)(unsigned long)args->hashval,
5788 +               (void *)((unsigned long)(args->inumber >> 32)),
5789 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5790 +               (void *)args->dp, (void *)args->trans,
5791 +               (void *)(unsigned long)args->justcheck, (void *)(long)db,
5792 +               (void *)dbp);
5793  }
5794  
5795  void
5796 @@ -179,9 +192,13 @@
5797  {
5798         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_I, where,
5799                 (char *)args->name, (int)args->namelen,
5800 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5801 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5802 -               (__psunsigned_t)args->justcheck, (__psunsigned_t)i, 0);
5803 +               (void *)(unsigned long)args->hashval,
5804 +               (void *)((unsigned long)(args->inumber >> 32)),
5805 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5806 +               (void *)args->dp, (void *)args->trans,
5807 +               (void *)(unsigned long)args->justcheck,
5808 +               (void *)((unsigned long)(i >> 32)),
5809 +               (void *)((unsigned long)(i & 0xFFFFFFFF)));
5810  }
5811  
5812  void
5813 @@ -192,9 +209,11 @@
5814  {
5815         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_S, where,
5816                 (char *)args->name, (int)args->namelen,
5817 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5818 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5819 -               (__psunsigned_t)args->justcheck, (__psunsigned_t)s, 0);
5820 +               (void *)(unsigned long)args->hashval,
5821 +               (void *)((unsigned long)(args->inumber >> 32)),
5822 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5823 +               (void *)args->dp, (void *)args->trans,
5824 +               (void *)(unsigned long)args->justcheck, (void *)(long)s, 0);
5825  }
5826  
5827  void
5828 @@ -204,11 +223,15 @@
5829         int             s,
5830         xfs_dabuf_t     *bp)
5831  {
5832 +       xfs_buf_t       *dbp = bp ? bp->bps[0] : NULL;
5833 +
5834         xfs_dir2_trace_enter(args->dp, XFS_DIR2_KTRACE_ARGS_SB, where,
5835                 (char *)args->name, (int)args->namelen,
5836 -               (__psunsigned_t)args->hashval, (__psunsigned_t)args->inumber,
5837 -               (__psunsigned_t)args->dp, (__psunsigned_t)args->trans,
5838 -               (__psunsigned_t)args->justcheck, (__psunsigned_t)s,
5839 -               (__psunsigned_t)(bp ? bp->bps[0] : NULL));
5840 +               (void *)(unsigned long)args->hashval,
5841 +               (void *)((unsigned long)(args->inumber >> 32)),
5842 +               (void *)((unsigned long)(args->inumber & 0xFFFFFFFF)),
5843 +               (void *)args->dp, (void *)args->trans,
5844 +               (void *)(unsigned long)args->justcheck, (void *)(long)s,
5845 +               (void *)dbp);
5846  }
5847  #endif /* XFS_DIR2_TRACE */
5848 diff -urN linux.org/fs/xfs/xfs_dir2_trace.h linux/fs/xfs/xfs_dir2_trace.h
5849 --- linux.org/fs/xfs/xfs_dir2_trace.h   2003-12-31 05:46:56.000000000 +0100
5850 +++ linux/fs/xfs/xfs_dir2_trace.h       2004-01-02 04:21:44.000000000 +0100
5851 @@ -36,20 +36,15 @@
5852   * Tracing for xfs v2 directories.
5853   */
5854  
5855 +#if defined(XFS_DIR2_TRACE)
5856 +
5857  struct ktrace;
5858  struct xfs_dabuf;
5859  struct xfs_da_args;
5860  
5861 -#ifdef XFS_ALL_TRACE
5862 -#define XFS_DIR2_TRACE
5863 -#endif /* XFS_ALL_TRACE */
5864 -
5865 -#if !defined(DEBUG)
5866 -#undef XFS_DIR2_TRACE
5867 -#endif /* !DEBUG */
5868 -
5869  #define        XFS_DIR2_GTRACE_SIZE            4096    /* global buffer */
5870  #define        XFS_DIR2_KTRACE_SIZE            32      /* per-inode buffer */
5871 +extern struct ktrace *xfs_dir2_trace_buf;
5872  
5873  #define        XFS_DIR2_KTRACE_ARGS            1       /* args only */
5874  #define        XFS_DIR2_KTRACE_ARGS_B          2       /* args + buffer */
5875 @@ -60,8 +55,6 @@
5876  #define        XFS_DIR2_KTRACE_ARGS_SB         7       /* args, int, buffer */
5877  #define        XFS_DIR2_KTRACE_ARGS_BIBII      8       /* args, buf/int/buf/int/int */
5878  
5879 -#ifdef XFS_DIR2_TRACE
5880 -
5881  void xfs_dir2_trace_args(char *where, struct xfs_da_args *args);
5882  void xfs_dir2_trace_args_b(char *where, struct xfs_da_args *args,
5883                            struct xfs_dabuf *bp);
5884 @@ -90,6 +83,4 @@
5885  
5886  #endif /* XFS_DIR2_TRACE */
5887  
5888 -extern struct ktrace *xfs_dir2_trace_buf;
5889 -
5890  #endif /* __XFS_DIR2_TRACE_H__ */
5891 diff -urN linux.org/fs/xfs/xfs_dir.c linux/fs/xfs/xfs_dir.c
5892 --- linux.org/fs/xfs/xfs_dir.c  2003-12-31 05:46:43.000000000 +0100
5893 +++ linux/fs/xfs/xfs_dir.c      2004-01-02 04:21:43.000000000 +0100
5894 @@ -1093,10 +1093,10 @@
5895  xfs_dir_trace_g_du(char *where, xfs_inode_t *dp, uio_t *uio)
5896  {
5897         xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DU, where,
5898 -                    (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
5899 -                    (__psunsigned_t)(uio->uio_offset >> 32),
5900 -                    (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
5901 -                    (__psunsigned_t)uio->uio_resid,
5902 +                    (void *)dp, (void *)dp->i_mount,
5903 +                    (void *)((unsigned long)(uio->uio_offset >> 32)),
5904 +                    (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
5905 +                    (void *)(unsigned long)uio->uio_resid,
5906                      NULL, NULL, NULL, NULL, NULL, NULL, NULL);
5907  }
5908  
5909 @@ -1107,11 +1107,11 @@
5910  xfs_dir_trace_g_dub(char *where, xfs_inode_t *dp, uio_t *uio, xfs_dablk_t bno)
5911  {
5912         xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUB, where,
5913 -                    (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
5914 -                    (__psunsigned_t)(uio->uio_offset >> 32),
5915 -                    (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
5916 -                    (__psunsigned_t)uio->uio_resid,
5917 -                    (__psunsigned_t)bno,
5918 +                    (void *)dp, (void *)dp->i_mount,
5919 +                    (void *)((unsigned long)(uio->uio_offset >> 32)),
5920 +                    (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
5921 +                    (void *)(unsigned long)uio->uio_resid,
5922 +                    (void *)(unsigned long)bno,
5923                      NULL, NULL, NULL, NULL, NULL, NULL);
5924  }
5925  
5926 @@ -1122,15 +1122,21 @@
5927  xfs_dir_trace_g_dun(char *where, xfs_inode_t *dp, uio_t *uio,
5928                         xfs_da_intnode_t *node)
5929  {
5930 +       int     last = INT_GET(node->hdr.count, ARCH_CONVERT) - 1;
5931 +
5932         xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUN, where,
5933 -                    (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
5934 -                    (__psunsigned_t)(uio->uio_offset >> 32),
5935 -                    (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
5936 -                    (__psunsigned_t)uio->uio_resid,
5937 -                    (__psunsigned_t)INT_GET(node->hdr.info.forw, ARCH_CONVERT),
5938 -                    (__psunsigned_t)INT_GET(node->hdr.count, ARCH_CONVERT),
5939 -                    (__psunsigned_t)INT_GET(node->btree[0].hashval, ARCH_CONVERT),
5940 -                    (__psunsigned_t)INT_GET(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT),
5941 +                    (void *)dp, (void *)dp->i_mount,
5942 +                    (void *)((unsigned long)(uio->uio_offset >> 32)),
5943 +                    (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
5944 +                    (void *)(unsigned long)uio->uio_resid,
5945 +                    (void *)(unsigned long)
5946 +                       INT_GET(node->hdr.info.forw, ARCH_CONVERT),
5947 +                    (void *)(unsigned long)
5948 +                       INT_GET(node->hdr.count, ARCH_CONVERT),
5949 +                    (void *)(unsigned long)
5950 +                       INT_GET(node->btree[0].hashval, ARCH_CONVERT),
5951 +                    (void *)(unsigned long)
5952 +                       INT_GET(node->btree[last].hashval, ARCH_CONVERT),
5953                      NULL, NULL, NULL);
5954  }
5955  
5956 @@ -1141,15 +1147,21 @@
5957  xfs_dir_trace_g_dul(char *where, xfs_inode_t *dp, uio_t *uio,
5958                         xfs_dir_leafblock_t *leaf)
5959  {
5960 +       int     last = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1;
5961 +
5962         xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUL, where,
5963 -                    (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
5964 -                    (__psunsigned_t)(uio->uio_offset >> 32),
5965 -                    (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
5966 -                    (__psunsigned_t)uio->uio_resid,
5967 -                    (__psunsigned_t)INT_GET(leaf->hdr.info.forw, ARCH_CONVERT),
5968 -                    (__psunsigned_t)INT_GET(leaf->hdr.count, ARCH_CONVERT),
5969 -                    (__psunsigned_t)INT_GET(leaf->entries[0].hashval, ARCH_CONVERT),
5970 -                    (__psunsigned_t)INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT),
5971 +                    (void *)dp, (void *)dp->i_mount,
5972 +                    (void *)((unsigned long)(uio->uio_offset >> 32)),
5973 +                    (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
5974 +                    (void *)(unsigned long)uio->uio_resid,
5975 +                    (void *)(unsigned long)
5976 +                       INT_GET(leaf->hdr.info.forw, ARCH_CONVERT),
5977 +                    (void *)(unsigned long)
5978 +                       INT_GET(leaf->hdr.count, ARCH_CONVERT),
5979 +                    (void *)(unsigned long)
5980 +                       INT_GET(leaf->entries[0].hashval, ARCH_CONVERT),
5981 +                    (void *)(unsigned long)
5982 +                       INT_GET(leaf->entries[last].hashval, ARCH_CONVERT),
5983                      NULL, NULL, NULL);
5984  }
5985  
5986 @@ -1161,11 +1173,12 @@
5987                         xfs_dir_leaf_entry_t *entry)
5988  {
5989         xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUE, where,
5990 -                    (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
5991 -                    (__psunsigned_t)(uio->uio_offset >> 32),
5992 -                    (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
5993 -                    (__psunsigned_t)uio->uio_resid,
5994 -                    (__psunsigned_t)INT_GET(entry->hashval, ARCH_CONVERT),
5995 +                    (void *)dp, (void *)dp->i_mount,
5996 +                    (void *)((unsigned long)(uio->uio_offset >> 32)),
5997 +                    (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
5998 +                    (void *)(unsigned long)uio->uio_resid,
5999 +                    (void *)(unsigned long)
6000 +                       INT_GET(entry->hashval, ARCH_CONVERT),
6001                      NULL, NULL, NULL, NULL, NULL, NULL);
6002  }
6003  
6004 @@ -1176,12 +1189,12 @@
6005  xfs_dir_trace_g_duc(char *where, xfs_inode_t *dp, uio_t *uio, xfs_off_t cookie)
6006  {
6007         xfs_dir_trace_enter(XFS_DIR_KTRACE_G_DUC, where,
6008 -                    (__psunsigned_t)dp, (__psunsigned_t)dp->i_mount,
6009 -                    (__psunsigned_t)(uio->uio_offset >> 32),
6010 -                    (__psunsigned_t)(uio->uio_offset & 0xFFFFFFFF),
6011 -                    (__psunsigned_t)uio->uio_resid,
6012 -                    (__psunsigned_t)(cookie >> 32),
6013 -                    (__psunsigned_t)(cookie & 0xFFFFFFFF),
6014 +                    (void *)dp, (void *)dp->i_mount,
6015 +                    (void *)((unsigned long)(uio->uio_offset >> 32)),
6016 +                    (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
6017 +                    (void *)(unsigned long)uio->uio_resid,
6018 +                    (void *)((unsigned long)(cookie >> 32)),
6019 +                    (void *)((unsigned long)(cookie & 0xFFFFFFFF)),
6020                      NULL, NULL, NULL, NULL, NULL);
6021  }
6022  
6023 @@ -1191,15 +1204,15 @@
6024   */
6025  void
6026  xfs_dir_trace_enter(int type, char *where,
6027 -                       __psunsigned_t a0, __psunsigned_t a1,
6028 -                       __psunsigned_t a2, __psunsigned_t a3,
6029 -                       __psunsigned_t a4, __psunsigned_t a5,
6030 -                       __psunsigned_t a6, __psunsigned_t a7,
6031 -                       __psunsigned_t a8, __psunsigned_t a9,
6032 -                       __psunsigned_t a10, __psunsigned_t a11)
6033 +                       void * a0, void * a1,
6034 +                       void * a2, void * a3,
6035 +                       void * a4, void * a5,
6036 +                       void * a6, void * a7,
6037 +                       void * a8, void * a9,
6038 +                       void * a10, void * a11)
6039  {
6040         ASSERT(xfs_dir_trace_buf);
6041 -       ktrace_enter(xfs_dir_trace_buf, (void *)((__psunsigned_t)type),
6042 +       ktrace_enter(xfs_dir_trace_buf, (void *)(unsigned long)type,
6043                                         (void *)where,
6044                                         (void *)a0, (void *)a1, (void *)a2,
6045                                         (void *)a3, (void *)a4, (void *)a5,
6046 diff -urN linux.org/fs/xfs/xfs_dir.h linux/fs/xfs/xfs_dir.h
6047 --- linux.org/fs/xfs/xfs_dir.h  2003-12-31 05:46:52.000000000 +0100
6048 +++ linux/fs/xfs/xfs_dir.h      2004-01-02 04:21:43.000000000 +0100
6049 @@ -43,14 +43,6 @@
6050   * as possible so as to fit into the literal area of the inode.
6051   */
6052  
6053 -#ifdef XFS_ALL_TRACE
6054 -#define        XFS_DIR_TRACE
6055 -#endif
6056 -
6057 -#if !defined(DEBUG)
6058 -#undef XFS_DIR_TRACE
6059 -#endif
6060 -
6061  /*========================================================================
6062   * Function prototypes for the kernel.
6063   *========================================================================*/
6064 diff -urN linux.org/fs/xfs/xfs_dir_sf.h linux/fs/xfs/xfs_dir_sf.h
6065 --- linux.org/fs/xfs/xfs_dir_sf.h       2003-12-31 05:47:55.000000000 +0100
6066 +++ linux/fs/xfs/xfs_dir_sf.h   2004-01-02 04:21:44.000000000 +0100
6067 @@ -126,13 +126,7 @@
6068                ((uint)sizeof(xfs_dir_sf_entry_t)-1)*(count) + (totallen))
6069  #endif
6070  
6071 -#ifdef XFS_ALL_TRACE
6072 -#define        XFS_DIR_TRACE
6073 -#endif
6074 -
6075 -#if !defined(DEBUG)
6076 -#undef XFS_DIR_TRACE
6077 -#endif
6078 +#if defined(XFS_DIR_TRACE)
6079  
6080  /*
6081   * Kernel tracing support for directories.
6082 @@ -145,6 +139,7 @@
6083  struct xfs_dir_leaf_entry;
6084  
6085  #define        XFS_DIR_TRACE_SIZE      4096    /* size of global trace buffer */
6086 +extern ktrace_t        *xfs_dir_trace_buf;
6087  
6088  /*
6089   * Trace record types.
6090 @@ -156,8 +151,6 @@
6091  #define        XFS_DIR_KTRACE_G_DUE    5       /* dp, uio, leaf entry */
6092  #define        XFS_DIR_KTRACE_G_DUC    6       /* dp, uio, cookie */
6093  
6094 -#if defined(XFS_DIR_TRACE)
6095 -
6096  void xfs_dir_trace_g_du(char *where, struct xfs_inode *dp, struct uio *uio);
6097  void xfs_dir_trace_g_dub(char *where, struct xfs_inode *dp, struct uio *uio,
6098                               xfs_dablk_t bno);
6099 @@ -170,12 +163,9 @@
6100  void xfs_dir_trace_g_duc(char *where, struct xfs_inode *dp, struct uio *uio,
6101                               xfs_off_t cookie);
6102  void xfs_dir_trace_enter(int type, char *where,
6103 -                            __psunsigned_t a0, __psunsigned_t a1,
6104 -                            __psunsigned_t a2, __psunsigned_t a3,
6105 -                            __psunsigned_t a4, __psunsigned_t a5,
6106 -                            __psunsigned_t a6, __psunsigned_t a7,
6107 -                            __psunsigned_t a8, __psunsigned_t a9,
6108 -                            __psunsigned_t a10, __psunsigned_t a11);
6109 +                            void *a0, void *a1, void *a2, void *a3,
6110 +                            void *a4, void *a5, void *a6, void *a7,
6111 +                            void *a8, void *a9, void *a10, void *a11);
6112  #else
6113  #define        xfs_dir_trace_g_du(w,d,u)
6114  #define        xfs_dir_trace_g_dub(w,d,u,b)
6115 diff -urN linux.org/fs/xfs/xfs_dmapi.h linux/fs/xfs/xfs_dmapi.h
6116 --- linux.org/fs/xfs/xfs_dmapi.h        2003-12-31 05:48:36.000000000 +0100
6117 +++ linux/fs/xfs/xfs_dmapi.h    2004-01-02 04:21:44.000000000 +0100
6118 @@ -175,14 +175,6 @@
6119                         DM_FLAGS_NDELAY : 0)
6120  #define AT_DELAY_FLAG(f) ((f&ATTR_NONBLOCK) ? DM_FLAGS_NDELAY : 0)
6121  
6122 -/*
6123 - *     Macros to turn caller specified delay/block flags into
6124 - *     dm_send_xxxx_event flag DM_FLAGS_NDELAY.
6125 - */
6126 -
6127 -#define FILP_DELAY_FLAG(filp) ((filp->f_flags&(O_NDELAY|O_NONBLOCK)) ? \
6128 -                       DM_FLAGS_NDELAY : 0)
6129 -
6130  
6131  extern struct bhv_vfsops xfs_dmops;
6132  
6133 diff -urN linux.org/fs/xfs/xfs_dmops.c linux/fs/xfs/xfs_dmops.c
6134 --- linux.org/fs/xfs/xfs_dmops.c        2003-12-31 05:48:36.000000000 +0100
6135 +++ linux/fs/xfs/xfs_dmops.c    2004-01-02 04:21:44.000000000 +0100
6136 @@ -43,8 +43,6 @@
6137  #include "xfs_dmapi.h"
6138  #include "xfs_mount.h"
6139  
6140 -
6141 -#ifndef CONFIG_XFS_DMAPI
6142  xfs_dmops_t    xfs_dmcore_xfs = {
6143         .xfs_send_data          = (xfs_send_data_t)fs_nosys,
6144         .xfs_send_mmap          = (xfs_send_mmap_t)fs_noerr,
6145 @@ -52,4 +50,3 @@
6146         .xfs_send_namesp        = (xfs_send_namesp_t)fs_nosys,
6147         .xfs_send_unmount       = (xfs_send_unmount_t)fs_noval,
6148  };
6149 -#endif /* CONFIG_XFS_DMAPI */
6150 diff -urN linux.org/fs/xfs/xfs_error.c linux/fs/xfs/xfs_error.c
6151 --- linux.org/fs/xfs/xfs_error.c        2003-12-31 05:48:26.000000000 +0100
6152 +++ linux/fs/xfs/xfs_error.c    2004-01-02 04:21:44.000000000 +0100
6153 @@ -102,7 +102,7 @@
6154         if (random() % randfactor)
6155                 return 0;
6156  
6157 -       memcpy(&fsid, fsidp, sizeof(fsid_t));
6158 +       memcpy(&fsid, fsidp, sizeof(xfs_fsid_t));
6159  
6160         for (i = 0; i < XFS_NUM_INJECT_ERROR; i++)  {
6161                 if (xfs_etest[i] == error_tag && xfs_etest_fsid[i] == fsid) {
6162 @@ -123,7 +123,7 @@
6163         int len;
6164         int64_t fsid;
6165  
6166 -       memcpy(&fsid, mp->m_fixedfsid, sizeof(fsid_t));
6167 +       memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t));
6168  
6169         for (i = 0; i < XFS_NUM_INJECT_ERROR; i++)  {
6170                 if (xfs_etest_fsid[i] == fsid && xfs_etest[i] == error_tag) {
6171 @@ -156,7 +156,7 @@
6172         int i;
6173         int64_t fsid;
6174  
6175 -       memcpy(&fsid, mp->m_fixedfsid, sizeof(fsid_t));
6176 +       memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t));
6177  
6178         for (i = 0; i < XFS_NUM_INJECT_ERROR; i++) {
6179                 if (xfs_etest_fsid[i] == fsid && xfs_etest[i] == error_tag) {
6180 @@ -209,7 +209,7 @@
6181  {
6182         int64_t fsid;
6183  
6184 -       memcpy(&fsid, mp->m_fixedfsid, sizeof(fsid_t));
6185 +       memcpy(&fsid, mp->m_fixedfsid, sizeof(xfs_fsid_t));
6186  
6187         return xfs_errortag_clearall_umount(fsid, mp->m_fsname, 1);
6188  }
6189 @@ -258,12 +258,6 @@
6190  }
6191  
6192  void
6193 -xfs_stack_trace(void)
6194 -{
6195 -       dump_stack();
6196 -}
6197 -
6198 -void
6199  xfs_error_report(
6200         char            *tag,
6201         int             level,
6202 diff -urN linux.org/fs/xfs/xfs_fsops.c linux/fs/xfs/xfs_fsops.c
6203 --- linux.org/fs/xfs/xfs_fsops.c        2003-12-31 05:48:18.000000000 +0100
6204 +++ linux/fs/xfs/xfs_fsops.c    2004-01-02 04:21:42.000000000 +0100
6205 @@ -51,6 +51,7 @@
6206  #include "xfs_fsops.h"
6207  #include "xfs_itable.h"
6208  #include "xfs_rw.h"
6209 +#include "xfs_refcache.h"
6210  #include "xfs_trans_space.h"
6211  #include "xfs_rtalloc.h"
6212  #include "xfs_dir2.h"
6213 @@ -593,6 +594,9 @@
6214         /* Stop new writers */
6215         xfs_start_freeze(mp, XFS_FREEZE_WRITE);
6216  
6217 +       /* Flush the refcache */
6218 +       xfs_refcache_purge_mp(mp);
6219 +
6220         /* Flush delalloc and delwri data */
6221         VFS_SYNC(vfsp, SYNC_DELWRI|SYNC_WAIT, NULL, error);
6222  
6223 diff -urN linux.org/fs/xfs/xfsidbg.c linux/fs/xfs/xfsidbg.c
6224 --- linux.org/fs/xfs/xfsidbg.c  2003-12-31 05:48:07.000000000 +0100
6225 +++ linux/fs/xfs/xfsidbg.c      2004-01-02 04:21:43.000000000 +0100
6226 @@ -31,7 +31,6 @@
6227   */
6228  
6229  #include "xfs.h"
6230 -#include "pagebuf/page_buf_internal.h"
6231  
6232  #include <linux/ctype.h>
6233  #include <linux/kdb.h>
6234 @@ -61,9 +60,11 @@
6235  #include "xfs_attr_sf.h"
6236  #include "xfs_dir_sf.h"
6237  #include "xfs_dir2_sf.h"
6238 +#include "xfs_dir2_trace.h"
6239  #include "xfs_dinode.h"
6240 -#include "xfs_inode.h"
6241 +#include "xfs_rw.h"
6242  #include "xfs_bmap.h"
6243 +#include "xfs_inode.h"
6244  #include "xfs_da_btree.h"
6245  #include "xfs_attr.h"
6246  #include "xfs_attr_leaf.h"
6247 @@ -72,18 +73,66 @@
6248  #include "xfs_dir2_leaf.h"
6249  #include "xfs_dir2_block.h"
6250  #include "xfs_dir2_node.h"
6251 -#include "xfs_dir2_trace.h"
6252  #include "xfs_log_priv.h"
6253  #include "xfs_log_recover.h"
6254 -#include "xfs_rw.h"
6255  #include "xfs_bit.h"
6256  #include "xfs_quota.h"
6257  #include "quota/xfs_qm.h"
6258 +#include "xfs_iomap.h"
6259  
6260  MODULE_AUTHOR("Silicon Graphics, Inc.");
6261  MODULE_DESCRIPTION("Additional kdb commands for debugging XFS");
6262  MODULE_LICENSE("GPL");
6263  
6264 +#define qprintf        kdb_printf
6265 +
6266 +/*
6267 + * Command table functions. (tracing)
6268 + */
6269 +#ifdef XFS_ALLOC_TRACE
6270 +static void    xfsidbg_xalatrace(int);
6271 +static void    xfsidbg_xalbtrace(xfs_agblock_t);
6272 +static void    xfsidbg_xalgtrace(xfs_agnumber_t);
6273 +static void    xfsidbg_xalmtrace(xfs_mount_t *);
6274 +static void    xfsidbg_xalttrace(int);
6275 +#endif
6276 +#ifdef XFS_ATTR_TRACE
6277 +static void    xfsidbg_xattrtrace(int);
6278 +#endif
6279 +#ifdef XFS_BLI_TRACE
6280 +static void    xfsidbg_xblitrace(xfs_buf_log_item_t *);
6281 +#endif
6282 +#ifdef XFS_BMAP_TRACE
6283 +static void    xfsidbg_xbmatrace(int);
6284 +static void    xfsidbg_xbmitrace(xfs_inode_t *);
6285 +static void    xfsidbg_xbmstrace(xfs_inode_t *);
6286 +static void    xfsidbg_xbxatrace(int);
6287 +static void    xfsidbg_xbxitrace(xfs_inode_t *);
6288 +static void    xfsidbg_xbxstrace(xfs_inode_t *);
6289 +#endif
6290 +#ifdef XFS_ILOCK_TRACE
6291 +static void    xfsidbg_xilock_trace(xfs_inode_t *);
6292 +static void    xfsidbg_xailock_trace(int);
6293 +#endif
6294 +#ifdef XFS_DIR_TRACE
6295 +static void    xfsidbg_xdirtrace(int);
6296 +#endif
6297 +#ifdef XFS_DIR2_TRACE
6298 +static void    xfsidbg_xdir2atrace(int);
6299 +static void    xfsidbg_xdir2itrace(xfs_inode_t *);
6300 +#endif
6301 +#ifdef XFS_LOG_TRACE
6302 +static void    xfsidbg_xiclogtrace(xlog_in_core_t *);
6303 +static void    xfsidbg_xlog_granttrace(xlog_t *);
6304 +#endif
6305 +#ifdef XFS_DQUOT_TRACE
6306 +static void    xfsidbg_xqm_dqtrace(xfs_dquot_t *);
6307 +#endif
6308 +#ifdef XFS_RW_TRACE
6309 +static void    xfsidbg_xrwtrace(xfs_inode_t *);
6310 +#endif
6311 +
6312 +
6313  /*
6314   * Command table functions.
6315   */
6316 @@ -91,9 +140,6 @@
6317  static void    xfsidbg_xagi(xfs_agi_t *);
6318  static void    xfsidbg_xaildump(xfs_mount_t *);
6319  static void    xfsidbg_xalloc(xfs_alloc_arg_t *);
6320 -#ifdef DEBUG
6321 -static void    xfsidbg_xalmtrace(xfs_mount_t *);
6322 -#endif
6323  static void    xfsidbg_xattrcontext(xfs_attr_list_context_t *);
6324  static void    xfsidbg_xattrleaf(xfs_attr_leafblock_t *);
6325  static void    xfsidbg_xattrsf(xfs_attr_shortform_t *);
6326 @@ -105,6 +151,8 @@
6327  static void    xfsidbg_xbtcur(xfs_btree_cur_t *);
6328  static void    xfsidbg_xbuf(xfs_buf_t *);
6329  static void    xfsidbg_xbuf_real(xfs_buf_t *, int);
6330 +static void    xfsidbg_xarg(int);
6331 +static void    xfsidbg_xchksum(uint *);
6332  static void    xfsidbg_xchash(xfs_mount_t *mp);
6333  static void    xfsidbg_xchashlist(xfs_chashlist_t *chl);
6334  static void    xfsidbg_xdaargs(xfs_da_args_t *);
6335 @@ -144,13 +192,18 @@
6336  static void    xfsidbg_xsb(xfs_sb_t *, int convert);
6337  static void    xfsidbg_xtp(xfs_trans_t *);
6338  static void    xfsidbg_xtrans_res(xfs_mount_t *);
6339 -#ifdef CONFIG_XFS_QUOTA
6340 +#ifdef CONFIG_XFS_QUOTA
6341  static void    xfsidbg_xqm(void);
6342  static void    xfsidbg_xqm_htab(void);
6343  static void    xfsidbg_xqm_freelist_print(xfs_frlist_t *qlist, char *title);
6344  static void    xfsidbg_xqm_freelist(void);
6345  #endif
6346  
6347 +#ifdef XFS_BMAP_TRACE
6348 +static void    xfs_convert_extent(xfs_bmbt_rec_32_t *, xfs_dfiloff_t *,
6349 +                               xfs_dfsbno_t *, xfs_dfilblks_t *, int *);
6350 +#endif
6351 +
6352  /* kdb wrappers */
6353  
6354  static int     kdbm_xfs_xagf(
6355 @@ -216,7 +269,8 @@
6356         return 0;
6357  }
6358  
6359 -static int     kdbm_xfs_xalloc(
6360 +#ifdef XFS_ALLOC_TRACE
6361 +static int     kdbm_xfs_xalatrace(
6362         int     argc,
6363         const char **argv,
6364         const char **envp,
6365 @@ -226,19 +280,19 @@
6366         int nextarg = 1;
6367         long offset = 0;
6368         int diag;
6369 -
6370 +       
6371         if (argc != 1)
6372                 return KDB_ARGCOUNT;
6373 +
6374         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6375         if (diag)
6376                 return diag;
6377  
6378 -       xfsidbg_xalloc((xfs_alloc_arg_t *) addr);
6379 +       xfsidbg_xalatrace((int) addr);
6380         return 0;
6381  }
6382  
6383 -#ifdef DEBUG
6384 -static int     kdbm_xfs_xalmtrace(
6385 +static int     kdbm_xfs_xalbtrace(
6386         int     argc,
6387         const char **argv,
6388         const char **envp,
6389 @@ -251,16 +305,16 @@
6390  
6391         if (argc != 1)
6392                 return KDB_ARGCOUNT;
6393 +
6394         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6395         if (diag)
6396                 return diag;
6397  
6398 -       xfsidbg_xalmtrace((xfs_mount_t *) addr);
6399 +       xfsidbg_xalbtrace((xfs_agblock_t) addr);
6400         return 0;
6401  }
6402 -#endif /* DEBUG */
6403  
6404 -static int     kdbm_xfs_xattrcontext(
6405 +static int     kdbm_xfs_xalgtrace(
6406         int     argc,
6407         const char **argv,
6408         const char **envp,
6409 @@ -273,15 +327,18 @@
6410  
6411         if (argc != 1)
6412                 return KDB_ARGCOUNT;
6413 +
6414         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6415         if (diag)
6416                 return diag;
6417  
6418 -       xfsidbg_xattrcontext((xfs_attr_list_context_t *) addr);
6419 +       xfsidbg_xalgtrace((xfs_agnumber_t) addr);
6420         return 0;
6421  }
6422 +#endif
6423  
6424 -static int     kdbm_xfs_xattrleaf(
6425 +#ifdef XFS_ATTR_TRACE
6426 +static int     kdbm_xfs_xattrtrace(
6427         int     argc,
6428         const char **argv,
6429         const char **envp,
6430 @@ -294,15 +351,18 @@
6431  
6432         if (argc != 1)
6433                 return KDB_ARGCOUNT;
6434 +
6435         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6436         if (diag)
6437                 return diag;
6438  
6439 -       xfsidbg_xattrleaf((xfs_attr_leafblock_t *) addr);
6440 +       xfsidbg_xattrtrace((int) addr);
6441         return 0;
6442  }
6443 +#endif
6444  
6445 -static int     kdbm_xfs_xattrsf(
6446 +#ifdef XFS_BLI_TRACE
6447 +static int     kdbm_xfs_xblitrace(
6448         int     argc,
6449         const char **argv,
6450         const char **envp,
6451 @@ -315,15 +375,18 @@
6452  
6453         if (argc != 1)
6454                 return KDB_ARGCOUNT;
6455 +
6456         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6457         if (diag)
6458                 return diag;
6459  
6460 -       xfsidbg_xattrsf((xfs_attr_shortform_t *) addr);
6461 +       xfsidbg_xblitrace((xfs_buf_log_item_t *) addr);
6462         return 0;
6463  }
6464 +#endif
6465  
6466 -static int     kdbm_xfs_xbirec(
6467 +#ifdef XFS_BMAP_TRACE
6468 +static int     kdbm_xfs_xbmatrace(
6469         int     argc,
6470         const char **argv,
6471         const char **envp,
6472 @@ -336,15 +399,16 @@
6473  
6474         if (argc != 1)
6475                 return KDB_ARGCOUNT;
6476 +
6477         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6478         if (diag)
6479                 return diag;
6480  
6481 -       xfsidbg_xbirec((xfs_bmbt_irec_t *) addr);
6482 +       xfsidbg_xbmatrace((int) addr);
6483         return 0;
6484  }
6485  
6486 -static int     kdbm_xfs_xbmalla(
6487 +static int     kdbm_xfs_xbmitrace(
6488         int     argc,
6489         const char **argv,
6490         const char **envp,
6491 @@ -357,15 +421,16 @@
6492  
6493         if (argc != 1)
6494                 return KDB_ARGCOUNT;
6495 +
6496         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6497         if (diag)
6498                 return diag;
6499  
6500 -       xfsidbg_xbmalla((xfs_bmalloca_t *)addr);
6501 +       xfsidbg_xbmitrace((xfs_inode_t *) addr);
6502         return 0;
6503  }
6504  
6505 -static int     kdbm_xfs_xbrec(
6506 +static int     kdbm_xfs_xbmstrace(
6507         int     argc,
6508         const char **argv,
6509         const char **envp,
6510 @@ -378,15 +443,16 @@
6511  
6512         if (argc != 1)
6513                 return KDB_ARGCOUNT;
6514 +
6515         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6516         if (diag)
6517                 return diag;
6518  
6519 -       xfsidbg_xbrec((xfs_bmbt_rec_64_t *) addr);
6520 +       xfsidbg_xbmstrace((xfs_inode_t *) addr);
6521         return 0;
6522  }
6523  
6524 -static int     kdbm_xfs_xbroot(
6525 +static int     kdbm_xfs_xbxatrace(
6526         int     argc,
6527         const char **argv,
6528         const char **envp,
6529 @@ -399,15 +465,16 @@
6530  
6531         if (argc != 1)
6532                 return KDB_ARGCOUNT;
6533 +
6534         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6535         if (diag)
6536                 return diag;
6537  
6538 -       xfsidbg_xbroot((xfs_inode_t *) addr);
6539 +       xfsidbg_xbxatrace((int) addr);
6540         return 0;
6541  }
6542  
6543 -static int     kdbm_xfs_xbroota(
6544 +static int     kdbm_xfs_xbxitrace(
6545         int     argc,
6546         const char **argv,
6547         const char **envp,
6548 @@ -420,15 +487,16 @@
6549  
6550         if (argc != 1)
6551                 return KDB_ARGCOUNT;
6552 +
6553         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6554         if (diag)
6555                 return diag;
6556  
6557 -       xfsidbg_xbroota((xfs_inode_t *) addr);
6558 +       xfsidbg_xbxitrace((xfs_inode_t *) addr);
6559         return 0;
6560  }
6561  
6562 -static int     kdbm_xfs_xbtcur(
6563 +static int     kdbm_xfs_xbxstrace(
6564         int     argc,
6565         const char **argv,
6566         const char **envp,
6567 @@ -441,15 +509,18 @@
6568  
6569         if (argc != 1)
6570                 return KDB_ARGCOUNT;
6571 +
6572         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6573         if (diag)
6574                 return diag;
6575  
6576 -       xfsidbg_xbtcur((xfs_btree_cur_t *) addr);
6577 +       xfsidbg_xbxstrace((xfs_inode_t *) addr);
6578         return 0;
6579  }
6580 +#endif
6581  
6582 -static int     kdbm_xfs_xbuf(
6583 +#ifdef XFS_DIR2_TRACE
6584 +static int     kdbm_xfs_xdir2atrace(
6585         int     argc,
6586         const char **argv,
6587         const char **envp,
6588 @@ -462,16 +533,16 @@
6589  
6590         if (argc != 1)
6591                 return KDB_ARGCOUNT;
6592 +
6593         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6594         if (diag)
6595                 return diag;
6596  
6597 -       xfsidbg_xbuf((xfs_buf_t *) addr);
6598 +       xfsidbg_xdir2atrace((int) addr);
6599         return 0;
6600  }
6601  
6602 -
6603 -static int     kdbm_xfs_xchash(
6604 +static int     kdbm_xfs_xdir2itrace(
6605         int     argc,
6606         const char **argv,
6607         const char **envp,
6608 @@ -484,15 +555,18 @@
6609  
6610         if (argc != 1)
6611                 return KDB_ARGCOUNT;
6612 +
6613         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6614         if (diag)
6615                 return diag;
6616  
6617 -       xfsidbg_xchash((xfs_mount_t *) addr);
6618 +       xfsidbg_xdir2itrace((xfs_inode_t *) addr);
6619         return 0;
6620  }
6621 +#endif
6622  
6623 -static int     kdbm_xfs_xchashlist(
6624 +#ifdef XFS_DIR_TRACE
6625 +static int     kdbm_xfs_xdirtrace(
6626         int     argc,
6627         const char **argv,
6628         const char **envp,
6629 @@ -505,16 +579,18 @@
6630  
6631         if (argc != 1)
6632                 return KDB_ARGCOUNT;
6633 +
6634         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6635         if (diag)
6636                 return diag;
6637  
6638 -       xfsidbg_xchashlist((xfs_chashlist_t *) addr);
6639 +       xfsidbg_xdirtrace((int) addr);
6640         return 0;
6641  }
6642 +#endif
6643  
6644 -
6645 -static int     kdbm_xfs_xdaargs(
6646 +#ifdef XFS_LOG_TRACE
6647 +static int     kdbm_xfs_xiclogtrace(
6648         int     argc,
6649         const char **argv,
6650         const char **envp,
6651 @@ -527,15 +603,18 @@
6652  
6653         if (argc != 1)
6654                 return KDB_ARGCOUNT;
6655 +
6656         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6657         if (diag)
6658                 return diag;
6659  
6660 -       xfsidbg_xdaargs((xfs_da_args_t *) addr);
6661 +       xfsidbg_xiclogtrace((xlog_in_core_t *) addr);
6662         return 0;
6663  }
6664 +#endif
6665  
6666 -static int     kdbm_xfs_xdabuf(
6667 +#ifdef XFS_ILOCK_TRACE
6668 +static int     kdbm_xfs_xilock_trace(
6669         int     argc,
6670         const char **argv,
6671         const char **envp,
6672 @@ -548,15 +627,16 @@
6673  
6674         if (argc != 1)
6675                 return KDB_ARGCOUNT;
6676 +
6677         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6678         if (diag)
6679                 return diag;
6680  
6681 -       xfsidbg_xdabuf((xfs_dabuf_t *) addr);
6682 +       xfsidbg_xilock_trace((xfs_inode_t *) addr);
6683         return 0;
6684  }
6685  
6686 -static int     kdbm_xfs_xdanode(
6687 +static int     kdbm_xfs_xailock_trace(
6688         int     argc,
6689         const char **argv,
6690         const char **envp,
6691 @@ -569,15 +649,18 @@
6692  
6693         if (argc != 1)
6694                 return KDB_ARGCOUNT;
6695 +
6696         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6697         if (diag)
6698                 return diag;
6699  
6700 -       xfsidbg_xdanode((xfs_da_intnode_t *) addr);
6701 +       xfsidbg_xailock_trace((int) addr);
6702         return 0;
6703  }
6704 +#endif
6705  
6706 -static int     kdbm_xfs_xdastate(
6707 +#ifdef XFS_LOG_TRACE
6708 +static int     kdbm_xfs_xlog_granttrace(
6709         int     argc,
6710         const char **argv,
6711         const char **envp,
6712 @@ -590,15 +673,18 @@
6713  
6714         if (argc != 1)
6715                 return KDB_ARGCOUNT;
6716 +
6717         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6718         if (diag)
6719                 return diag;
6720  
6721 -       xfsidbg_xdastate((xfs_da_state_t *) addr);
6722 +       xfsidbg_xlog_granttrace((xlog_t *) addr);
6723         return 0;
6724  }
6725 +#endif
6726  
6727 -static int     kdbm_xfs_xdirleaf(
6728 +#ifdef XFS_DQUOT_TRACE
6729 +static int     kdbm_xfs_xqm_dqtrace(
6730         int     argc,
6731         const char **argv,
6732         const char **envp,
6733 @@ -611,15 +697,18 @@
6734  
6735         if (argc != 1)
6736                 return KDB_ARGCOUNT;
6737 +
6738         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6739         if (diag)
6740                 return diag;
6741  
6742 -       xfsidbg_xdirleaf((xfs_dir_leafblock_t *) addr);
6743 +       xfsidbg_xqm_dqtrace((xfs_dquot_t *) addr);
6744         return 0;
6745  }
6746 +#endif
6747  
6748 -static int     kdbm_xfs_xdirsf(
6749 +#ifdef XFS_RW_TRACE
6750 +static int     kdbm_xfs_xrwtrace(
6751         int     argc,
6752         const char **argv,
6753         const char **envp,
6754 @@ -632,15 +721,17 @@
6755  
6756         if (argc != 1)
6757                 return KDB_ARGCOUNT;
6758 +
6759         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6760         if (diag)
6761                 return diag;
6762  
6763 -       xfsidbg_xdirsf((xfs_dir_shortform_t *) addr);
6764 +       xfsidbg_xrwtrace((xfs_inode_t *) addr);
6765         return 0;
6766  }
6767 +#endif
6768  
6769 -static int     kdbm_xfs_xdir2free(
6770 +static int     kdbm_xfs_xalloc(
6771         int     argc,
6772         const char **argv,
6773         const char **envp,
6774 @@ -657,11 +748,12 @@
6775         if (diag)
6776                 return diag;
6777  
6778 -       xfsidbg_xdir2free((xfs_dir2_free_t *) addr);
6779 +       xfsidbg_xalloc((xfs_alloc_arg_t *) addr);
6780         return 0;
6781  }
6782  
6783 -static int     kdbm_xfs_xdir2sf(
6784 +#ifdef XFS_ALLOC_TRACE
6785 +static int     kdbm_xfs_xalmtrace(
6786         int     argc,
6787         const char **argv,
6788         const char **envp,
6789 @@ -678,11 +770,11 @@
6790         if (diag)
6791                 return diag;
6792  
6793 -       xfsidbg_xdir2sf((xfs_dir2_sf_t *) addr);
6794 +       xfsidbg_xalmtrace((xfs_mount_t *) addr);
6795         return 0;
6796  }
6797  
6798 -static int     kdbm_xfs_xexlist(
6799 +static int     kdbm_xfs_xalttrace(
6800         int     argc,
6801         const char **argv,
6802         const char **envp,
6803 @@ -699,11 +791,12 @@
6804         if (diag)
6805                 return diag;
6806  
6807 -       xfsidbg_xexlist((xfs_inode_t *) addr);
6808 +       xfsidbg_xalttrace((int) addr);
6809         return 0;
6810  }
6811 +#endif /* XFS_ALLOC_TRACE */
6812  
6813 -static int     kdbm_xfs_xflist(
6814 +static int     kdbm_xfs_xattrcontext(
6815         int     argc,
6816         const char **argv,
6817         const char **envp,
6818 @@ -720,24 +813,32 @@
6819         if (diag)
6820                 return diag;
6821  
6822 -       xfsidbg_xflist((xfs_bmap_free_t *) addr);
6823 +       xfsidbg_xattrcontext((xfs_attr_list_context_t *) addr);
6824         return 0;
6825  }
6826  
6827 -static int     kdbm_xfs_xhelp(
6828 +static int     kdbm_xfs_xattrleaf(
6829         int     argc,
6830         const char **argv,
6831         const char **envp,
6832         struct pt_regs *regs)
6833  {
6834 -       if (argc != 0)
6835 +       unsigned long addr;
6836 +       int nextarg = 1;
6837 +       long offset = 0;
6838 +       int diag;
6839 +
6840 +       if (argc != 1)
6841                 return KDB_ARGCOUNT;
6842 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
6843 +       if (diag)
6844 +               return diag;
6845  
6846 -       xfsidbg_xhelp();
6847 +       xfsidbg_xattrleaf((xfs_attr_leafblock_t *) addr);
6848         return 0;
6849  }
6850  
6851 -static int     kdbm_xfs_xiclog(
6852 +static int     kdbm_xfs_xattrsf(
6853         int     argc,
6854         const char **argv,
6855         const char **envp,
6856 @@ -754,11 +855,11 @@
6857         if (diag)
6858                 return diag;
6859  
6860 -       xfsidbg_xiclog((xlog_in_core_t *) addr);
6861 +       xfsidbg_xattrsf((xfs_attr_shortform_t *) addr);
6862         return 0;
6863  }
6864  
6865 -static int     kdbm_xfs_xiclogall(
6866 +static int     kdbm_xfs_xbirec(
6867         int     argc,
6868         const char **argv,
6869         const char **envp,
6870 @@ -775,11 +876,11 @@
6871         if (diag)
6872                 return diag;
6873  
6874 -       xfsidbg_xiclogall((xlog_in_core_t *) addr);
6875 +       xfsidbg_xbirec((xfs_bmbt_irec_t *) addr);
6876         return 0;
6877  }
6878  
6879 -static int     kdbm_xfs_xiclogcb(
6880 +static int     kdbm_xfs_xbmalla(
6881         int     argc,
6882         const char **argv,
6883         const char **envp,
6884 @@ -796,11 +897,11 @@
6885         if (diag)
6886                 return diag;
6887  
6888 -       xfsidbg_xiclogcb((xlog_in_core_t *) addr);
6889 +       xfsidbg_xbmalla((xfs_bmalloca_t *)addr);
6890         return 0;
6891  }
6892  
6893 -static int     kdbm_xfs_xihash(
6894 +static int     kdbm_xfs_xbrec(
6895         int     argc,
6896         const char **argv,
6897         const char **envp,
6898 @@ -817,11 +918,11 @@
6899         if (diag)
6900                 return diag;
6901  
6902 -       xfsidbg_xihash((xfs_mount_t *) addr);
6903 +       xfsidbg_xbrec((xfs_bmbt_rec_64_t *) addr);
6904         return 0;
6905  }
6906  
6907 -static int     kdbm_xfs_xinodes(
6908 +static int     kdbm_xfs_xbroot(
6909         int     argc,
6910         const char **argv,
6911         const char **envp,
6912 @@ -838,11 +939,11 @@
6913         if (diag)
6914                 return diag;
6915  
6916 -       xfsidbg_xinodes((xfs_mount_t *) addr);
6917 +       xfsidbg_xbroot((xfs_inode_t *) addr);
6918         return 0;
6919  }
6920  
6921 -static int     kdbm_xfs_delayed_blocks(
6922 +static int     kdbm_xfs_xbroota(
6923         int     argc,
6924         const char **argv,
6925         const char **envp,
6926 @@ -859,12 +960,11 @@
6927         if (diag)
6928                 return diag;
6929  
6930 -       xfsidbg_delayed_blocks((xfs_mount_t *) addr);
6931 +       xfsidbg_xbroota((xfs_inode_t *) addr);
6932         return 0;
6933  }
6934  
6935 -
6936 -static int     kdbm_xfs_xinodes_quiesce(
6937 +static int     kdbm_xfs_xbtcur(
6938         int     argc,
6939         const char **argv,
6940         const char **envp,
6941 @@ -881,11 +981,11 @@
6942         if (diag)
6943                 return diag;
6944  
6945 -       xfsidbg_xinodes_quiesce((xfs_mount_t *) addr);
6946 +       xfsidbg_xbtcur((xfs_btree_cur_t *) addr);
6947         return 0;
6948  }
6949  
6950 -static int     kdbm_xfs_xlog(
6951 +static int     kdbm_xfs_xbuf(
6952         int     argc,
6953         const char **argv,
6954         const char **envp,
6955 @@ -902,11 +1002,12 @@
6956         if (diag)
6957                 return diag;
6958  
6959 -       xfsidbg_xlog((xlog_t *) addr);
6960 +       xfsidbg_xbuf((xfs_buf_t *) addr);
6961         return 0;
6962  }
6963  
6964 -static int     kdbm_xfs_xlog_ritem(
6965 +
6966 +static int     kdbm_xfs_xarg(
6967         int     argc,
6968         const char **argv,
6969         const char **envp,
6970 @@ -923,11 +1024,11 @@
6971         if (diag)
6972                 return diag;
6973  
6974 -       xfsidbg_xlog_ritem((xlog_recover_item_t *) addr);
6975 +       xfsidbg_xarg((int) addr);
6976         return 0;
6977  }
6978  
6979 -static int     kdbm_xfs_xlog_rtrans(
6980 +static int     kdbm_xfs_xchksum(
6981         int     argc,
6982         const char **argv,
6983         const char **envp,
6984 @@ -944,11 +1045,12 @@
6985         if (diag)
6986                 return diag;
6987  
6988 -       xfsidbg_xlog_rtrans((xlog_recover_t *) addr);
6989 +       xfsidbg_xchksum((uint *) addr);
6990         return 0;
6991  }
6992  
6993 -static int     kdbm_xfs_xlog_rtrans_entire(
6994 +
6995 +static int     kdbm_xfs_xchash(
6996         int     argc,
6997         const char **argv,
6998         const char **envp,
6999 @@ -965,11 +1067,11 @@
7000         if (diag)
7001                 return diag;
7002  
7003 -       xfsidbg_xlog_rtrans_entire((xlog_recover_t *) addr);
7004 +       xfsidbg_xchash((xfs_mount_t *) addr);
7005         return 0;
7006  }
7007  
7008 -static int     kdbm_xfs_xlog_tic(
7009 +static int     kdbm_xfs_xchashlist(
7010         int     argc,
7011         const char **argv,
7012         const char **envp,
7013 @@ -986,11 +1088,12 @@
7014         if (diag)
7015                 return diag;
7016  
7017 -       xfsidbg_xlog_tic((xlog_ticket_t *) addr);
7018 +       xfsidbg_xchashlist((xfs_chashlist_t *) addr);
7019         return 0;
7020  }
7021  
7022 -static int     kdbm_xfs_xlogitem(
7023 +
7024 +static int     kdbm_xfs_xdaargs(
7025         int     argc,
7026         const char **argv,
7027         const char **envp,
7028 @@ -1007,11 +1110,11 @@
7029         if (diag)
7030                 return diag;
7031  
7032 -       xfsidbg_xlogitem((xfs_log_item_t *) addr);
7033 +       xfsidbg_xdaargs((xfs_da_args_t *) addr);
7034         return 0;
7035  }
7036  
7037 -static int     kdbm_xfs_xmount(
7038 +static int     kdbm_xfs_xdabuf(
7039         int     argc,
7040         const char **argv,
7041         const char **envp,
7042 @@ -1028,11 +1131,11 @@
7043         if (diag)
7044                 return diag;
7045  
7046 -       xfsidbg_xmount((xfs_mount_t *) addr);
7047 +       xfsidbg_xdabuf((xfs_dabuf_t *) addr);
7048         return 0;
7049  }
7050  
7051 -static int     kdbm_xfs_xnode(
7052 +static int     kdbm_xfs_xdanode(
7053         int     argc,
7054         const char **argv,
7055         const char **envp,
7056 @@ -1049,11 +1152,11 @@
7057         if (diag)
7058                 return diag;
7059  
7060 -       xfsidbg_xnode((xfs_inode_t *) addr);
7061 +       xfsidbg_xdanode((xfs_da_intnode_t *) addr);
7062         return 0;
7063  }
7064  
7065 -static int     kdbm_xfs_xcore(
7066 +static int     kdbm_xfs_xdastate(
7067         int     argc,
7068         const char **argv,
7069         const char **envp,
7070 @@ -1070,11 +1173,11 @@
7071         if (diag)
7072                 return diag;
7073  
7074 -       xfsidbg_xcore((xfs_iocore_t *) addr);
7075 +       xfsidbg_xdastate((xfs_da_state_t *) addr);
7076         return 0;
7077  }
7078  
7079 -static int     kdbm_xfs_xperag(
7080 +static int     kdbm_xfs_xdirleaf(
7081         int     argc,
7082         const char **argv,
7083         const char **envp,
7084 @@ -1091,11 +1194,11 @@
7085         if (diag)
7086                 return diag;
7087  
7088 -       xfsidbg_xperag((xfs_mount_t *) addr);
7089 +       xfsidbg_xdirleaf((xfs_dir_leafblock_t *) addr);
7090         return 0;
7091  }
7092  
7093 -static int     kdbm_xfs_xqm_diskdq(
7094 +static int     kdbm_xfs_xdirsf(
7095         int     argc,
7096         const char **argv,
7097         const char **envp,
7098 @@ -1112,11 +1215,11 @@
7099         if (diag)
7100                 return diag;
7101  
7102 -       xfsidbg_xqm_diskdq((xfs_disk_dquot_t *) addr);
7103 +       xfsidbg_xdirsf((xfs_dir_shortform_t *) addr);
7104         return 0;
7105  }
7106  
7107 -static int     kdbm_xfs_xqm_dqattached_inos(
7108 +static int     kdbm_xfs_xdir2free(
7109         int     argc,
7110         const char **argv,
7111         const char **envp,
7112 @@ -1133,11 +1236,11 @@
7113         if (diag)
7114                 return diag;
7115  
7116 -       xfsidbg_xqm_dqattached_inos((xfs_mount_t *) addr);
7117 +       xfsidbg_xdir2free((xfs_dir2_free_t *) addr);
7118         return 0;
7119  }
7120  
7121 -static int     kdbm_xfs_xqm_dquot(
7122 +static int     kdbm_xfs_xdir2sf(
7123         int     argc,
7124         const char **argv,
7125         const char **envp,
7126 @@ -1154,38 +1257,53 @@
7127         if (diag)
7128                 return diag;
7129  
7130 -       xfsidbg_xqm_dquot((xfs_dquot_t *) addr);
7131 +       xfsidbg_xdir2sf((xfs_dir2_sf_t *) addr);
7132         return 0;
7133  }
7134  
7135 -#ifdef CONFIG_XFS_QUOTA
7136 -static int     kdbm_xfs_xqm(
7137 +static int     kdbm_xfs_xexlist(
7138         int     argc,
7139         const char **argv,
7140         const char **envp,
7141         struct pt_regs *regs)
7142  {
7143 -       if (argc != 0)
7144 +       unsigned long addr;
7145 +       int nextarg = 1;
7146 +       long offset = 0;
7147 +       int diag;
7148 +
7149 +       if (argc != 1)
7150                 return KDB_ARGCOUNT;
7151 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7152 +       if (diag)
7153 +               return diag;
7154  
7155 -       xfsidbg_xqm();
7156 +       xfsidbg_xexlist((xfs_inode_t *) addr);
7157         return 0;
7158  }
7159  
7160 -static int     kdbm_xfs_xqm_freelist(
7161 +static int     kdbm_xfs_xflist(
7162         int     argc,
7163         const char **argv,
7164         const char **envp,
7165         struct pt_regs *regs)
7166  {
7167 -       if (argc != 0)
7168 +       unsigned long addr;
7169 +       int nextarg = 1;
7170 +       long offset = 0;
7171 +       int diag;
7172 +
7173 +       if (argc != 1)
7174                 return KDB_ARGCOUNT;
7175 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7176 +       if (diag)
7177 +               return diag;
7178  
7179 -       xfsidbg_xqm_freelist();
7180 +       xfsidbg_xflist((xfs_bmap_free_t *) addr);
7181         return 0;
7182  }
7183  
7184 -static int     kdbm_xfs_xqm_htab(
7185 +static int     kdbm_xfs_xhelp(
7186         int     argc,
7187         const char **argv,
7188         const char **envp,
7189 @@ -1194,12 +1312,11 @@
7190         if (argc != 0)
7191                 return KDB_ARGCOUNT;
7192  
7193 -       xfsidbg_xqm_htab();
7194 +       xfsidbg_xhelp();
7195         return 0;
7196  }
7197 -#endif
7198  
7199 -static int     kdbm_xfs_xqm_mplist(
7200 +static int     kdbm_xfs_xiclog(
7201         int     argc,
7202         const char **argv,
7203         const char **envp,
7204 @@ -1216,11 +1333,11 @@
7205         if (diag)
7206                 return diag;
7207  
7208 -       xfsidbg_xqm_mplist((xfs_mount_t *) addr);
7209 +       xfsidbg_xiclog((xlog_in_core_t *) addr);
7210         return 0;
7211  }
7212  
7213 -static int     kdbm_xfs_xqm_qinfo(
7214 +static int     kdbm_xfs_xiclogall(
7215         int     argc,
7216         const char **argv,
7217         const char **envp,
7218 @@ -1237,11 +1354,473 @@
7219         if (diag)
7220                 return diag;
7221  
7222 -       xfsidbg_xqm_qinfo((xfs_mount_t *) addr);
7223 +       xfsidbg_xiclogall((xlog_in_core_t *) addr);
7224         return 0;
7225  }
7226  
7227 -static int     kdbm_xfs_xqm_tpdqinfo(
7228 +static int     kdbm_xfs_xiclogcb(
7229 +       int     argc,
7230 +       const char **argv,
7231 +       const char **envp,
7232 +       struct pt_regs *regs)
7233 +{
7234 +       unsigned long addr;
7235 +       int nextarg = 1;
7236 +       long offset = 0;
7237 +       int diag;
7238 +
7239 +       if (argc != 1)
7240 +               return KDB_ARGCOUNT;
7241 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7242 +       if (diag)
7243 +               return diag;
7244 +
7245 +       xfsidbg_xiclogcb((xlog_in_core_t *) addr);
7246 +       return 0;
7247 +}
7248 +
7249 +static int     kdbm_xfs_xihash(
7250 +       int     argc,
7251 +       const char **argv,
7252 +       const char **envp,
7253 +       struct pt_regs *regs)
7254 +{
7255 +       unsigned long addr;
7256 +       int nextarg = 1;
7257 +       long offset = 0;
7258 +       int diag;
7259 +
7260 +       if (argc != 1)
7261 +               return KDB_ARGCOUNT;
7262 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7263 +       if (diag)
7264 +               return diag;
7265 +
7266 +       xfsidbg_xihash((xfs_mount_t *) addr);
7267 +       return 0;
7268 +}
7269 +
7270 +static int     kdbm_xfs_xinodes(
7271 +       int     argc,
7272 +       const char **argv,
7273 +       const char **envp,
7274 +       struct pt_regs *regs)
7275 +{
7276 +       unsigned long addr;
7277 +       int nextarg = 1;
7278 +       long offset = 0;
7279 +       int diag;
7280 +
7281 +       if (argc != 1)
7282 +               return KDB_ARGCOUNT;
7283 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7284 +       if (diag)
7285 +               return diag;
7286 +
7287 +       xfsidbg_xinodes((xfs_mount_t *) addr);
7288 +       return 0;
7289 +}
7290 +
7291 +static int     kdbm_xfs_delayed_blocks(
7292 +       int     argc,
7293 +       const char **argv,
7294 +       const char **envp,
7295 +       struct pt_regs *regs)
7296 +{
7297 +       unsigned long addr;
7298 +       int nextarg = 1;
7299 +       long offset = 0;
7300 +       int diag;
7301 +
7302 +       if (argc != 1)
7303 +               return KDB_ARGCOUNT;
7304 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7305 +       if (diag)
7306 +               return diag;
7307 +
7308 +       xfsidbg_delayed_blocks((xfs_mount_t *) addr);
7309 +       return 0;
7310 +}
7311 +
7312 +
7313 +static int     kdbm_xfs_xinodes_quiesce(
7314 +       int     argc,
7315 +       const char **argv,
7316 +       const char **envp,
7317 +       struct pt_regs *regs)
7318 +{
7319 +       unsigned long addr;
7320 +       int nextarg = 1;
7321 +       long offset = 0;
7322 +       int diag;
7323 +
7324 +       if (argc != 1)
7325 +               return KDB_ARGCOUNT;
7326 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7327 +       if (diag)
7328 +               return diag;
7329 +
7330 +       xfsidbg_xinodes_quiesce((xfs_mount_t *) addr);
7331 +       return 0;
7332 +}
7333 +
7334 +static int     kdbm_xfs_xlog(
7335 +       int     argc,
7336 +       const char **argv,
7337 +       const char **envp,
7338 +       struct pt_regs *regs)
7339 +{
7340 +       unsigned long addr;
7341 +       int nextarg = 1;
7342 +       long offset = 0;
7343 +       int diag;
7344 +
7345 +       if (argc != 1)
7346 +               return KDB_ARGCOUNT;
7347 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7348 +       if (diag)
7349 +               return diag;
7350 +
7351 +       xfsidbg_xlog((xlog_t *) addr);
7352 +       return 0;
7353 +}
7354 +
7355 +static int     kdbm_xfs_xlog_ritem(
7356 +       int     argc,
7357 +       const char **argv,
7358 +       const char **envp,
7359 +       struct pt_regs *regs)
7360 +{
7361 +       unsigned long addr;
7362 +       int nextarg = 1;
7363 +       long offset = 0;
7364 +       int diag;
7365 +
7366 +       if (argc != 1)
7367 +               return KDB_ARGCOUNT;
7368 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7369 +       if (diag)
7370 +               return diag;
7371 +
7372 +       xfsidbg_xlog_ritem((xlog_recover_item_t *) addr);
7373 +       return 0;
7374 +}
7375 +
7376 +static int     kdbm_xfs_xlog_rtrans(
7377 +       int     argc,
7378 +       const char **argv,
7379 +       const char **envp,
7380 +       struct pt_regs *regs)
7381 +{
7382 +       unsigned long addr;
7383 +       int nextarg = 1;
7384 +       long offset = 0;
7385 +       int diag;
7386 +
7387 +       if (argc != 1)
7388 +               return KDB_ARGCOUNT;
7389 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7390 +       if (diag)
7391 +               return diag;
7392 +
7393 +       xfsidbg_xlog_rtrans((xlog_recover_t *) addr);
7394 +       return 0;
7395 +}
7396 +
7397 +static int     kdbm_xfs_xlog_rtrans_entire(
7398 +       int     argc,
7399 +       const char **argv,
7400 +       const char **envp,
7401 +       struct pt_regs *regs)
7402 +{
7403 +       unsigned long addr;
7404 +       int nextarg = 1;
7405 +       long offset = 0;
7406 +       int diag;
7407 +
7408 +       if (argc != 1)
7409 +               return KDB_ARGCOUNT;
7410 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7411 +       if (diag)
7412 +               return diag;
7413 +
7414 +       xfsidbg_xlog_rtrans_entire((xlog_recover_t *) addr);
7415 +       return 0;
7416 +}
7417 +
7418 +static int     kdbm_xfs_xlog_tic(
7419 +       int     argc,
7420 +       const char **argv,
7421 +       const char **envp,
7422 +       struct pt_regs *regs)
7423 +{
7424 +       unsigned long addr;
7425 +       int nextarg = 1;
7426 +       long offset = 0;
7427 +       int diag;
7428 +
7429 +       if (argc != 1)
7430 +               return KDB_ARGCOUNT;
7431 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7432 +       if (diag)
7433 +               return diag;
7434 +
7435 +       xfsidbg_xlog_tic((xlog_ticket_t *) addr);
7436 +       return 0;
7437 +}
7438 +
7439 +static int     kdbm_xfs_xlogitem(
7440 +       int     argc,
7441 +       const char **argv,
7442 +       const char **envp,
7443 +       struct pt_regs *regs)
7444 +{
7445 +       unsigned long addr;
7446 +       int nextarg = 1;
7447 +       long offset = 0;
7448 +       int diag;
7449 +
7450 +       if (argc != 1)
7451 +               return KDB_ARGCOUNT;
7452 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7453 +       if (diag)
7454 +               return diag;
7455 +
7456 +       xfsidbg_xlogitem((xfs_log_item_t *) addr);
7457 +       return 0;
7458 +}
7459 +
7460 +static int     kdbm_xfs_xmount(
7461 +       int     argc,
7462 +       const char **argv,
7463 +       const char **envp,
7464 +       struct pt_regs *regs)
7465 +{
7466 +       unsigned long addr;
7467 +       int nextarg = 1;
7468 +       long offset = 0;
7469 +       int diag;
7470 +
7471 +       if (argc != 1)
7472 +               return KDB_ARGCOUNT;
7473 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7474 +       if (diag)
7475 +               return diag;
7476 +
7477 +       xfsidbg_xmount((xfs_mount_t *) addr);
7478 +       return 0;
7479 +}
7480 +
7481 +static int     kdbm_xfs_xnode(
7482 +       int     argc,
7483 +       const char **argv,
7484 +       const char **envp,
7485 +       struct pt_regs *regs)
7486 +{
7487 +       unsigned long addr;
7488 +       int nextarg = 1;
7489 +       long offset = 0;
7490 +       int diag;
7491 +
7492 +       if (argc != 1)
7493 +               return KDB_ARGCOUNT;
7494 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7495 +       if (diag)
7496 +               return diag;
7497 +
7498 +       xfsidbg_xnode((xfs_inode_t *) addr);
7499 +       return 0;
7500 +}
7501 +
7502 +static int     kdbm_xfs_xcore(
7503 +       int     argc,
7504 +       const char **argv,
7505 +       const char **envp,
7506 +       struct pt_regs *regs)
7507 +{
7508 +       unsigned long addr;
7509 +       int nextarg = 1;
7510 +       long offset = 0;
7511 +       int diag;
7512 +
7513 +       if (argc != 1)
7514 +               return KDB_ARGCOUNT;
7515 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7516 +       if (diag)
7517 +               return diag;
7518 +
7519 +       xfsidbg_xcore((xfs_iocore_t *) addr);
7520 +       return 0;
7521 +}
7522 +
7523 +static int     kdbm_xfs_xperag(
7524 +       int     argc,
7525 +       const char **argv,
7526 +       const char **envp,
7527 +       struct pt_regs *regs)
7528 +{
7529 +       unsigned long addr;
7530 +       int nextarg = 1;
7531 +       long offset = 0;
7532 +       int diag;
7533 +
7534 +       if (argc != 1)
7535 +               return KDB_ARGCOUNT;
7536 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7537 +       if (diag)
7538 +               return diag;
7539 +
7540 +       xfsidbg_xperag((xfs_mount_t *) addr);
7541 +       return 0;
7542 +}
7543 +
7544 +static int     kdbm_xfs_xqm_diskdq(
7545 +       int     argc,
7546 +       const char **argv,
7547 +       const char **envp,
7548 +       struct pt_regs *regs)
7549 +{
7550 +       unsigned long addr;
7551 +       int nextarg = 1;
7552 +       long offset = 0;
7553 +       int diag;
7554 +
7555 +       if (argc != 1)
7556 +               return KDB_ARGCOUNT;
7557 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7558 +       if (diag)
7559 +               return diag;
7560 +
7561 +       xfsidbg_xqm_diskdq((xfs_disk_dquot_t *) addr);
7562 +       return 0;
7563 +}
7564 +
7565 +static int     kdbm_xfs_xqm_dqattached_inos(
7566 +       int     argc,
7567 +       const char **argv,
7568 +       const char **envp,
7569 +       struct pt_regs *regs)
7570 +{
7571 +       unsigned long addr;
7572 +       int nextarg = 1;
7573 +       long offset = 0;
7574 +       int diag;
7575 +
7576 +       if (argc != 1)
7577 +               return KDB_ARGCOUNT;
7578 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7579 +       if (diag)
7580 +               return diag;
7581 +
7582 +       xfsidbg_xqm_dqattached_inos((xfs_mount_t *) addr);
7583 +       return 0;
7584 +}
7585 +
7586 +static int     kdbm_xfs_xqm_dquot(
7587 +       int     argc,
7588 +       const char **argv,
7589 +       const char **envp,
7590 +       struct pt_regs *regs)
7591 +{
7592 +       unsigned long addr;
7593 +       int nextarg = 1;
7594 +       long offset = 0;
7595 +       int diag;
7596 +
7597 +       if (argc != 1)
7598 +               return KDB_ARGCOUNT;
7599 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7600 +       if (diag)
7601 +               return diag;
7602 +
7603 +       xfsidbg_xqm_dquot((xfs_dquot_t *) addr);
7604 +       return 0;
7605 +}
7606 +
7607 +#ifdef CONFIG_XFS_QUOTA
7608 +static int     kdbm_xfs_xqm(
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();
7618 +       return 0;
7619 +}
7620 +
7621 +static int     kdbm_xfs_xqm_freelist(
7622 +       int     argc,
7623 +       const char **argv,
7624 +       const char **envp,
7625 +       struct pt_regs *regs)
7626 +{
7627 +       if (argc != 0)
7628 +               return KDB_ARGCOUNT;
7629 +
7630 +       xfsidbg_xqm_freelist();
7631 +       return 0;
7632 +}
7633 +
7634 +static int     kdbm_xfs_xqm_htab(
7635 +       int     argc,
7636 +       const char **argv,
7637 +       const char **envp,
7638 +       struct pt_regs *regs)
7639 +{
7640 +       if (argc != 0)
7641 +               return KDB_ARGCOUNT;
7642 +
7643 +       xfsidbg_xqm_htab();
7644 +       return 0;
7645 +}
7646 +#endif
7647 +
7648 +static int     kdbm_xfs_xqm_mplist(
7649 +       int     argc,
7650 +       const char **argv,
7651 +       const char **envp,
7652 +       struct pt_regs *regs)
7653 +{
7654 +       unsigned long addr;
7655 +       int nextarg = 1;
7656 +       long offset = 0;
7657 +       int diag;
7658 +
7659 +       if (argc != 1)
7660 +               return KDB_ARGCOUNT;
7661 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7662 +       if (diag)
7663 +               return diag;
7664 +
7665 +       xfsidbg_xqm_mplist((xfs_mount_t *) addr);
7666 +       return 0;
7667 +}
7668 +
7669 +static int     kdbm_xfs_xqm_qinfo(
7670 +       int     argc,
7671 +       const char **argv,
7672 +       const char **envp,
7673 +       struct pt_regs *regs)
7674 +{
7675 +       unsigned long addr;
7676 +       int nextarg = 1;
7677 +       long offset = 0;
7678 +       int diag;
7679 +
7680 +       if (argc != 1)
7681 +               return KDB_ARGCOUNT;
7682 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7683 +       if (diag)
7684 +               return diag;
7685 +
7686 +       xfsidbg_xqm_qinfo((xfs_mount_t *) addr);
7687 +       return 0;
7688 +}
7689 +
7690 +static int     kdbm_xfs_xqm_tpdqinfo(
7691         int     argc,
7692         const char **argv,
7693         const char **envp,
7694 @@ -1404,45 +1983,52 @@
7695  }
7696  
7697  
7698 -static void    printvnode(vnode_t *vp)
7699 +static void printbhv(bhv_desc_t *bdp)
7700  {
7701 -       bhv_desc_t      *bh;
7702         kdb_symtab_t     symtab;
7703  
7704 +       if (bdp == NULL) {
7705 +               kdb_printf("NULL bhv\n");
7706 +               return;
7707 +       }
7708 +
7709 +       kdb_printf("bhv at 0x%p\n", bdp);
7710 +       while (bdp) {
7711 +               if (kdbnearsym((unsigned long)bdp->bd_ops, &symtab))
7712 +                       kdb_printf("  ops %s", symtab.sym_name);
7713 +               else
7714 +                       kdb_printf("  ops %s/0x%p", "???", (void *)bdp->bd_ops);
7715 +
7716 +               kdb_printf(" vobj 0x%p pdata 0x%p next 0x%p\n",
7717 +                          bdp->bd_vobj, bdp->bd_pdata, bdp->bd_next);
7718 +
7719 +               bdp = bdp->bd_next;
7720 +       }
7721 +}
7722  
7723 -       kdb_printf("vnode: 0x%p type ", vp);
7724 +
7725 +static void    printvnode(vnode_t *vp, unsigned long addr)
7726 +{
7727 +       kdb_printf("vnode: 0x%lx type ", addr);
7728         if ((size_t)vp->v_type >= sizeof(vnode_type)/sizeof(vnode_type[0]))
7729                 kdb_printf("out of range 0x%x", vp->v_type);
7730         else
7731                 kdb_printf("%s", vnode_type[vp->v_type]);
7732 -       kdb_printf(" v_bh %p\n", &vp->v_bh);
7733 +       kdb_printf(" v_bh 0x%p\n", &vp->v_bh);
7734  
7735 -       if ((bh = vp->v_bh.bh_first)) {
7736 -               kdb_printf("   v_inode 0x%p v_bh->bh_first 0x%p pobj 0x%p\n",
7737 -                                       LINVFS_GET_IP(vp), bh, bh->bd_pdata);
7738 -
7739 -               if (kdbnearsym((unsigned long)bh->bd_ops, &symtab))
7740 -                       kdb_printf("   ops %s ", symtab.sym_name);
7741 -               else
7742 -                       kdb_printf("   ops %s/0x%p ",
7743 -                                               "???", (void *)bh->bd_ops);
7744 -       } else {
7745 -               kdb_printf("   v_inode 0x%p v_bh->bh_first = NULLBHV ",
7746 -                                       LINVFS_GET_IP(vp));
7747 -       }
7748 +       printbhv(vp->v_fbhv);
7749  
7750         printflags((__psunsigned_t)vp->v_flag, tab_vflags, "flag =");
7751         kdb_printf("\n");
7752  
7753 -#ifdef CONFIG_XFS_VNODE_TRACING
7754 +#ifdef XFS_VNODE_TRACE
7755         kdb_printf("   v_trace 0x%p\n", vp->v_trace);
7756 -#endif /* CONFIG_XFS_VNODE_TRACING */
7757 +#endif /* XFS_VNODE_TRACE */
7758  
7759 -       kdb_printf("   v_vfsp 0x%p v_number %Lx\n",
7760 -               vp->v_vfsp, vp->v_number);
7761 +       kdb_printf("   v_vfsp 0x%p v_number 0x%llx\n",
7762 +               vp->v_vfsp, (unsigned long long)vp->v_number);
7763  }
7764  
7765 -
7766  static int     kdbm_vnode(
7767         int     argc,
7768         const char **argv,
7769 @@ -1453,9 +2039,7 @@
7770         int nextarg = 1;
7771         long offset = 0;
7772         int diag;
7773 -       vnode_t         *vp;
7774 -/*     bhv_desc_t      *bh; */
7775 -/*     kdb_symtab_t     symtab;*/
7776 +       vnode_t         vp;
7777  
7778         if (argc != 1)
7779                 return KDB_ARGCOUNT;
7780 @@ -1465,14 +2049,82 @@
7781         if (diag)
7782                 return diag;
7783  
7784 -       vp = (vnode_t *)addr;
7785 +       if ((diag = kdb_getarea(vp, addr)))
7786 +               return diag;
7787 +
7788 +       printvnode(&vp, addr);
7789 +
7790 +       return 0;
7791 +}
7792 +
7793 +static void
7794 +print_vfs(vfs_t        *vfs, unsigned long addr)
7795 +{
7796 +       kdb_printf("vfsp at 0x%lx", addr);
7797 +       kdb_printf(" vfs_flag 0x%x\n", vfs->vfs_flag);
7798 +       kdb_printf(" vfs_super 0x%p", vfs->vfs_super);
7799 +       kdb_printf(" vfs_bh 0x%p\n", &vfs->vfs_bh);
7800 +
7801 +       printbhv(vfs->vfs_fbhv);
7802 +}
7803 +
7804 +static int     kdbm_bhv(
7805 +       int     argc,
7806 +       const char **argv,
7807 +       const char **envp,
7808 +       struct pt_regs *regs)
7809 +{
7810 +       unsigned long addr;
7811 +       int nextarg = 1;
7812 +       long offset = 0;
7813 +       int diag;
7814 +       bhv_desc_t      *bh;
7815 +
7816 +       if (argc != 1)
7817 +               return KDB_ARGCOUNT;
7818 +
7819 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7820 +
7821 +       if (diag)
7822 +               return diag;
7823 +
7824 +       bh = (bhv_desc_t *)addr;
7825 +
7826 +       printbhv(bh);
7827 +
7828 +       return 0;
7829 +}
7830 +
7831 +static int     kdbm_vfs(
7832 +       int     argc,
7833 +       const char **argv,
7834 +       const char **envp,
7835 +       struct pt_regs *regs)
7836 +{
7837 +       unsigned long addr;
7838 +       int nextarg = 1;
7839 +       long offset = 0;
7840 +       int diag;
7841 +       vfs_t           vfs;
7842 +
7843 +       if (argc != 1)
7844 +               return KDB_ARGCOUNT;
7845 +
7846 +       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7847 +
7848 +       if (diag)
7849 +               return diag;
7850 +
7851 +       if ((diag = kdb_getarea(vfs, addr)))
7852 +               return diag;
7853  
7854 -       printvnode(vp);
7855 +       print_vfs(&vfs, addr);
7856  
7857         return 0;
7858  }
7859  
7860 -#ifdef CONFIG_XFS_VNODE_TRACING
7861 +
7862 +#ifdef XFS_VNODE_TRACE
7863  /*
7864   * Print a vnode trace entry.
7865   */
7866 @@ -1668,7 +2320,7 @@
7867  
7868         return 0;
7869  }
7870 -#endif /* CONFIG_XFS_VNODE_TRACING */
7871 +#endif /* XFS_VNODE_TRACE */
7872  
7873  
7874  static void    printinode(struct inode *ip)
7875 @@ -1682,16 +2334,21 @@
7876         kdb_printf(" i_ino = %lu i_count = %u i_size %Ld\n",
7877                                         ip->i_ino, atomic_read(&ip->i_count),
7878                                         ip->i_size);
7879 -
7880 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
7881         kdb_printf(
7882 -               " i_mode = 0x%x  i_nlink = %d  i_rdev = %u:%u i_state = 0x%lx\n",
7883 +               " i_mode = 0x%x  i_nlink = %d  i_rdev = 0x%x i_state = 0x%lx\n",
7884                                         ip->i_mode, ip->i_nlink,
7885 -                                       MAJOR(ip->i_rdev),
7886 -                                       MINOR(ip->i_rdev),
7887 -                                       ip->i_state);
7888 -
7889 -       kdb_printf(" i_hash.nxt = 0x%p i_hash.prv = 0x%p\n",
7890 -                                       ip->i_hash.next, ip->i_hash.prev);
7891 +                                       kdev_t_to_nr(ip->i_rdev), ip->i_state);
7892 +       kdb_printf(" i_hash.nxt = 0x%p i_hash.pprv = 0x%p\n",
7893 +                                        ip->i_hash.next, ip->i_hash.prev);
7894 +#else
7895 +       kdb_printf(
7896 +               " i_mode = 0x%x  i_nlink = %d  i_rdev = 0x%x i_state = 0x%lx\n",
7897 +                                       ip->i_mode, ip->i_nlink,
7898 +                                       ip->i_rdev, ip->i_state);
7899 +       kdb_printf(" i_hash.nxt = 0x%p i_hash.pprv = 0x%p\n",
7900 +                                        ip->i_hash.next, ip->i_hash.pprev);
7901 +#endif
7902         kdb_printf(" i_list.nxt = 0x%p i_list.prv = 0x%p\n",
7903                                         ip->i_list.next, ip->i_list.prev);
7904         kdb_printf(" i_dentry.nxt = 0x%p i_dentry.prv = 0x%p\n",
7905 @@ -1717,52 +2374,44 @@
7906  {
7907         int             diag;
7908         int             nextarg = 1;
7909 -/*     char            *symname; */
7910         long            offset = 0;
7911         unsigned long   addr;
7912         struct inode    *ip;
7913 -/*     bhv_desc_t      *bh; */
7914 -#ifdef CONFIG_XFS_VNODE_TRACING
7915 +       vnode_t         vp;
7916 +#ifdef XFS_VNODE_TRACE
7917         ktrace_entry_t  *ktep;
7918         ktrace_snap_t   kts;
7919  #endif
7920 -       vnode_t         *vp;
7921  
7922         if (argc != 1)
7923                 return KDB_ARGCOUNT;
7924  
7925         diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
7926 -
7927         if (diag)
7928                 return diag;
7929  
7930 -       vp = (vnode_t *)addr;
7931 -
7932 -       ip = LINVFS_GET_IP(vp);
7933 +       if ((diag = kdb_getarea(vp, addr)))
7934 +               return diag;
7935  
7936 +       ip = LINVFS_GET_IP((vnode_t *)addr);
7937         kdb_printf("--> Inode @ 0x%p\n", ip);
7938         printinode(ip);
7939  
7940 -       kdb_printf("--> Vnode @ 0x%p\n", vp);
7941 -       printvnode(vp);
7942 -
7943 -#ifdef CONFIG_XFS_VNODE_TRACING
7944 +       kdb_printf("--> Vnode @ 0x%lx\n", addr);
7945 +       printvnode(&vp, addr);
7946  
7947 -       kdb_printf("--> Vntrace @ 0x%p/0x%p\n", vp, vp->v_trace);
7948 -
7949 -       if (vp->v_trace == NULL)
7950 +#ifdef XFS_VNODE_TRACE
7951 +       kdb_printf("--> Vntrace @ 0x%lx/0x%p\n", addr, vp.v_trace);
7952 +       if (vp.v_trace == NULL)
7953                 return 0;
7954 -
7955 -       ktep = ktrace_first(vp->v_trace, &kts);
7956 -
7957 +       ktep = ktrace_first(vp.v_trace, &kts);
7958         while (ktep != NULL) {
7959                 if (vn_trace_pr_entry(ktep))
7960                         kdb_printf("\n");
7961  
7962 -               ktep = ktrace_next(vp->v_trace, &kts);
7963 +               ktep = ktrace_next(vp.v_trace, &kts);
7964         }
7965 -#endif /* CONFIG_XFS_VNODE_TRACING */
7966 -
7967 +#endif /* XFS_VNODE_TRACE */
7968         return 0;
7969  }
7970  
7971 @@ -1772,15 +2421,15 @@
7972  static char    *pb_flag_vals[] = {
7973  /*  0 */ "READ", "WRITE", "MAPPED", "PARTIAL", "ASYNC",
7974  /*  5 */ "NONE", "DELWRI", "FREED", "SYNC", "MAPPABLE",
7975 -/* 10 */ "STALE", "FS_MANAGED", "INVALID12", "LOCK", "TRYLOCK",
7976 +/* 10 */ "STALE", "FS_MANAGED", "FS_DATAIOD", "LOCK", "TRYLOCK",
7977  /* 15 */ "DONT_BLOCK", "LOCKABLE", "PRIVATE_BH", "ALL_PAGES_MAPPED", 
7978          "ADDR_ALLOCATED",
7979  /* 20 */ "MEM_ALLOCATED", "FORCEIO", "FLUSH", "READ_AHEAD",
7980          NULL };
7981  
7982 -static char    *pbm_flag_vals[] = {
7983 +static char    *iomap_flag_vals[] = {
7984         "EOF", "HOLE", "DELAY", "INVALID0x08",
7985 -       "INVALID0x10", "UNWRITTEN", "INVALID0x40", "INVALID0x80",
7986 +       "INVALID0x10", "UNWRITTEN", "NEW", "INVALID0x80",
7987         NULL };
7988  
7989  
7990 @@ -1795,7 +2444,7 @@
7991         for (index = 0; flags && mapping[index]; flags >>= 1, index++) {
7992                 if (flags & 1) {
7993                         if ((offset + strlen(mapping[index]) + 1) >= 80) {
7994 -                               strcat(buffer, "\n            ");
7995 +                               strcat(buffer, "\n          ");
7996                                 offset = 12;
7997                         } else if (offset > 12) {
7998                                 strcat(buffer, " ");
7999 @@ -1832,6 +2481,48 @@
8000         return 0;
8001  }
8002  
8003 +static void
8004 +print_pagebuf(
8005 +       page_buf_t      *pb,
8006 +       unsigned long addr)
8007 +{
8008 +       kdb_printf("page_buf_t at 0x%lx\n", addr);
8009 +       kdb_printf("  pb_flags %s\n", pb_flags(pb->pb_flags));
8010 +       kdb_printf("  pb_target 0x%p pb_hold %d pb_next 0x%p pb_prev 0x%p\n",
8011 +                  pb->pb_target, pb->pb_hold.counter,
8012 +                  list_entry(pb->pb_list.next, page_buf_t, pb_list),
8013 +                  list_entry(pb->pb_list.prev, page_buf_t, pb_list));
8014 +       kdb_printf("  pb_hash_index %d pb_hash_next 0x%p pb_hash_prev 0x%p\n",
8015 +                  pb->pb_hash_index,
8016 +                  list_entry(pb->pb_hash_list.next, page_buf_t, pb_hash_list),
8017 +                  list_entry(pb->pb_hash_list.prev, page_buf_t, pb_hash_list));
8018 +       kdb_printf("  pb_file_offset 0x%llx pb_buffer_length 0x%llx pb_addr 0x%p\n",
8019 +                  (unsigned long long) pb->pb_file_offset,
8020 +                  (unsigned long long) pb->pb_buffer_length,
8021 +                  pb->pb_addr);
8022 +       kdb_printf("  pb_bn 0x%Lx pb_count_desired 0x%lx pb_locked %d\n",
8023 +                  pb->pb_bn,
8024 +                  (unsigned long) pb->pb_count_desired, (int)pb->pb_locked);
8025 +       kdb_printf("  pb_flushtime %ld (%ld) pb_io_remaining %d pb_error %u\n",
8026 +                  pb->pb_flushtime, pb->pb_flushtime - jiffies,
8027 +                  pb->pb_io_remaining.counter, pb->pb_error);
8028 +       kdb_printf("  pb_page_count %u pb_offset 0x%x pb_pages 0x%p\n",
8029 +               pb->pb_page_count, pb->pb_offset,
8030 +               pb->pb_pages);
8031 +       kdb_printf("  pb_iodonesema (%d,%d) pb_sema (%d,%d) pincount (%d)\n",
8032 +                  pb->pb_iodonesema.count.counter,
8033 +                  pb->pb_iodonesema.sleepers,
8034 +                  pb->pb_sema.count.counter, pb->pb_sema.sleepers,
8035 +                  pb->pb_pin_count.counter);
8036 +#ifdef PAGEBUF_LOCK_TRACKING
8037 +       kdb_printf("  last holder %d\n", pb->pb_last_holder);
8038 +#endif
8039 +       if (pb->pb_fspriv || pb->pb_fspriv2) {
8040 +               kdb_printf(  "  pb_fspriv 0x%p pb_fspriv2 0x%p\n",
8041 +                          pb->pb_fspriv, pb->pb_fspriv2);
8042 +       }
8043 +}
8044 +
8045  static int
8046  kdbm_pb(int argc, const char **argv, const char **envp, struct pt_regs *regs)
8047  {
8048 @@ -1849,109 +2540,64 @@
8049             (diag = kdb_getarea(bp, addr)))
8050                 return diag;
8051  
8052 -       kdb_printf("page_buf_t at 0x%lx\n", addr);
8053 -       kdb_printf("  pb_flags %s\n", pb_flags(bp.pb_flags));
8054 -       kdb_printf("  pb_target 0x%p pb_hold %d pb_next 0x%p pb_prev 0x%p\n",
8055 -                  bp.pb_target, bp.pb_hold.counter,
8056 -                  bp.pb_list.next, bp.pb_list.prev);
8057 -       kdb_printf("  pb_hash_index %d pb_hash_next 0x%p pb_hash_prev 0x%p\n",
8058 -                  bp.pb_hash_index,
8059 -                  bp.pb_hash_list.next,
8060 -                  bp.pb_hash_list.prev);
8061 -       kdb_printf("  pb_file_offset 0x%llx pb_buffer_length 0x%llx pb_addr 0x%p\n",
8062 -                  (unsigned long long) bp.pb_file_offset,
8063 -                  (unsigned long long) bp.pb_buffer_length,
8064 -                  bp.pb_addr);
8065 -       kdb_printf("  pb_bn 0x%Lx pb_count_desired 0x%lx\n",
8066 -                  bp.pb_bn,
8067 -                  (unsigned long) bp.pb_count_desired);
8068 -       kdb_printf("  pb_io_remaining %d pb_error %u\n",
8069 -                  bp.pb_io_remaining.counter,
8070 -                  bp.pb_error);
8071 -       kdb_printf("  pb_page_count %u pb_offset 0x%x pb_pages 0x%p\n",
8072 -               bp.pb_page_count, bp.pb_offset,
8073 -               bp.pb_pages);
8074 -#ifdef PAGEBUF_LOCK_TRACKING
8075 -       kdb_printf("  pb_iodonesema (%d,%d) pb_sema (%d,%d) pincount (%d) last holder %d\n",
8076 -                  bp.pb_iodonesema.count.counter,
8077 -                  bp.pb_iodonesema.sleepers,
8078 -                  bp.pb_sema.count.counter, bp.pb_sema.sleepers,
8079 -                  bp.pb_pin_count.counter, bp.pb_last_holder);
8080 -#else
8081 -       kdb_printf("  pb_iodonesema (%d,%d) pb_sema (%d,%d) pincount (%d)\n",
8082 -                  bp.pb_iodonesema.count.counter,
8083 -                  bp.pb_iodonesema.sleepers,
8084 -                  bp.pb_sema.count.counter, bp.pb_sema.sleepers,
8085 -                  bp.pb_pin_count.counter);
8086 -#endif
8087 -       if (bp.pb_fspriv || bp.pb_fspriv2) {
8088 -               kdb_printf(  "pb_fspriv 0x%p pb_fspriv2 0x%p\n",
8089 -                          bp.pb_fspriv, bp.pb_fspriv2);
8090 -       }
8091 +       print_pagebuf(&bp, addr);
8092  
8093         return 0;
8094  }
8095  
8096 -/* XXXXXXXXXXXXXXXXXXXXXX */
8097 -/* The start of this deliberately looks like a read_descriptor_t in layout */
8098 -typedef struct {
8099 -       read_descriptor_t io_rdesc;
8100 -
8101 -       /* 0x10 */
8102 -       page_buf_rw_t io_dir;   /* read or write */
8103 -       loff_t io_offset;       /* Starting offset of I/O */
8104 -       int io_iovec_nr;        /* Number of entries in iovec */
8105 -
8106 -       /* 0x20 */
8107 -       struct iovec **io_iovec;        /* iovec list indexed by iovec_index */
8108 -       loff_t io_iovec_offset; /* offset into current iovec. */
8109 -       int io_iovec_index;     /* current iovec being processed */
8110 -       unsigned int io_sshift; /* sector bit shift */
8111 -       loff_t io_i_size;       /* size of the file */
8112 -} pb_io_desc_t;
8113 -
8114  static int
8115 -kdbm_pbiodesc(int argc, const char **argv, const char **envp,
8116 +kdbm_pbdelay(int argc, const char **argv, const char **envp,
8117         struct pt_regs *regs)
8118  {
8119 -       pb_io_desc_t    pbio;
8120 +#ifdef DEBUG
8121 +       unsigned long   verbose = 0;
8122 +       int     count = 0;
8123 +       struct list_head        *curr, *next;
8124 +       page_buf_t      bp;
8125         unsigned long addr;
8126 -       long    offset=0;
8127 -       int nextarg;
8128         int diag;
8129 +       extern struct list_head pbd_delwrite_queue;
8130  
8131 -       if (argc != 1)
8132 +       if (argc > 1)
8133                 return KDB_ARGCOUNT;
8134  
8135 -       nextarg = 1;
8136 -       if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs)) ||
8137 -           (diag = kdb_getarea(pbio, addr)))
8138 -
8139 -       kdb_printf("pb_io_desc_t at 0x%lx\n", addr);
8140 -       kdb_printf("  io_rdesc [ written 0x%lx count 0x%lx buf 0x%p error %d ]\n",
8141 -                       (unsigned long) pbio.io_rdesc.written,
8142 -                       (unsigned long) pbio.io_rdesc.count,
8143 -                       pbio.io_rdesc.buf, pbio.io_rdesc.error);
8144 -
8145 -       kdb_printf("  io_dir %d io_offset 0x%Lx io_iovec_nr 0x%d\n",
8146 -                       pbio.io_dir, pbio.io_offset, pbio.io_iovec_nr);
8147 +       if (argc == 1) {
8148 +               if ((diag = kdbgetularg(argv[1], &verbose))) {
8149 +                       return diag;
8150 +               }
8151 +       }
8152  
8153 -       kdb_printf("  io_iovec 0x%p io_iovec_offset 0x%Lx io_iovec_index 0x%d\n",
8154 -               pbio.io_iovec, pbio.io_iovec_offset, pbio.io_iovec_index);
8155 +       if (!verbose) {
8156 +               kdb_printf("index pb       pin   flushtime\n");
8157 +       }
8158  
8159 -       kdb_printf("  io_sshift 0x%d io_i_size 0x%Lx\n",
8160 -               pbio.io_sshift, pbio.io_i_size);
8161 +       list_for_each_safe(curr, next, &pbd_delwrite_queue) {
8162 +               addr = (unsigned long)list_entry(curr, page_buf_t, pb_list);
8163 +               if ((diag = kdb_getarea(bp, addr)))
8164 +                       return diag;
8165  
8166 +               if (verbose) {
8167 +                       print_pagebuf(&bp, addr);
8168 +               } else {
8169 +                       kdb_printf("%4d  0x%lx   %d   %ld\n",
8170 +                               count++, addr, 
8171 +                               bp.pb_pin_count.counter,
8172 +                               bp.pb_flushtime - jiffies);
8173 +               }
8174 +       }
8175 +#else
8176 +       kdb_printf("pbd_delwrite_queue inaccessible (non-debug)\n");
8177 +#endif
8178         return 0;
8179  }
8180  
8181  static int
8182 -kdbm_pbmap(int argc, const char **argv, const char **envp,
8183 +kdbm_iomap(int argc, const char **argv, const char **envp,
8184         struct pt_regs *regs)
8185  {
8186 -       page_buf_bmap_t pbm;
8187 +       xfs_iomap_t iomap;
8188         unsigned long addr;
8189 -       long    offset=0;
8190 +       long offset=0;
8191         int nextarg;
8192         int diag;
8193  
8194 @@ -1960,113 +2606,49 @@
8195  
8196         nextarg = 1;
8197         if ((diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs)) ||
8198 -           (diag = kdb_getarea(pbm, addr)))
8199 +           (diag = kdb_getarea(iomap, addr)))
8200  
8201 -       kdb_printf("page_buf_bmap_t at 0x%lx\n", addr);
8202 -       kdb_printf("  pbm_bn 0x%llx pbm_offset 0x%Lx pbm_delta 0x%lx pbm_bsize 0x%lx\n",
8203 -               (long long) pbm.pbm_bn, pbm.pbm_offset,
8204 -               (unsigned long) pbm.pbm_delta, (unsigned long) pbm.pbm_bsize);
8205 +       kdb_printf("iomap_t at 0x%lx\n", addr);
8206 +       kdb_printf("  iomap_bn 0x%llx iomap_offset 0x%Lx iomap_delta 0x%lx iomap_bsize 0x%lx\n",
8207 +               (long long) iomap.iomap_bn, iomap.iomap_offset,
8208 +               (unsigned long) iomap.iomap_delta, (unsigned long) iomap.iomap_bsize);
8209  
8210 -       kdb_printf("  pbm_flags %s\n", map_flags(pbm.pbm_flags, pbm_flag_vals));
8211 +       kdb_printf("  iomap_flags %s\n", map_flags(iomap.iomap_flags, iomap_flag_vals));
8212  
8213         return 0;
8214  }
8215  
8216  #ifdef PAGEBUF_TRACE
8217 -# ifdef __PAGEBUF_TRACE__
8218 -# undef __PAGEBUF_TRACE__
8219 -# undef PB_DEFINE_TRACES
8220 -# undef PB_TRACE_START
8221 -# undef PB_TRACE_REC
8222 -# undef PB_TRACE_END
8223 -# endif
8224 -#include "pagebuf/page_buf_trace.h"
8225 -
8226 -#define EV_SIZE        (sizeof(event_names)/sizeof(char *))
8227 -
8228 -void
8229 -pb_trace_core(
8230 -       unsigned long match,
8231 -       char    *event_match,
8232 -       unsigned long long offset,
8233 -       long long mask)
8234 -{
8235 -       extern struct pagebuf_trace_buf pb_trace;
8236 -       int i, total, end;
8237 -       pagebuf_trace_t *trace;
8238 -       char    *event;
8239 -       char    value[10];
8240 -
8241 -       end = pb_trace.start - 1;
8242 -       if (end < 0)
8243 -               end = PB_TRACE_BUFSIZE - 1;
8244 -
8245 -       if (match && (match < PB_TRACE_BUFSIZE)) {
8246 -               for (i = pb_trace.start, total = 0; i != end; i = CIRC_INC(i)) {
8247 -                       trace = &pb_trace.buf[i];
8248 -                       if (trace->pb == 0)
8249 -                               continue;
8250 -                       total++;
8251 -               }
8252 -               total = total - match;
8253 -               for (i = pb_trace.start; i != end && total; i = CIRC_INC(i)) {
8254 -                       trace = &pb_trace.buf[i];
8255 -                       if (trace->pb == 0)
8256 -                               continue;
8257 -                       total--;
8258 -               }
8259 -               match = 0;
8260 -       } else
8261 -               i = pb_trace.start;
8262 -       for ( ; i != end; i = CIRC_INC(i)) {
8263 -               trace = &pb_trace.buf[i];
8264 -
8265 -               if (offset) {
8266 -                       if ((trace->offset & ~mask) != offset)
8267 -                               continue;
8268 -               }
8269 -
8270 -               if (trace->pb == 0)
8271 -                       continue;
8272 -
8273 -               if ((match != 0) && (trace->pb != match))
8274 -                       continue;
8275 -
8276 -               if ((trace->event < EV_SIZE-1) && event_names[trace->event]) {
8277 -                       event = event_names[trace->event];
8278 -               } else if (trace->event == EV_SIZE-1) {
8279 -                       event = (char *)trace->misc;
8280 -               } else {
8281 -                       event = value;
8282 -                       sprintf(value, "%8d", trace->event);
8283 -               }
8284 -
8285 -               if (event_match && strcmp(event, event_match)) {
8286 -                       continue;
8287 -               }
8288 +static int pagebuf_trace_entry(ktrace_entry_t *ktep)
8289 +{
8290 +       unsigned long long daddr;
8291  
8292 +       daddr = ((unsigned long long)(unsigned long)ktep->val[8] << 32)
8293 +               | ((unsigned long long)(unsigned long)ktep->val[9]);
8294  
8295 -               kdb_printf("pb 0x%lx [%s] (hold %u lock %d) misc 0x%p",
8296 -                          trace->pb, event,
8297 -                          trace->hold, trace->lock_value,
8298 -                          trace->misc);
8299 -               kdb_symbol_print((unsigned int)trace->ra, NULL,
8300 -                       KDB_SP_SPACEB|KDB_SP_PAREN|KDB_SP_NEWLINE);
8301 -               kdb_printf("    offset 0x%Lx size 0x%x task 0x%p\n",
8302 -                          trace->offset, trace->size, trace->task);
8303 -               kdb_printf("    flags: %s\n",
8304 -                          pb_flags(trace->flags));
8305 -       }
8306 +       kdb_printf("pb 0x%p [%s] (hold %lu lock %ld) data 0x%p",
8307 +               ktep->val[0],
8308 +               (char *)ktep->val[1],
8309 +               (unsigned long)ktep->val[3],
8310 +               (long)ktep->val[4],
8311 +               ktep->val[6]);
8312 +       kdb_symbol_print((unsigned long)ktep->val[7], NULL,
8313 +               KDB_SP_SPACEB|KDB_SP_PAREN|KDB_SP_NEWLINE);
8314 +       kdb_printf("    offset 0x%llx size 0x%lx task 0x%p\n",
8315 +               daddr, (long)ktep->val[10], ktep->val[5]);
8316 +       kdb_printf("    flags: %s\n", pb_flags((int)(long)ktep->val[2]));
8317 +       return 1;
8318  }
8319  
8320 -
8321  static int
8322  kdbm_pbtrace_offset(int argc, const char **argv, const char **envp,
8323         struct pt_regs *regs)
8324  {
8325 -       long mask = 0;
8326 -       unsigned long offset = 0;
8327 -       int diag;
8328 +       long            mask = 0;
8329 +       unsigned long   offset = 0;
8330 +       int             diag;
8331 +       ktrace_entry_t  *ktep;
8332 +       ktrace_snap_t   kts;
8333  
8334         if (argc > 2)
8335                 return KDB_ARGCOUNT;
8336 @@ -2078,13 +2660,23 @@
8337         }
8338  
8339         if (argc > 1) {
8340 -               diag = kdbgetularg(argv[1], &mask);
8341 +               diag = kdbgetularg(argv[1], &mask);     /* sign extent mask */
8342                 if (diag)
8343                         return diag;
8344         }
8345  
8346 -       pb_trace_core(0, NULL, (unsigned long long)offset,
8347 -                              (long long)mask);        /* sign extent mask */
8348 +       ktep = ktrace_first(pagebuf_trace_buf, &kts);
8349 +       while (ktep != NULL) {
8350 +               unsigned long long daddr;
8351 +
8352 +               daddr = ((unsigned long long)(unsigned long)ktep->val[8] << 32)
8353 +                       | ((unsigned long long)(unsigned long)ktep->val[9]);
8354 +               if (offset && ((daddr & ~mask) != offset))
8355 +                       continue;
8356 +               if (pagebuf_trace_entry(ktep))
8357 +                       kdb_printf("\n");
8358 +               ktep = ktrace_next(pagebuf_trace_buf, &kts);
8359 +       }
8360         return 0;
8361  }
8362  
8363 @@ -2092,10 +2684,12 @@
8364  kdbm_pbtrace(int argc, const char **argv, const char **envp,
8365         struct pt_regs *regs)
8366  {
8367 -       unsigned long addr = 0;
8368 -       int diag, nextarg;
8369 -       long offset = 0;
8370 -       char    *event_match = NULL;
8371 +       unsigned long   addr = 0;
8372 +       int             diag, nextarg;
8373 +       long            offset = 0;
8374 +       char            *event_match = NULL;
8375 +       ktrace_entry_t  *ktep;
8376 +       ktrace_snap_t   kts;
8377  
8378         if (argc > 1)
8379                 return KDB_ARGCOUNT;
8380 @@ -2103,69 +2697,102 @@
8381         if (argc == 1) {
8382                 if (isupper(argv[1][0]) || islower(argv[1][0])) {
8383                         event_match = (char *)argv[1];
8384 -                       printk("event match on \"%s\"\n", event_match);
8385 +                       kdb_printf("event match on \"%s\"\n", event_match);
8386                         argc = 0;
8387                 } else {
8388                         nextarg = 1;
8389 -                       diag = kdbgetaddrarg(argc, argv, &nextarg, &addr, &offset, NULL, regs);
8390 +                       diag = kdbgetaddrarg(argc, argv,
8391 +                                       &nextarg, &addr, &offset, NULL, regs);
8392                         if (diag) {
8393 -                               printk("failed to parse %s as a number\n",
8394 -                                                               argv[1]);
8395 +                               kdb_printf("non-numeric arg: %s\n", argv[1]);
8396                                 return diag;
8397                         }
8398                 }
8399         }
8400  
8401 -       pb_trace_core(addr, event_match, 0LL, 0LL);
8402 -       return 0;
8403 -}
8404 -
8405 -#else  /* PAGEBUF_TRACE */
8406 -static int
8407 -kdbm_pbtrace(int argc, const char **argv, const char **envp,
8408 -       struct pt_regs *regs)
8409 -{
8410 -       kdb_printf("pagebuf tracing not compiled in\n");
8411 -
8412 +       ktep = ktrace_first(pagebuf_trace_buf, &kts);
8413 +       while (ktep != NULL) {
8414 +               if (addr && (ktep->val[0] != (void *)addr))
8415 +                       continue;
8416 +               if (event_match && strcmp((char *)ktep->val[1], event_match))
8417 +                       continue;
8418 +               if (pagebuf_trace_entry(ktep))
8419 +                       qprintf("\n");
8420 +               ktep = ktrace_next(pagebuf_trace_buf, &kts);
8421 +       }
8422         return 0;
8423  }
8424 -#endif /* PAGEBUF_TRACE */
8425 +#endif
8426  
8427 -static struct xif {
8428 +struct xif {
8429         char    *name;
8430         int     (*func)(int, const char **, const char **, struct pt_regs *);
8431         char    *args;
8432         char    *help;
8433 -} xfsidbg_funcs[] = {
8434 +};
8435 +
8436 +static struct xif xfsidbg_funcs[] = {
8437 +  {  "bhv",    kdbm_bhv,       "<bhv>", "Dump bhv chain"},
8438    {  "vn",     kdbm_vn,        "<vnode>", "Dump inode/vnode/trace"},
8439    {  "vnode",  kdbm_vnode,     "<vnode>", "Dump vnode"},
8440 -#ifdef CONFIG_XFS_VNODE_TRACING
8441 +  {  "vfs",    kdbm_vfs,       "<vfs>", "Dump vfs"},
8442 +#ifdef XFS_VNODE_TRACE
8443    {  "vntrace",        kdbm_vntrace,   "<vntrace>", "Dump vnode Trace"},
8444 -  {  "vntraceaddr",    kdbm_vntraceaddr, "<vntrace>", "Dump vnode Trace by Address"},
8445 -#endif /* CONFIG_XFS_VNODE_TRACING */
8446 +  {  "vntraceaddr",    kdbm_vntraceaddr, "<vntrace>",
8447 +                               "Dump vnode Trace by Address"},
8448 +#endif
8449    {  "xagf",   kdbm_xfs_xagf,  "<agf>",
8450                                 "Dump XFS allocation group freespace" },
8451    {  "xagi",   kdbm_xfs_xagi,  "<agi>",
8452                                 "Dump XFS allocation group inode" },
8453    {  "xail",   kdbm_xfs_xaildump,      "<xfs_mount_t>",
8454                                 "Dump XFS AIL for a mountpoint" },
8455 +#ifdef XFS_ALLOC_TRACE
8456 +  {  "xalatrc",        kdbm_xfs_xalatrace,     "<count>",
8457 +                               "Dump XFS alloc count trace" },
8458 +  {  "xalbtrc",        kdbm_xfs_xalbtrace,     "<xfs_agblock_t>",
8459 +                               "Dump XFS alloc block trace" },
8460 +  {  "xalgtrc",        kdbm_xfs_xalgtrace,     "<xfs_agnumber_t>",
8461 +                               "Dump XFS alloc alloc-group trace" },
8462 +#endif
8463 +
8464    {  "xalloc", kdbm_xfs_xalloc,        "<xfs_alloc_arg_t>",
8465                                 "Dump XFS allocation args structure" },
8466 -#ifdef DEBUG
8467 +#ifdef XFS_ALLOC_TRACE
8468    {  "xalmtrc",        kdbm_xfs_xalmtrace,     "<xfs_mount_t>",
8469                                 "Dump XFS alloc mount-point trace" },
8470 +  {  "xalttrc",        kdbm_xfs_xalttrace,     "<tag>",
8471 +                               "Dump XFS alloc trace by tag number" },
8472  #endif
8473 +  {  "xarg",   kdbm_xfs_xarg,          "<value>",
8474 +                               "Input XFS argument for next function" },
8475    {  "xattrcx",        kdbm_xfs_xattrcontext,  "<xfs_attr_list_context_t>",
8476                                 "Dump XFS attr_list context struct"},
8477    {  "xattrlf",        kdbm_xfs_xattrleaf,     "<xfs_attr_leafblock_t>",
8478                                 "Dump XFS attribute leaf block"},
8479    {  "xattrsf",        kdbm_xfs_xattrsf,       "<xfs_attr_shortform_t>",
8480                                 "Dump XFS attribute shortform"},
8481 +#ifdef XFS_ATTR_TRACE
8482 +  {  "xattrtr",        kdbm_xfs_xattrtrace,    "<count>",
8483 +                               "Dump XFS attribute attr_list() trace" },
8484 +#endif
8485    {  "xbirec", kdbm_xfs_xbirec,        "<xfs_bmbt_irec_t",
8486                                 "Dump XFS bmap incore record"},
8487 +#ifdef XFS_BLI_TRACE
8488 +  {  "xblitrc",        kdbm_xfs_xblitrace,     "<xfs_buf_log_item_t>",
8489 +                               "Dump XFS buf log item trace" },
8490 +#endif
8491    {  "xbmalla",        kdbm_xfs_xbmalla,       "<xfs_bmalloca_t>",
8492                                 "Dump XFS bmalloc args structure"},
8493 -  {  "xbrec",  kdbm_xfs_xbrec,         "<xfs_bmbt_rec_64_t",
8494 +#ifdef XFS_BMAP_TRACE
8495 +  {  "xbmatrc",        kdbm_xfs_xbmatrace,     "<count>",
8496 +                               "Dump XFS bmap btree count trace" },
8497 +  {  "xbmitrc",        kdbm_xfs_xbmitrace,     "<xfs_inode_t>",
8498 +                               "Dump XFS bmap btree per-inode trace" },
8499 +  {  "xbmstrc",        kdbm_xfs_xbmstrace,     "<xfs_inode_t>",
8500 +                               "Dump XFS bmap btree inode trace" },
8501 +#endif
8502 +  {  "xbrec",  kdbm_xfs_xbrec,         "<xfs_bmbt_rec_64_t>",
8503                                 "Dump XFS bmap record"},
8504    {  "xbroot", kdbm_xfs_xbroot,        "<xfs_inode_t>",
8505                                 "Dump XFS bmap btree root (data)"},
8506 @@ -2175,12 +2802,29 @@
8507                                 "Dump XFS btree cursor"},
8508    {  "xbuf",   kdbm_xfs_xbuf,          "<xfs_buf_t>",
8509                                 "Dump XFS data from a buffer"},
8510 +#ifdef XFS_BMAP_TRACE
8511 +  {  "xbxatrc",        kdbm_xfs_xbxatrace,     "<count>",
8512 +                               "Dump XFS bmap extent count trace" },
8513 +  {  "xbxitrc",        kdbm_xfs_xbxitrace,     "<xfs_inode_t>",
8514 +                               "Dump XFS bmap extent per-inode trace" },
8515 +  {  "xbxstrc",        kdbm_xfs_xbxstrace,     "<xfs_inode_t>",
8516 +                               "Dump XFS bmap extent inode trace" },
8517 +#endif
8518    {  "xchash", kdbm_xfs_xchash,        "<xfs_mount_t>",
8519                                 "Dump XFS cluster hash"},
8520    {  "xchlist",        kdbm_xfs_xchashlist,    "<xfs_chashlist_t>",
8521                                 "Dump XFS cluster hash list"},
8522 +  {  "xchksum",        kdbm_xfs_xchksum,       "<addr>", "Dump chksum" },
8523 +#ifdef XFS_DIR2_TRACE
8524 +  {  "xd2atrc",        kdbm_xfs_xdir2atrace,   "<count>",
8525 +                               "Dump XFS directory v2 count trace" },
8526 +#endif
8527    {  "xd2free",        kdbm_xfs_xdir2free,     "<xfs_dir2_free_t>",
8528                                 "Dump XFS directory v2 freemap"},
8529 +#ifdef XFS_DIR2_TRACE
8530 +  {  "xd2itrc",        kdbm_xfs_xdir2itrace,   "<xfs_inode_t>",
8531 +                               "Dump XFS directory v2 per-inode trace" },
8532 +#endif
8533    {  "xdaargs",        kdbm_xfs_xdaargs,       "<xfs_da_args_t>",
8534                                 "Dump XFS dir/attr args structure"},
8535    {  "xdabuf", kdbm_xfs_xdabuf,        "<xfs_dabuf_t>",
8536 @@ -2197,12 +2841,20 @@
8537                                 "Dump XFS directory shortform"},
8538    {  "xdir2sf",        kdbm_xfs_xdir2sf,       "<xfs_dir2_sf_t>",
8539                                 "Dump XFS directory v2 shortform"},
8540 +#ifdef XFS_DIR_TRACE
8541 +  {  "xdirtrc",        kdbm_xfs_xdirtrace,     "<count>",
8542 +                               "Dump XFS directory getdents() trace" },
8543 +#endif
8544    {  "xdiskdq",        kdbm_xfs_xqm_diskdq,    "<xfs_disk_dquot_t>",
8545                                 "Dump XFS ondisk dquot (quota) struct"},
8546    {  "xdqatt", kdbm_xfs_xqm_dqattached_inos,   "<xfs_mount_t>",
8547                                  "All incore inodes with dquots"},
8548    {  "xdqinfo",        kdbm_xfs_xqm_tpdqinfo,  "<xfs_trans_t>",
8549                                 "Dump dqinfo structure of a trans"},
8550 +#ifdef XFS_DQUOT_TRACE
8551 +  {  "xdqtrace",kdbm_xfs_xqm_dqtrace,  "<xfs_dquot_t>",
8552 +                               "Dump trace of a given dquot" },
8553 +#endif
8554    {  "xdquot", kdbm_xfs_xqm_dquot,     "<xfs_dquot_t>",
8555                                 "Dump XFS dquot (quota) structure"},
8556    {  "xexlist",        kdbm_xfs_xexlist,       "<xfs_inode_t>",
8557 @@ -2215,12 +2867,26 @@
8558                                 "Dump All XFS in-core logs"},
8559    {  "xiclog", kdbm_xfs_xiclog,        "<xlog_in_core_t>",
8560                                 "Dump XFS in-core log"},
8561 +#ifdef XFS_LOG_TRACE
8562 +  {  "xictrc", kdbm_xfs_xiclogtrace,   "<xlog_in_core_t>",
8563 +                               "Dump XFS in-core log trace" },
8564 +#endif
8565    {  "xihash", kdbm_xfs_xihash,        "<xfs_mount_t>",
8566                                 "Dump XFS inode hash statistics"},
8567 +#ifdef XFS_ILOCK_TRACE
8568 +  {  "xilocktrc",kdbm_xfs_xilock_trace,        "<xfs_inode_t>",
8569 +                               "Dump XFS ilock trace" },
8570 +  {  "xailcktrc",kdbm_xfs_xailock_trace,"<count>",
8571 +                               "Dump XFS global ilock trace" },
8572 +#endif
8573    {  "xinodes",        kdbm_xfs_xinodes,       "<xfs_mount_t>",
8574                                 "Dump XFS inodes per mount"},
8575    {  "xquiesce",kdbm_xfs_xinodes_quiesce, "<xfs_mount_t>",
8576                                 "Dump non-quiesced XFS inodes per mount"},
8577 +#ifdef XFS_LOG_TRACE
8578 +  {  "xl_grtr",        kdbm_xfs_xlog_granttrace,       "<xlog_t>",
8579 +                               "Dump XFS log grant trace" },
8580 +#endif
8581    {  "xl_rcit",        kdbm_xfs_xlog_ritem,    "<xlog_recover_item_t>",
8582                                 "Dump XFS recovery item"},
8583    {  "xl_rctr",        kdbm_xfs_xlog_rtrans,   "<xlog_recover_t>",
8584 @@ -2255,6 +2921,10 @@
8585  #endif /* CONFIG_XFS_QUOTA */
8586    {  "xqmplist",kdbm_xfs_xqm_mplist,   "<xfs_mount_t>",
8587                                 "Dump XFS all dquots of a f/s"},
8588 +#ifdef XFS_RW_TRACE
8589 +  {  "xrwtrc", kdbm_xfs_xrwtrace,      "<xfs_inode_t>",
8590 +                               "Dump XFS inode read/write trace" },
8591 +#endif
8592    {  "xsb",    kdbm_xfs_xsb,           "<xfs_sb_t> <cnv>",
8593                                 "Dump XFS superblock"},
8594    {  "xtp",    kdbm_xfs_xtp,           "<xfs_trans_t>",
8595 @@ -2264,6 +2934,18 @@
8596    {  0,                0,      0 }
8597  };
8598  
8599 +static struct xif pb_funcs[] = {
8600 +  {  "pb",     kdbm_pb,        "<vaddr>",      "Display page_buf_t" },
8601 +  {  "pbflags",        kdbm_pb_flags,  "<flags>",      "Display page_buf flags" },
8602 +  {  "iomapap",        kdbm_iomap,     "<iomap_t *>",  "Display IOmap" },
8603 +  {  "pbdelay",        kdbm_pbdelay,   "0|1",          "Display delwri pagebufs" },
8604 +#ifdef PAGEBUF_TRACE
8605 +  {  "pbtrace",        kdbm_pbtrace,   "<vaddr>|<count>",      "page_buf_t trace" },
8606 +  {  "pboffset",kdbm_pbtrace_offset, "<daddr> [<mask>]","page_buf_t trace" },
8607 +#endif
8608 +  {  0,                0,      0 }
8609 +};
8610 +
8611  static int
8612  __init xfsidbg_init(void)
8613  {
8614 @@ -2271,20 +2953,8 @@
8615  
8616         for (p = xfsidbg_funcs; p->name; p++)
8617                 kdb_register(p->name, p->func, p->args, p->help, 0);
8618 -
8619 -       kdb_register("pb", kdbm_pb, "<vaddr>", "Display page_buf_t", 0);
8620 -       kdb_register("pbflags", kdbm_pb_flags, "<flags>",
8621 -                                       "Display page buf flags", 0);
8622 -       kdb_register("pbiodesc", kdbm_pbiodesc, "<pb_io_desc_t *>",
8623 -                                       "Display I/O Descriptor", 0);
8624 -       kdb_register("pbmap", kdbm_pbmap, "<page_buf_bmap_t *>",
8625 -                                       "Display Bmap", 0);
8626 -       kdb_register("pbtrace", kdbm_pbtrace, "<vaddr>|<count>",
8627 -                                       "page_buf_t trace", 0);
8628 -#ifdef PAGEBUF_TRACE
8629 -       kdb_register("pboffset", kdbm_pbtrace_offset, "<addr> [<mask>]",
8630 -                                       "page_buf_t trace", 0);
8631 -#endif
8632 +       for (p = pb_funcs; p->name; p++)
8633 +               kdb_register(p->name, p->func, p->args, p->help, 0);
8634         return 0;
8635  }
8636  
8637 @@ -2295,16 +2965,8 @@
8638  
8639         for (p = xfsidbg_funcs; p->name; p++)
8640                 kdb_unregister(p->name);
8641 -
8642 -       kdb_unregister("pb");
8643 -       kdb_unregister("pbflags");
8644 -       kdb_unregister("pbmap");
8645 -       kdb_unregister("pbiodesc");
8646 -       kdb_unregister("pbtrace");
8647 -#ifdef PAGEBUF_TRACE
8648 -       kdb_unregister("pboffset");
8649 -#endif
8650 -
8651 +       for (p = pb_funcs; p->name; p++)
8652 +               kdb_unregister(p->name);
8653  }
8654  
8655  /*
8656 @@ -2315,19 +2977,35 @@
8657         "start_bno", "near_bno", "this_bno"
8658  };
8659  
8660 +static int xargument = 0;
8661  
8662  /*
8663   * Prototypes for static functions.
8664   */
8665 -#ifdef DEBUG
8666 +#ifdef XFS_ALLOC_TRACE
8667  static int xfs_alloc_trace_entry(ktrace_entry_t *ktep);
8668  #endif
8669 +#ifdef XFS_ATTR_TRACE
8670 +static int xfs_attr_trace_entry(ktrace_entry_t *ktep);
8671 +#endif
8672 +#ifdef XFS_BMAP_TRACE
8673 +static int xfs_bmap_trace_entry(ktrace_entry_t *ktep);
8674 +#endif
8675 +#ifdef XFS_BMAP_TRACE
8676 +static int xfs_bmbt_trace_entry(ktrace_entry_t *ktep);
8677 +#endif
8678  static void xfs_broot(xfs_inode_t *ip, xfs_ifork_t *f);
8679  static void xfs_btalloc(xfs_alloc_block_t *bt, int bsz);
8680  static void xfs_btbmap(xfs_bmbt_block_t *bt, int bsz);
8681  static void xfs_btino(xfs_inobt_block_t *bt, int bsz);
8682  static void xfs_buf_item_print(xfs_buf_log_item_t *blip, int summary);
8683  static void xfs_dastate_path(xfs_da_state_path_t *p);
8684 +#ifdef XFS_DIR_TRACE
8685 +static int xfs_dir_trace_entry(ktrace_entry_t *ktep);
8686 +#endif
8687 +#ifdef XFS_DIR2_TRACE
8688 +static int xfs_dir2_trace_entry(ktrace_entry_t *ktep);
8689 +#endif
8690  static void xfs_dir2data(void *addr, int size);
8691  static void xfs_dir2leaf(xfs_dir2_leaf_t *leaf, int size);
8692  static void xfs_dquot_item_print(xfs_dq_logitem_t *lip, int summary);
8693 @@ -2345,6 +3023,10 @@
8694  static void xfs_prdinode(xfs_dinode_t *di, int coreonly, int convert);
8695  static void xfs_prdinode_core(xfs_dinode_core_t *dip, int convert);
8696  static void xfs_qoff_item_print(xfs_qoff_logitem_t *lip, int summary);
8697 +#ifdef XFS_RW_TRACE
8698 +static void xfs_rw_enter_trace_entry(ktrace_entry_t *ktep);
8699 +static int xfs_rw_trace_entry(ktrace_entry_t *ktep);
8700 +#endif
8701  static void xfs_xexlist_fork(xfs_inode_t *ip, int whichfork);
8702  static void xfs_xnode_fork(char *name, xfs_ifork_t *f);
8703  
8704 @@ -2352,7 +3034,7 @@
8705   * Static functions.
8706   */
8707  
8708 -#ifdef DEBUG
8709 +#ifdef XFS_ALLOC_TRACE
8710  /*
8711   * Print xfs alloc trace buffer entry.
8712   */
8713 @@ -2378,24 +3060,24 @@
8714                 return 0;
8715         switch ((long)ktep->val[0] & 0xffffL) {
8716         case XFS_ALLOC_KTRACE_ALLOC:
8717 -               kdb_printf("alloc %s[%s %d] mp 0x%p\n",
8718 +               kdb_printf("alloc %s[%s %ld] mp 0x%p\n",
8719                         (char *)ktep->val[1],
8720                         ktep->val[2] ? (char *)ktep->val[2] : "",
8721 -                       (__psint_t)ktep->val[0] >> 16,
8722 +                       (long)ktep->val[0] >> 16,
8723                         (xfs_mount_t *)ktep->val[3]);
8724                 kdb_printf(
8725 -       "agno %d agbno %d minlen %d maxlen %d mod %d prod %d minleft %d\n",
8726 -                       (__psunsigned_t)ktep->val[4],
8727 -                       (__psunsigned_t)ktep->val[5],
8728 -                       (__psunsigned_t)ktep->val[6],
8729 -                       (__psunsigned_t)ktep->val[7],
8730 -                       (__psunsigned_t)ktep->val[8],
8731 -                       (__psunsigned_t)ktep->val[9],
8732 -                       (__psunsigned_t)ktep->val[10]);
8733 -               kdb_printf("total %d alignment %d len %d type %s otype %s\n",
8734 -                       (__psunsigned_t)ktep->val[11],
8735 -                       (__psunsigned_t)ktep->val[12],
8736 -                       (__psunsigned_t)ktep->val[13],
8737 +       "agno %ld agbno %ld minlen %ld maxlen %ld mod %ld prod %ld minleft %ld\n",
8738 +                       (long)ktep->val[4],
8739 +                       (long)ktep->val[5],
8740 +                       (long)ktep->val[6],
8741 +                       (long)ktep->val[7],
8742 +                       (long)ktep->val[8],
8743 +                       (long)ktep->val[9],
8744 +                       (long)ktep->val[10]);
8745 +               kdb_printf("total %ld alignment %ld len %ld type %s otype %s\n",
8746 +                       (long)ktep->val[11],
8747 +                       (long)ktep->val[12],
8748 +                       (long)ktep->val[13],
8749                         xfs_alloctype[((__psint_t)ktep->val[14]) >> 16],
8750                         xfs_alloctype[((__psint_t)ktep->val[14]) & 0xffff]);
8751                 kdb_printf("wasdel %d wasfromfl %d isfl %d userdata %d\n",
8752 @@ -2405,76 +3087,76 @@
8753                         ((__psint_t)ktep->val[15] & (1 << 0)) != 0);
8754                 break;
8755         case XFS_ALLOC_KTRACE_FREE:
8756 -               kdb_printf("free %s[%s %d] mp 0x%p\n",
8757 +               kdb_printf("free %s[%s %ld] mp 0x%p\n",
8758                         (char *)ktep->val[1],
8759                         ktep->val[2] ? (char *)ktep->val[2] : "",
8760 -                       (__psint_t)ktep->val[0] >> 16,
8761 +                       (long)ktep->val[0] >> 16,
8762                         (xfs_mount_t *)ktep->val[3]);
8763 -               kdb_printf("agno %d agbno %d len %d isfl %d\n",
8764 -                       (__psunsigned_t)ktep->val[4],
8765 -                       (__psunsigned_t)ktep->val[5],
8766 -                       (__psunsigned_t)ktep->val[6],
8767 -                       (__psint_t)ktep->val[7]);
8768 +               kdb_printf("agno %ld agbno %ld len %ld isfl %d\n",
8769 +                       (long)ktep->val[4],
8770 +                       (long)ktep->val[5],
8771 +                       (long)ktep->val[6],
8772 +                       (__psint_t)ktep->val[7] != 0);
8773                 break;
8774         case XFS_ALLOC_KTRACE_MODAGF:
8775 -               kdb_printf("modagf %s[%s %d] mp 0x%p\n",
8776 +               kdb_printf("modagf %s[%s %ld] mp 0x%p\n",
8777                         (char *)ktep->val[1],
8778                         ktep->val[2] ? (char *)ktep->val[2] : "",
8779 -                       (__psint_t)ktep->val[0] >> 16,
8780 +                       (long)ktep->val[0] >> 16,
8781                         (xfs_mount_t *)ktep->val[3]);
8782                 printflags((__psint_t)ktep->val[4], modagf_flags, "modified");
8783 -               kdb_printf("seqno %d length %d roots b %d c %d\n",
8784 -                       (__psunsigned_t)ktep->val[5],
8785 -                       (__psunsigned_t)ktep->val[6],
8786 -                       (__psunsigned_t)ktep->val[7],
8787 -                       (__psunsigned_t)ktep->val[8]);
8788 -               kdb_printf("levels b %d c %d flfirst %d fllast %d flcount %d\n",
8789 -                       (__psunsigned_t)ktep->val[9],
8790 -                       (__psunsigned_t)ktep->val[10],
8791 -                       (__psunsigned_t)ktep->val[11],
8792 -                       (__psunsigned_t)ktep->val[12],
8793 -                       (__psunsigned_t)ktep->val[13]);
8794 -               kdb_printf("freeblks %d longest %d\n",
8795 -                       (__psunsigned_t)ktep->val[14],
8796 -                       (__psunsigned_t)ktep->val[15]);
8797 +               kdb_printf("seqno %lu length %lu roots b %lu c %lu\n",
8798 +                       (unsigned long)ktep->val[5],
8799 +                       (unsigned long)ktep->val[6],
8800 +                       (unsigned long)ktep->val[7],
8801 +                       (unsigned long)ktep->val[8]);
8802 +               kdb_printf("levels b %lu c %lu flfirst %lu fllast %lu flcount %lu\n",
8803 +                       (unsigned long)ktep->val[9],
8804 +                       (unsigned long)ktep->val[10],
8805 +                       (unsigned long)ktep->val[11],
8806 +                       (unsigned long)ktep->val[12],
8807 +                       (unsigned long)ktep->val[13]);
8808 +               kdb_printf("freeblks %lu longest %lu\n",
8809 +                       (unsigned long)ktep->val[14],
8810 +                       (unsigned long)ktep->val[15]);
8811                 break;
8812  
8813         case XFS_ALLOC_KTRACE_UNBUSY:
8814 -               kdb_printf("unbusy %s [%s %d] mp 0x%p\n",
8815 +               kdb_printf("unbusy %s [%s %ld] mp 0x%p\n",
8816                         (char *)ktep->val[1],
8817                         ktep->val[2] ? (char *)ktep->val[2] : "",
8818 -                       (__psint_t)ktep->val[0] >> 16,
8819 +                       (long)ktep->val[0] >> 16,
8820                         (xfs_mount_t *)ktep->val[3]);
8821 -               kdb_printf("      agno %d slot %d tp 0x%x\n",
8822 -                       (__psunsigned_t)ktep->val[4],
8823 -                       (__psunsigned_t)ktep->val[7],
8824 -                       (__psunsigned_t)ktep->val[8]);
8825 +               kdb_printf("      agno %lu slot %lu tp 0x%p\n",
8826 +                       (unsigned long)ktep->val[4],
8827 +                       (unsigned long)ktep->val[7],
8828 +                       (xfs_trans_t *)ktep->val[8]);
8829                 break;
8830         case XFS_ALLOC_KTRACE_BUSY:
8831 -               kdb_printf("busy %s [%s %d] mp 0x%p\n",
8832 +               kdb_printf("busy %s [%s %ld] mp 0x%p\n",
8833                         (char *)ktep->val[1],
8834                         ktep->val[2] ? (char *)ktep->val[2] : "",
8835 -                       (__psint_t)ktep->val[0] >> 16,
8836 +                       (long)ktep->val[0] >> 16,
8837                         (xfs_mount_t *)ktep->val[3]);
8838 -               kdb_printf("      agno %d agbno %d len %d slot %d tp 0x%x\n",
8839 -                       (__psunsigned_t)ktep->val[4],
8840 -                       (__psunsigned_t)ktep->val[5],
8841 -                       (__psunsigned_t)ktep->val[6],
8842 -                       (__psunsigned_t)ktep->val[7],
8843 -                       (__psunsigned_t)ktep->val[8]);
8844 +               kdb_printf("      agno %lu agbno %lu len %lu slot %lu tp 0x%p\n",
8845 +                       (unsigned long)ktep->val[4],
8846 +                       (unsigned long)ktep->val[5],
8847 +                       (unsigned long)ktep->val[6],
8848 +                       (unsigned long)ktep->val[7],
8849 +                       (xfs_trans_t *)ktep->val[8]);
8850                 break;
8851         case XFS_ALLOC_KTRACE_BUSYSEARCH:
8852 -               kdb_printf("busy-search %s [%s %d] mp 0x%p\n",
8853 +               kdb_printf("busy-search %s [%s %ld] mp 0x%p\n",
8854                         (char *)ktep->val[1],
8855                         ktep->val[2] ? (char *)ktep->val[2] : "",
8856 -                       (__psint_t)ktep->val[0] >> 16,
8857 +                       (long)ktep->val[0] >> 16,
8858                         (xfs_mount_t *)ktep->val[3]);
8859 -               kdb_printf("      agno %d agbno %d len %d slot %d tp 0x%x\n",
8860 -                       (__psunsigned_t)ktep->val[4],
8861 -                       (__psunsigned_t)ktep->val[5],
8862 -                       (__psunsigned_t)ktep->val[6],
8863 -                       (__psunsigned_t)ktep->val[7],
8864 -                       (__psunsigned_t)ktep->val[8]);
8865 +               kdb_printf("      agno %ld agbno %ld len %ld slot %ld tp 0x%p\n",
8866 +                       (unsigned long)ktep->val[4],
8867 +                       (unsigned long)ktep->val[5],
8868 +                       (unsigned long)ktep->val[6],
8869 +                       (unsigned long)ktep->val[7],
8870 +                       (xfs_trans_t *)ktep->val[8]);
8871                 break;
8872         default:
8873                 kdb_printf("unknown alloc trace record\n");
8874 @@ -2482,7 +3164,242 @@
8875         }
8876         return 1;
8877  }
8878 -#endif /* DEBUG */
8879 +#endif /* XFS_ALLOC_TRACE */
8880 +
8881 +#ifdef XFS_ATTR_TRACE
8882 +/*
8883 + * Print an attribute trace buffer entry.
8884 + */
8885 +static int
8886 +xfs_attr_trace_entry(ktrace_entry_t *ktep)
8887 +{
8888 +       static char *attr_arg_flags[] = {
8889 +               "DONTFOLLOW",   /* 0x0001 */
8890 +               "ROOT",         /* 0x0002 */
8891 +               "TRUSTED",      /* 0x0004 */
8892 +               "?",            /* 0x0008 */
8893 +               "CREATE",       /* 0x0010 */
8894 +               "REPLACE",      /* 0x0020 */
8895 +               "?",            /* 0x0040 */
8896 +               "?",            /* 0x0080 */
8897 +               "SYSTEM",       /* 0x0100 */
8898 +               "?",            /* 0x0200 */
8899 +               "?",            /* 0x0400 */
8900 +               "?",            /* 0x0800 */
8901 +               "KERNOTIME",    /* 0x1000 */
8902 +               "KERNOVAL",     /* 0x2000 */
8903 +               "KERNAMELS",    /* 0x4000 */
8904 +               "KERNFULLS",    /* 0x8000 */
8905 +               NULL
8906 +       };
8907 +
8908 +       if (!ktep->val[0])
8909 +               return 0;
8910 +
8911 +       qprintf("-- %s: cursor h/b/o 0x%lx/0x%lx/%lu, dupcnt %lu, dp 0x%p\n",
8912 +                (char *)ktep->val[1],
8913 +                (unsigned long)ktep->val[3],
8914 +                (unsigned long)ktep->val[4],
8915 +                (unsigned long)ktep->val[5],
8916 +                (unsigned long)ktep->val[11],
8917 +                (xfs_inode_t *)ktep->val[2]);
8918 +       qprintf("   alist 0x%p, size %lu, count %lu, firstu %lu, Llen %lu",
8919 +                (attrlist_t *)ktep->val[6],
8920 +                (unsigned long)ktep->val[7],
8921 +                (unsigned long)ktep->val[8],
8922 +                (unsigned long)ktep->val[9],
8923 +                (unsigned long)ktep->val[10]);
8924 +       printflags((__psunsigned_t)(ktep->val[12]), attr_arg_flags, ", flags");
8925 +       qprintf("\n");
8926 +
8927 +       switch ((__psint_t)ktep->val[0]) {
8928 +       case XFS_ATTR_KTRACE_L_C:
8929 +               break;
8930 +       case XFS_ATTR_KTRACE_L_CN:
8931 +               qprintf("   node: count %lu, 1st hash 0x%lx, last hash 0x%lx\n",
8932 +                        (unsigned long)ktep->val[13],
8933 +                        (unsigned long)ktep->val[14],
8934 +                        (unsigned long)ktep->val[15]);
8935 +               break;
8936 +       case XFS_ATTR_KTRACE_L_CB:
8937 +               qprintf("   btree: hash 0x%lx, blkno 0x%lx\n",
8938 +                        (unsigned long)ktep->val[13],
8939 +                        (unsigned long)ktep->val[14]);
8940 +               break;
8941 +       case XFS_ATTR_KTRACE_L_CL:
8942 +               qprintf("   leaf: count %ld, 1st hash 0x%lx, last hash 0x%lx\n",
8943 +                        (unsigned long)ktep->val[13],
8944 +                        (unsigned long)ktep->val[14],
8945 +                        (unsigned long)ktep->val[15]);
8946 +               break;
8947 +       default:
8948 +               qprintf("   unknown attr trace record format\n");
8949 +               break;
8950 +       }
8951 +       return 1;
8952 +}
8953 +#endif /* XFS_ATTR_TRACE */
8954 +
8955 +#ifdef XFS_BMAP_TRACE
8956 +/*
8957 + * Print xfs bmap extent trace buffer entry.
8958 + */
8959 +static int
8960 +xfs_bmap_trace_entry(ktrace_entry_t *ktep)
8961 +{
8962 +       xfs_dfsbno_t        b;
8963 +       xfs_dfilblks_t    c;
8964 +       xfs_inode_t          *ip;
8965 +       xfs_ino_t              ino;
8966 +       xfs_dfiloff_t      o;
8967 +       int                  flag;
8968 +       int                  opcode;
8969 +       static char          *ops[] = { "del", "ins", "pre", "post" };
8970 +       xfs_bmbt_rec_32_t       r;
8971 +       int                  whichfork;
8972 +
8973 +       opcode = ((__psint_t)ktep->val[0]) & 0xffff;
8974 +       if (opcode == 0)
8975 +               return 0;
8976 +       whichfork = ((__psint_t)ktep->val[0]) >> 16;
8977 +       ip = (xfs_inode_t *)ktep->val[3];
8978 +       ino = ((xfs_ino_t)(unsigned long)ktep->val[6] << 32) |
8979 +               ((xfs_ino_t)(unsigned long)ktep->val[7]);
8980 +       qprintf("%s %s:%s ip %p ino %s %cf\n",
8981 +               ops[opcode - 1], (char *)ktep->val[1],
8982 +               (char *)ktep->val[2], ip, xfs_fmtino(ino, ip->i_mount),
8983 +               "da"[whichfork]);
8984 +       r.l0 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[8];
8985 +       r.l1 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[9];
8986 +       r.l2 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[10];
8987 +       r.l3 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[11];
8988 +       xfs_convert_extent(&r, &o, &b, &c, &flag);
8989 +       qprintf(" idx %ld offset %lld block %s",
8990 +               (long)ktep->val[4], o,
8991 +               xfs_fmtfsblock((xfs_fsblock_t)b, ip->i_mount));
8992 +       qprintf(" count %lld flag %d\n", c, flag);
8993 +       if ((__psint_t)ktep->val[5] != 2)
8994 +               return 1;
8995 +       r.l0 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[12];
8996 +       r.l1 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[13];
8997 +       r.l2 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[14];
8998 +       r.l3 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[15];
8999 +       xfs_convert_extent(&r, &o, &b, &c, &flag);
9000 +       qprintf(" offset %lld block %s", o,
9001 +               xfs_fmtfsblock((xfs_fsblock_t)b, ip->i_mount));
9002 +       qprintf(" count %lld flag %d\n", c, flag);
9003 +       return 1;
9004 +}
9005 +
9006 +/*
9007 + * Print xfs bmap btree trace buffer entry.
9008 + */
9009 +static int
9010 +xfs_bmbt_trace_entry(
9011 +       ktrace_entry_t    *ktep)
9012 +{
9013 +       int                     line;
9014 +       xfs_bmbt_rec_32_t       r;
9015 +       xfs_bmbt_irec_t         s;
9016 +       int                     type;
9017 +       int                     whichfork;
9018 +
9019 +       type = (__psint_t)ktep->val[0] & 0xff;
9020 +       if (type == 0)
9021 +               return 0;
9022 +       whichfork = ((__psint_t)ktep->val[0] >> 8) & 0xff;
9023 +       line = ((__psint_t)ktep->val[0] >> 16) & 0xffff;
9024 +       qprintf("%s[%s@%d] ip 0x%p %cf cur 0x%p\n",
9025 +               (char *)ktep->val[1],
9026 +               (char *)ktep->val[2],
9027 +               line,
9028 +               (xfs_inode_t *)ktep->val[3],
9029 +               "da"[whichfork],
9030 +               (xfs_btree_cur_t *)ktep->val[4]);
9031 +       switch (type) {
9032 +       case XFS_BMBT_KTRACE_ARGBI:
9033 +               qprintf(" buf 0x%p i %ld\n",
9034 +                       (xfs_buf_t *)ktep->val[5],
9035 +                       (long)ktep->val[6]);
9036 +               break;
9037 +       case XFS_BMBT_KTRACE_ARGBII:
9038 +               qprintf(" buf 0x%p i0 %ld i1 %ld\n",
9039 +                       (xfs_buf_t *)ktep->val[5],
9040 +                       (long)ktep->val[6],
9041 +                       (long)ktep->val[7]);
9042 +               break;
9043 +       case XFS_BMBT_KTRACE_ARGFFFI:
9044 +               qprintf(" o 0x%x%08x b 0x%x%08x i 0x%x%08x j %ld\n",
9045 +                       (unsigned int)(long)ktep->val[5],
9046 +                       (unsigned int)(long)ktep->val[6],
9047 +                       (unsigned int)(long)ktep->val[7],
9048 +                       (unsigned int)(long)ktep->val[8],
9049 +                       (unsigned int)(long)ktep->val[9],
9050 +                       (unsigned int)(long)ktep->val[10],
9051 +                       (long)ktep->val[11]);
9052 +               break;
9053 +       case XFS_BMBT_KTRACE_ARGI:
9054 +               qprintf(" i 0x%lx\n",
9055 +                       (long)ktep->val[5]);
9056 +               break;
9057 +       case XFS_BMBT_KTRACE_ARGIFK:
9058 +               qprintf(" i 0x%lx f 0x%x%08x o 0x%x%08x\n",
9059 +                       (long)ktep->val[5],
9060 +                       (unsigned int)(long)ktep->val[6],
9061 +                       (unsigned int)(long)ktep->val[7],
9062 +                       (unsigned int)(long)ktep->val[8],
9063 +                       (unsigned int)(long)ktep->val[9]);
9064 +               break;
9065 +       case XFS_BMBT_KTRACE_ARGIFR:
9066 +               qprintf(" i 0x%lx f 0x%x%08x ",
9067 +                       (long)ktep->val[5],
9068 +                       (unsigned int)(long)ktep->val[6],
9069 +                       (unsigned int)(long)ktep->val[7]);
9070 +               s.br_startoff = (xfs_fileoff_t)
9071 +                       (((xfs_dfiloff_t)(unsigned long)ktep->val[8] << 32) |
9072 +                               (xfs_dfiloff_t)(unsigned long)ktep->val[9]);
9073 +               s.br_startblock = (xfs_fsblock_t)
9074 +                       (((xfs_dfsbno_t)(unsigned long)ktep->val[10] << 32) |
9075 +                               (xfs_dfsbno_t)(unsigned long)ktep->val[11]);
9076 +               s.br_blockcount = (xfs_filblks_t)
9077 +                       (((xfs_dfilblks_t)(unsigned long)ktep->val[12] << 32) |
9078 +                               (xfs_dfilblks_t)(unsigned long)ktep->val[13]);
9079 +               xfsidbg_xbirec(&s);
9080 +               break;
9081 +       case XFS_BMBT_KTRACE_ARGIK:
9082 +               qprintf(" i 0x%lx o 0x%x%08x\n",
9083 +                       (long)ktep->val[5],
9084 +                       (unsigned int)(long)ktep->val[6],
9085 +                       (unsigned int)(long)ktep->val[7]);
9086 +               break;
9087 +       case XFS_BMBT_KTRACE_CUR:
9088 +               qprintf(" nlevels %ld flags %ld allocated %ld ",
9089 +                       ((long)ktep->val[5] >> 24) & 0xff,
9090 +                       ((long)ktep->val[5] >> 16) & 0xff,
9091 +                       (long)ktep->val[5] & 0xffff);
9092 +               r.l0 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[6];
9093 +               r.l1 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[7];
9094 +               r.l2 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[8];
9095 +               r.l3 = (xfs_bmbt_rec_base_t)(unsigned long)ktep->val[9];
9096 +               xfsidbg_xbrec((xfs_bmbt_rec_64_t *)&r);
9097 +               qprintf(" bufs 0x%p 0x%p 0x%p 0x%p ",
9098 +                       (xfs_buf_t *)ktep->val[10],
9099 +                       (xfs_buf_t *)ktep->val[11],
9100 +                       (xfs_buf_t *)ktep->val[12],
9101 +                       (xfs_buf_t *)ktep->val[13]);
9102 +               qprintf("ptrs %ld %ld %ld %ld\n",
9103 +                       (long)ktep->val[14] >> 16,
9104 +                       (long)ktep->val[14] & 0xffff,
9105 +                       (long)ktep->val[15] >> 16,
9106 +                       (long)ktep->val[15] & 0xffff);
9107 +               break;
9108 +       default:
9109 +               qprintf("unknown bmbt trace record\n");
9110 +               break;
9111 +       }
9112 +       return 1;
9113 +}
9114 +#endif
9115  
9116  /*
9117   * Print an xfs in-inode bmap btree root.
9118 @@ -2603,8 +3520,11 @@
9119         int i;
9120  
9121         kdb_printf("magic 0x%x level %d numrecs %d leftsib 0x%x rightsib 0x%x\n",
9122 -               INT_GET(bt->bb_magic, ARCH_CONVERT), INT_GET(bt->bb_level, ARCH_CONVERT), INT_GET(bt->bb_numrecs, ARCH_CONVERT),
9123 -               INT_GET(bt->bb_leftsib, ARCH_CONVERT), INT_GET(bt->bb_rightsib, ARCH_CONVERT));
9124 +               INT_GET(bt->bb_magic, ARCH_CONVERT),
9125 +               INT_GET(bt->bb_level, ARCH_CONVERT),
9126 +               INT_GET(bt->bb_numrecs, ARCH_CONVERT),
9127 +               INT_GET(bt->bb_leftsib, ARCH_CONVERT),
9128 +               INT_GET(bt->bb_rightsib, ARCH_CONVERT));
9129         if (INT_ISZERO(bt->bb_level, ARCH_CONVERT)) {
9130  
9131                 for (i = 1; i <= INT_GET(bt->bb_numrecs, ARCH_CONVERT); i++) {
9132 @@ -2612,7 +3532,8 @@
9133  
9134                         r = XFS_BTREE_REC_ADDR(bsz, xfs_inobt, bt, i, 0);
9135                         kdb_printf("rec %d startino 0x%x freecount %d, free %Lx\n",
9136 -                               i, INT_GET(r->ir_startino, ARCH_CONVERT), INT_GET(r->ir_freecount, ARCH_CONVERT),
9137 +                               i, INT_GET(r->ir_startino, ARCH_CONVERT),
9138 +                               INT_GET(r->ir_freecount, ARCH_CONVERT),
9139                                 INT_GET(r->ir_free, ARCH_CONVERT));
9140                 }
9141         } else {
9142 @@ -2626,7 +3547,8 @@
9143                         k = XFS_BTREE_KEY_ADDR(bsz, xfs_inobt, bt, i, mxr);
9144                         p = XFS_BTREE_PTR_ADDR(bsz, xfs_inobt, bt, i, mxr);
9145                         kdb_printf("key %d startino 0x%x ptr 0x%x\n",
9146 -                               i, INT_GET(k->ir_startino, ARCH_CONVERT), INT_GET(*p, ARCH_CONVERT));
9147 +                               i, INT_GET(k->ir_startino, ARCH_CONVERT),
9148 +                               INT_GET(*p, ARCH_CONVERT));
9149                 }
9150         }
9151  }
9152 @@ -2678,30 +3600,199 @@
9153         kdb_printf("\n");
9154  }
9155  
9156 +#ifdef XFS_BMAP_TRACE
9157 +/*
9158 + * Convert an external extent descriptor to internal form.
9159 + */
9160 +static void
9161 +xfs_convert_extent(xfs_bmbt_rec_32_t *rp, xfs_dfiloff_t *op, xfs_dfsbno_t *sp,
9162 +                  xfs_dfilblks_t *cp, int *fp)
9163 +{
9164 +       xfs_dfiloff_t o;
9165 +       xfs_dfsbno_t s;
9166 +       xfs_dfilblks_t c;
9167 +       int flag;
9168 +
9169 +       flag = (((xfs_dfiloff_t)rp->l0) >> 31) & 1;
9170 +       o = ((((xfs_dfiloff_t)rp->l0) & 0x7fffffff) << 23) |
9171 +           (((xfs_dfiloff_t)rp->l1) >> 9);
9172 +       s = (((xfs_dfsbno_t)(rp->l1 & 0x000001ff)) << 43) |
9173 +           (((xfs_dfsbno_t)rp->l2) << 11) |
9174 +           (((xfs_dfsbno_t)rp->l3) >> 21);
9175 +       c = (xfs_dfilblks_t)(rp->l3 & 0x001fffff);
9176 +       *op = o;
9177 +       *sp = s;
9178 +       *cp = c;
9179 +       *fp = flag;
9180 +}
9181 +#endif
9182 +
9183 +#ifdef XFS_RW_TRACE
9184 +/*
9185 + * Print itrunc entry trace.
9186 + */
9187 +static void
9188 +xfs_ctrunc_trace_entry(ktrace_entry_t  *ktep)
9189 +{
9190 +       qprintf("ip 0x%p cpu %ld\n",
9191 +               (xfs_inode_t *)(unsigned long)ktep->val[1], (long)ktep->val[2]);
9192 +}
9193 +#endif
9194 +
9195 +/*
9196 + * Print an xfs_da_state_path structure.
9197 + */
9198 +static void
9199 +xfs_dastate_path(xfs_da_state_path_t *p)
9200 +{
9201 +       int i;
9202 +
9203 +       kdb_printf("active %d\n", p->active);
9204 +       for (i = 0; i < XFS_DA_NODE_MAXDEPTH; i++) {
9205 +               kdb_printf(" blk %d bp 0x%p blkno 0x%x",
9206 +                       i, p->blk[i].bp, p->blk[i].blkno);
9207 +               kdb_printf(" index %d hashval 0x%x ",
9208 +                       p->blk[i].index, (uint_t)p->blk[i].hashval);
9209 +               switch(p->blk[i].magic) {
9210 +               case XFS_DA_NODE_MAGIC:         kdb_printf("NODE\n");   break;
9211 +               case XFS_DIR_LEAF_MAGIC:        kdb_printf("DIR\n");    break;
9212 +               case XFS_ATTR_LEAF_MAGIC:       kdb_printf("ATTR\n");   break;
9213 +               case XFS_DIR2_LEAFN_MAGIC:      kdb_printf("DIR2\n");   break;
9214 +               default:                        kdb_printf("type ?\n"); break;
9215 +               }
9216 +       }
9217 +}
9218 +
9219 +#ifdef XFS_DIR_TRACE
9220 +/*
9221 + * Print a xfs directory trace buffer entry.
9222 + */
9223 +static int
9224 +xfs_dir_trace_entry(ktrace_entry_t *ktep)
9225 +{
9226 +       xfs_mount_t *mp;
9227 +       __uint32_t hash;
9228 +       xfs_off_t cookie;
9229 +
9230 +       if (!ktep->val[0] || !ktep->val[1])
9231 +               return 0;
9232 +
9233 +       mp = (xfs_mount_t *)ktep->val[3];
9234 +       cookie = (__psunsigned_t)ktep->val[4];
9235 +       cookie <<= 32;
9236 +       cookie |= (__psunsigned_t)ktep->val[5];
9237 +       qprintf("%s -- dp=0x%p b/e/h=%ld/%ld/0x%08lx resid=0x%lx ",
9238 +                   (char *)ktep->val[1],
9239 +                   (xfs_inode_t *)ktep->val[2],
9240 +                   (long)XFS_DA_COOKIE_BNO(mp, cookie),
9241 +                   (long)XFS_DA_COOKIE_ENTRY(mp, cookie),
9242 +                   (unsigned long)XFS_DA_COOKIE_HASH(mp, cookie),
9243 +                   (long)ktep->val[6]);
9244 +
9245 +       switch ((__psint_t)ktep->val[0]) {
9246 +       case XFS_DIR_KTRACE_G_DU:
9247 +               break;
9248 +       case XFS_DIR_KTRACE_G_DUB:
9249 +               qprintf("bno=%ld", (long)ktep->val[7]);
9250 +               break;
9251 +       case XFS_DIR_KTRACE_G_DUN:
9252 +               qprintf("forw=%ld, cnt=%ld, 0x%08lx - 0x%08lx",
9253 +                             (long)ktep->val[7],
9254 +                             (long)ktep->val[8],
9255 +                             (unsigned long)ktep->val[9],
9256 +                             (unsigned long)ktep->val[10]);
9257 +               break;
9258 +       case XFS_DIR_KTRACE_G_DUL:
9259 +               qprintf("forw=%ld, cnt=%ld, 0x%08lx - 0x%08lx",
9260 +                             (long)ktep->val[7],
9261 +                             (long)ktep->val[8],
9262 +                             (unsigned long)ktep->val[9],
9263 +                             (unsigned long)ktep->val[10]);
9264 +               break;
9265 +       case XFS_DIR_KTRACE_G_DUE:
9266 +               qprintf("entry hashval 0x%08lx", (unsigned long)ktep->val[7]);
9267 +               break;
9268 +       case XFS_DIR_KTRACE_G_DUC:
9269 +               cookie = (__psunsigned_t)ktep->val[7];
9270 +               cookie <<= 32;
9271 +               cookie |= (__psunsigned_t)ktep->val[8];
9272 +               hash = XFS_DA_COOKIE_HASH(mp, cookie);
9273 +               qprintf("b/e/h=%ld/%ld/0x%08x",
9274 +                   (long)XFS_DA_COOKIE_BNO(mp, cookie),
9275 +                   (long)XFS_DA_COOKIE_ENTRY(mp, cookie),
9276 +                   hash);
9277 +               break;
9278 +       default:
9279 +               qprintf("unknown dir trace record format");
9280 +               break;
9281 +       }
9282 +       return 1;
9283 +}
9284 +#endif
9285 +
9286 +#ifdef XFS_DIR2_TRACE
9287  /*
9288 - * Print an xfs_da_state_path structure.
9289 + * Print a xfs v2 directory trace buffer entry.
9290   */
9291 -static void
9292 -xfs_dastate_path(xfs_da_state_path_t *p)
9293 +static int
9294 +xfs_dir2_trace_entry(ktrace_entry_t *ktep)
9295  {
9296 -       int i;
9297 +       char        *cp;
9298 +       int          i;
9299 +       int          len;
9300  
9301 -       kdb_printf("active %d\n", p->active);
9302 -       for (i = 0; i < XFS_DA_NODE_MAXDEPTH; i++) {
9303 -               kdb_printf(" blk %d bp 0x%p blkno 0x%x",
9304 -                       i, p->blk[i].bp, p->blk[i].blkno);
9305 -               kdb_printf(" index %d hashval 0x%x ",
9306 -                       p->blk[i].index, (uint_t)p->blk[i].hashval);
9307 -               switch(p->blk[i].magic) {
9308 -               case XFS_DA_NODE_MAGIC:         kdb_printf("NODE\n");   break;
9309 -               case XFS_DIR_LEAF_MAGIC:        kdb_printf("DIR\n");    break;
9310 -               case XFS_ATTR_LEAF_MAGIC:       kdb_printf("ATTR\n");   break;
9311 -               case XFS_DIR2_LEAFN_MAGIC:      kdb_printf("DIR2\n");   break;
9312 -               default:                        kdb_printf("type ??\n");        break;
9313 -               }
9314 +       if (!ktep->val[0])
9315 +               return 0;
9316 +       cp = (char *)&ktep->val[10];
9317 +       qprintf("%s: '", (char *)ktep->val[1]);
9318 +       len = min((__psint_t)ktep->val[9], (__psint_t)sizeof(ktep->val[10])*6);
9319 +       for (i = 0; i < len; i++)
9320 +               qprintf("%c", cp[i]);
9321 +       qprintf("'(%ld)", (long)ktep->val[9]);
9322 +       if ((__psunsigned_t)ktep->val[0] != XFS_DIR2_KTRACE_ARGS_BIBII)
9323 +               qprintf(" hashval 0x%llx inumber %lld dp 0x%p tp 0x%p check %d",
9324 +                       (__uint64_t)(unsigned long)ktep->val[2],
9325 +                       (__int64_t)(unsigned long)ktep->val[3],
9326 +                       ktep->val[4], ktep->val[5],
9327 +                       (int)(__psint_t)ktep->val[6]);
9328 +       switch ((__psunsigned_t)ktep->val[0]) {
9329 +       case XFS_DIR2_KTRACE_ARGS:
9330 +               break;
9331 +       case XFS_DIR2_KTRACE_ARGS_B:
9332 +               qprintf(" bp 0x%p", ktep->val[7]);
9333 +               break;
9334 +       case XFS_DIR2_KTRACE_ARGS_BB:
9335 +               qprintf(" lbp 0x%p dbp 0x%p", ktep->val[7], ktep->val[8]);
9336 +               break;
9337 +       case XFS_DIR2_KTRACE_ARGS_BIBII:
9338 +               qprintf(" dp 0x%p tp 0x%p srcbp 0x%p srci %d dstbp 0x%p dsti %d count %d",
9339 +                       ktep->val[2], ktep->val[3], ktep->val[4],
9340 +                       (int)(__psint_t)ktep->val[5], ktep->val[6],
9341 +                       (int)(__psint_t)ktep->val[7],
9342 +                       (int)(__psint_t)ktep->val[8]);
9343 +               break;
9344 +       case XFS_DIR2_KTRACE_ARGS_DB:
9345 +               qprintf(" db 0x%x bp 0x%p",
9346 +                       (xfs_dir2_db_t)(unsigned long)ktep->val[7],
9347 +                       ktep->val[8]);
9348 +               break;
9349 +       case XFS_DIR2_KTRACE_ARGS_I:
9350 +               qprintf(" i 0x%lx", (unsigned long)ktep->val[7]);
9351 +               break;
9352 +       case XFS_DIR2_KTRACE_ARGS_S:
9353 +               qprintf(" s 0x%x", (int)(__psint_t)ktep->val[7]);
9354 +               break;
9355 +       case XFS_DIR2_KTRACE_ARGS_SB:
9356 +               qprintf(" s 0x%x bp 0x%p", (int)(__psint_t)ktep->val[7],
9357 +                       ktep->val[8]);
9358 +               break;
9359 +       default:
9360 +               qprintf("unknown dirv2 trace record format");
9361 +               break;
9362         }
9363 +       return 1;
9364  }
9365 -
9366 +#endif
9367  
9368  /*
9369   * Print an efd log item.
9370 @@ -2847,19 +3938,19 @@
9371         static char rval[16];
9372  
9373         sprintf(rval, "%c%c%c%c%c%c%c%c%c%c%c%c%c",
9374 -               "?fc?dxb?r?l?S?m?"[(m & IFMT) >> 12],
9375 -               m & ISUID ? 'u' : '-',
9376 -               m & ISGID ? 'g' : '-',
9377 -               m & ISVTX ? 'v' : '-',
9378 -               m & IREAD ? 'r' : '-',
9379 -               m & IWRITE ? 'w' : '-',
9380 -               m & IEXEC ? 'x' : '-',
9381 -               m & (IREAD >> 3) ? 'r' : '-',
9382 -               m & (IWRITE >> 3) ? 'w' : '-',
9383 -               m & (IEXEC >> 3) ? 'x' : '-',
9384 -               m & (IREAD >> 6) ? 'r' : '-',
9385 -               m & (IWRITE >> 6) ? 'w' : '-',
9386 -               m & (IEXEC >> 6) ? 'x' : '-');
9387 +               "?fc?dxb?r?l?S?m?"[(m & S_IFMT) >> 12],
9388 +               m & S_ISUID ? 'u' : '-',
9389 +               m & S_ISGID ? 'g' : '-',
9390 +               m & S_ISVTX ? 'v' : '-',
9391 +               m & S_IRUSR ? 'r' : '-',
9392 +               m & S_IWUSR ? 'w' : '-',
9393 +               m & S_IXUSR ? 'x' : '-',
9394 +               m & S_IRGRP ? 'r' : '-',
9395 +               m & S_IWGRP ? 'w' : '-',
9396 +               m & S_IXGRP ? 'x' : '-',
9397 +               m & S_IROTH ? 'r' : '-',
9398 +               m & S_IWOTH ? 'w' : '-',
9399 +               m & S_IXOTH ? 'x' : '-');
9400         return rval;
9401  }
9402  
9403 @@ -2883,9 +3974,9 @@
9404  xfs_fmtuuid(uuid_t *uu)
9405  {
9406         static char rval[40];
9407 -       char        *o          = rval;
9408 -       char        *i          = (unsigned char*)uu;
9409 -       int         b;
9410 +       char    *o        = rval;
9411 +       char    *i        = (unsigned char*)uu;
9412 +       int      b;
9413  
9414         for (b=0;b<16;b++) {
9415             o+=sprintf(o, "%02x", *i++);
9416 @@ -2930,9 +4021,9 @@
9417                 kdb_printf("\n");
9418                 return;
9419         }
9420 -       kdb_printf("inode 0x%p ino 0x%llu logged %d flags: ",
9421 +       kdb_printf("inode 0x%p ino 0x%llu pushbuf %d logged %d flags: ",
9422                 ilip->ili_inode, (unsigned long long) ilip->ili_format.ilf_ino,
9423 -               ilip->ili_logged);
9424 +               ilip->ili_pushbuf_flag, ilip->ili_logged);
9425         printflags(ilip->ili_flags, ili_flags, NULL);
9426         kdb_printf("\n");
9427         kdb_printf("ilock recur %d iolock recur %d ext buf 0x%p\n",
9428 @@ -2942,10 +4033,9 @@
9429         kdb_printf("root bytes %d root orig 0x%x\n",
9430                 ilip->ili_root_size, ilip->ili_orig_root);
9431  #endif
9432 -       kdb_printf("size %d fields: ", ilip->ili_format.ilf_size);
9433 -       printflags(ilip->ili_format.ilf_fields, ilf_fields, "formatfield");
9434 -       kdb_printf(" last fields: ");
9435 -       printflags(ilip->ili_last_fields, ilf_fields, "lastfield");
9436 +       kdb_printf("size %d ", ilip->ili_format.ilf_size);
9437 +       printflags(ilip->ili_format.ilf_fields, ilf_fields, "fields:");
9438 +       printflags(ilip->ili_last_fields, ilf_fields, " last fields: ");
9439         kdb_printf("\n");
9440         kdb_printf(" flush lsn %s last lsn %s\n",
9441                 xfs_fmtlsn(&(ilip->ili_flush_lsn)),
9442 @@ -3001,6 +4091,129 @@
9443         }
9444  }
9445  
9446 +#ifdef XFS_RW_TRACE
9447 +/*
9448 + * Print iomap entry trace.
9449 + */
9450 +static void
9451 +xfs_iomap_enter_trace_entry(ktrace_entry_t *ktep)
9452 +{
9453 +       qprintf("ip 0x%p size 0x%x%x offset 0x%x%x count 0x%x\n",
9454 +               ktep->val[1],
9455 +               (unsigned int)(long)ktep->val[2],
9456 +               (unsigned int)(long)ktep->val[3],
9457 +               (unsigned int)(long)ktep->val[4],
9458 +               (unsigned int)(long)ktep->val[5],
9459 +               (unsigned int)(long)ktep->val[6]);
9460 +       qprintf("next offset 0x%x%x io offset 0x%x%x\n",
9461 +               (unsigned int)(long)ktep->val[7],
9462 +               (unsigned int)(long)ktep->val[8],
9463 +               (unsigned int)(long)ktep->val[9],
9464 +               (unsigned int)(long)ktep->val[10]);
9465 +       qprintf("io size 0x%x last req sz 0x%x new size 0x%x%x\n",
9466 +               (unsigned int)(long)ktep->val[11],
9467 +               (unsigned int)(long)ktep->val[12],
9468 +               (unsigned int)(long)ktep->val[13],
9469 +               (unsigned int)(long)ktep->val[14]);
9470 +}
9471 +
9472 +/*
9473 + * Print iomap map trace.
9474 + */
9475 +static void
9476 +xfs_iomap_map_trace_entry(ktrace_entry_t *ktep)
9477 +{
9478 +       qprintf("ip 0x%p size 0x%x%x offset 0x%x%x count 0x%x\n",
9479 +               ktep->val[1],
9480 +               (unsigned int)(long)ktep->val[2],
9481 +               (unsigned int)(long)ktep->val[3],
9482 +               (unsigned int)(long)ktep->val[4],
9483 +               (unsigned int)(long)ktep->val[5],
9484 +               (unsigned int)(long)ktep->val[6]);
9485 +       qprintf("bmap off 0x%x%x len 0x%x pboff 0x%x pbsize 0x%x bno 0x%x\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 +               (unsigned int)(long)ktep->val[11],
9491 +               (unsigned int)(long)ktep->val[12]);
9492 +       qprintf("imap off 0x%x count 0x%x block 0x%x\n",
9493 +               (unsigned int)(long)ktep->val[13],
9494 +               (unsigned int)(long)ktep->val[14],
9495 +               (unsigned int)(long)ktep->val[15]);
9496 +}
9497 +
9498 +/*
9499 + * Print itrunc entry trace.
9500 + */
9501 +static void
9502 +xfs_itrunc_trace_entry(ktrace_entry_t   *ktep)
9503 +{
9504 +       qprintf("ip 0x%p size 0x%x%x flag %ld new size 0x%x%x\n",
9505 +               ktep->val[1],
9506 +               (unsigned int)(long)ktep->val[2],
9507 +               (unsigned int)(long)ktep->val[3],
9508 +               (long)ktep->val[4],
9509 +               (unsigned int)(long)ktep->val[5],
9510 +               (unsigned int)(long)ktep->val[6]);
9511 +       qprintf("toss start 0x%x%x toss finish 0x%x%x cpu id %ld\n",
9512 +               (unsigned int)(long)ktep->val[7],
9513 +               (unsigned int)(long)ktep->val[8],
9514 +               (unsigned int)(long)ktep->val[9],
9515 +               (unsigned int)(long)ktep->val[10],
9516 +               (long)ktep->val[11]);
9517 +}
9518 +
9519 +/*
9520 + * Print bunmap entry trace.
9521 + */
9522 +static void
9523 +xfs_bunmap_trace_entry(ktrace_entry_t   *ktep)
9524 +{
9525 +       static char *bunmapi_flags[] = {
9526 +               "write",        /* 0x01 */
9527 +               "delay",        /* 0x02 */
9528 +               "entire",       /* 0x04 */
9529 +               "metadata",     /* 0x08 */
9530 +               "exact",        /* 0x10 */
9531 +               "attrfork",     /* 0x20 */
9532 +               "async",        /* 0x40 */
9533 +               "rsvblocks",    /* 0x80 */
9534 +               0
9535 +       };
9536 +
9537 +       qprintf("ip 0x%p size 0x%x%x bno 0x%x%x len 0x%x cpu id %ld\n",
9538 +               ktep->val[1],
9539 +               (unsigned int)(long)ktep->val[2],
9540 +               (unsigned int)(long)ktep->val[3],
9541 +               (unsigned int)(long)ktep->val[4],
9542 +               (unsigned int)(long)ktep->val[5],
9543 +               (unsigned int)(long)ktep->val[6],
9544 +               (long)ktep->val[8]);
9545 +       qprintf("ra 0x%p ", ktep->val[9]);
9546 +       printflags((__psint_t)ktep->val[7], bunmapi_flags, "flags");
9547 +       qprintf("\n");
9548 +}
9549 +
9550 +/*
9551 + * Print inval_cached_pages entry trace.
9552 + */
9553 +static void
9554 +xfs_inval_cached_trace_entry(ktrace_entry_t     *ktep)
9555 +{
9556 +       qprintf("ip 0x%p offset 0x%x%x len 0x%x%x first 0x%x%x last 0x%x%x\n",
9557 +               ktep->val[1],
9558 +               (unsigned int)(long)ktep->val[2],
9559 +               (unsigned int)(long)ktep->val[3],
9560 +               (unsigned int)(long)ktep->val[4],
9561 +               (unsigned int)(long)ktep->val[5],
9562 +               (unsigned int)(long)ktep->val[6],
9563 +               (unsigned int)(long)ktep->val[7],
9564 +               (unsigned int)(long)ktep->val[8],
9565 +               (unsigned int)(long)ktep->val[9]);
9566 +}
9567 +#endif
9568 +
9569  
9570  /*
9571   * Print disk inode.
9572 @@ -3047,14 +4260,14 @@
9573                 INT_GET(dip->di_gid, convert),
9574                 (uint)INT_GET(dip->di_projid, convert),
9575                 (uint)INT_GET(dip->di_flushiter, convert));
9576 -       kdb_printf("atime 0x%x:%x mtime 0x%x:%x ctime 0x%x:%x\n",
9577 +       kdb_printf("atime %u:%u mtime %ud:%u ctime %u:%u\n",
9578                 INT_GET(dip->di_atime.t_sec, convert),
9579                 INT_GET(dip->di_atime.t_nsec, convert),
9580                 INT_GET(dip->di_mtime.t_sec, convert),
9581                 INT_GET(dip->di_mtime.t_nsec, convert),
9582                 INT_GET(dip->di_ctime.t_sec, convert),
9583                 INT_GET(dip->di_ctime.t_nsec, convert));
9584 -       kdb_printf("size 0x%Lx ", INT_GET(dip->di_size, convert));
9585 +       kdb_printf("size %Ld ", INT_GET(dip->di_size, convert));
9586         kdb_printf("nblocks %Ld extsize 0x%x nextents 0x%x anextents 0x%x\n",
9587                 INT_GET(dip->di_nblocks, convert),
9588                 INT_GET(dip->di_extsize, convert),
9589 @@ -3071,6 +4284,129 @@
9590         kdb_printf("gen 0x%x\n", INT_GET(dip->di_gen, convert));
9591  }
9592  
9593 +#ifdef XFS_RW_TRACE
9594 +/*
9595 + * Print read/write entry trace.
9596 + */
9597 +static void
9598 +xfs_rw_enter_trace_entry(ktrace_entry_t *ktep)
9599 +{
9600 +       qprintf("ip 0x%p size 0x%x%x uio offset 0x%x%x uio count 0x%x\n",
9601 +               ktep->val[1],
9602 +               (unsigned int)(long)ktep->val[2],
9603 +               (unsigned int)(long)ktep->val[3],
9604 +               (unsigned int)(long)ktep->val[4],
9605 +               (unsigned int)(long)ktep->val[5],
9606 +               (unsigned int)(long)ktep->val[6]);
9607 +       qprintf("ioflags 0x%x next offset 0x%x%x io offset 0x%x%x\n",
9608 +               (unsigned int)(long)ktep->val[7],
9609 +               (unsigned int)(long)ktep->val[8],
9610 +               (unsigned int)(long)ktep->val[9],
9611 +               (unsigned int)(long)ktep->val[10],
9612 +               (unsigned int)(long)ktep->val[11]);
9613 +       qprintf("io size 0x%x last req sz 0x%x new size 0x%x%x\n",
9614 +               (unsigned int)(long)ktep->val[12],
9615 +               (unsigned int)(long)ktep->val[13],
9616 +               (unsigned int)(long)ktep->val[14],
9617 +               (unsigned int)(long)ktep->val[15]);
9618 +}
9619 +
9620 +/*
9621 + * Print read/write trace entry.
9622 + */
9623 +static int
9624 +xfs_rw_trace_entry(ktrace_entry_t *ktep)
9625 +{
9626 +       switch ( (long)ktep->val[0] ) {
9627 +       case XFS_READ_ENTER:
9628 +               qprintf("READ ENTER:\n");
9629 +               xfs_rw_enter_trace_entry(ktep);
9630 +               break;
9631 +       case XFS_WRITE_ENTER:
9632 +               qprintf("WRITE ENTER:\n");
9633 +               xfs_rw_enter_trace_entry(ktep);
9634 +               break;
9635 +       case XFS_IOMAP_READ_ENTER:
9636 +               qprintf("IOMAP READ ENTER:\n");
9637 +               xfs_iomap_enter_trace_entry(ktep);
9638 +               break;
9639 +       case XFS_IOMAP_WRITE_ENTER:
9640 +               qprintf("IOMAP WRITE ENTER:\n");
9641 +               xfs_iomap_enter_trace_entry(ktep);
9642 +               break;
9643 +       case XFS_IOMAP_WRITE_NOSPACE:
9644 +               qprintf("IOMAP WRITE NOSPACE:\n");
9645 +               xfs_iomap_enter_trace_entry(ktep);
9646 +               break;
9647 +       case XFS_IOMAP_READ_MAP:
9648 +               qprintf("IOMAP READ MAP:\n");
9649 +               xfs_iomap_map_trace_entry(ktep);
9650 +               break;
9651 +       case XFS_IOMAP_WRITE_MAP:
9652 +               qprintf("IOMAP WRITE MAP:\n");
9653 +               xfs_iomap_map_trace_entry(ktep);
9654 +               break;
9655 +       case XFS_ITRUNC_START:
9656 +               qprintf("ITRUNC START:\n");
9657 +               xfs_itrunc_trace_entry(ktep);
9658 +               break;
9659 +       case XFS_ITRUNC_FINISH1:
9660 +               qprintf("ITRUNC FINISH1:\n");
9661 +               xfs_itrunc_trace_entry(ktep);
9662 +               break;
9663 +       case XFS_ITRUNC_FINISH2:
9664 +               qprintf("ITRUNC FINISH2:\n");
9665 +               xfs_itrunc_trace_entry(ktep);
9666 +               break;
9667 +       case XFS_CTRUNC1:
9668 +               qprintf("CTRUNC1:\n");
9669 +               xfs_ctrunc_trace_entry(ktep);
9670 +               break;
9671 +       case XFS_CTRUNC2:
9672 +               qprintf("CTRUNC2:\n");
9673 +               xfs_ctrunc_trace_entry(ktep);
9674 +               break;
9675 +       case XFS_CTRUNC3:
9676 +               qprintf("CTRUNC3:\n");
9677 +               xfs_ctrunc_trace_entry(ktep);
9678 +               break;
9679 +       case XFS_CTRUNC4:
9680 +               qprintf("CTRUNC4:\n");
9681 +               xfs_ctrunc_trace_entry(ktep);
9682 +               break;
9683 +       case XFS_CTRUNC5:
9684 +               qprintf("CTRUNC5:\n");
9685 +               xfs_ctrunc_trace_entry(ktep);
9686 +               break;
9687 +       case XFS_CTRUNC6:
9688 +               qprintf("CTRUNC6:\n");
9689 +               xfs_ctrunc_trace_entry(ktep);
9690 +               break;
9691 +       case XFS_BUNMAPI:
9692 +               qprintf("BUNMAPI:\n");
9693 +               xfs_bunmap_trace_entry(ktep);
9694 +               break;
9695 +       case XFS_INVAL_CACHED:
9696 +               qprintf("INVAL CACHED:\n");
9697 +               xfs_inval_cached_trace_entry(ktep);
9698 +               break;
9699 +       case XFS_DIORD_ENTER:
9700 +               qprintf("DIORD ENTER:\n");
9701 +               xfs_rw_enter_trace_entry(ktep);
9702 +               break;
9703 +       case XFS_DIOWR_ENTER:
9704 +               qprintf("DIOWR ENTER:\n");
9705 +               xfs_rw_enter_trace_entry(ktep);
9706 +               break;
9707 +
9708 +       default:
9709 +               return 0;
9710 +       }
9711 +
9712 +       return 1;
9713 +}
9714 +#endif
9715 +
9716  /*
9717   * Print xfs extent list for a fork.
9718   */
9719 @@ -3194,6 +4530,109 @@
9720         }
9721  }
9722  
9723 +#ifdef XFS_ALLOC_TRACE
9724 +/*
9725 + * Print out the last "count" entries in the allocation trace buffer.
9726 + */
9727 +static void
9728 +xfsidbg_xalatrace(int count)
9729 +{
9730 +       ktrace_entry_t  *ktep;
9731 +       ktrace_snap_t   kts;
9732 +       int          nentries;
9733 +       int          skip_entries;
9734 +
9735 +       if (xfs_alloc_trace_buf == NULL) {
9736 +               qprintf("The xfs alloc trace buffer is not initialized\n");
9737 +               return;
9738 +       }
9739 +       nentries = ktrace_nentries(xfs_alloc_trace_buf);
9740 +       if (count == -1) {
9741 +               count = nentries;
9742 +       }
9743 +       if ((count <= 0) || (count > nentries)) {
9744 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
9745 +               return;
9746 +       }
9747 +
9748 +       ktep = ktrace_first(xfs_alloc_trace_buf, &kts);
9749 +       if (count != nentries) {
9750 +               /*
9751 +                * Skip the total minus the number to look at minus one
9752 +                * for the entry returned by ktrace_first().
9753 +                */
9754 +               skip_entries = nentries - count - 1;
9755 +               ktep = ktrace_skip(xfs_alloc_trace_buf, skip_entries, &kts);
9756 +               if (ktep == NULL) {
9757 +                       qprintf("Skipped them all\n");
9758 +                       return;
9759 +               }
9760 +       }
9761 +       while (ktep != NULL) {
9762 +               if (xfs_alloc_trace_entry(ktep))
9763 +                       qprintf("\n");
9764 +               ktep = ktrace_next(xfs_alloc_trace_buf, &kts);
9765 +       }
9766 +}
9767 +
9768 +/*
9769 + * Print out all the entries in the alloc trace buf corresponding
9770 + * to the given block number.
9771 + */
9772 +static void
9773 +xfsidbg_xalbtrace(xfs_agblock_t bno)
9774 +{
9775 +       ktrace_entry_t  *ktep;
9776 +       ktrace_snap_t   kts;
9777 +
9778 +       if (xfs_alloc_trace_buf == NULL) {
9779 +               qprintf("The xfs alloc trace buffer is not initialized\n");
9780 +               return;
9781 +       }
9782 +
9783 +       ktep = ktrace_first(xfs_alloc_trace_buf, &kts);
9784 +       while (ktep != NULL) {
9785 +               switch ((__psint_t)ktep->val[0]) {
9786 +               case XFS_ALLOC_KTRACE_ALLOC:
9787 +               case XFS_ALLOC_KTRACE_FREE:
9788 +                       if (bno >= (xfs_agblock_t)((__psint_t)ktep->val[5]) &&
9789 +                           bno < (xfs_agblock_t)((__psint_t)ktep->val[5]) +
9790 +                                 (xfs_extlen_t)((__psint_t)ktep->val[13])) {
9791 +                               (void)xfs_alloc_trace_entry(ktep);
9792 +                               qprintf("\n");
9793 +                       }
9794 +                       break;
9795 +               }
9796 +               ktep = ktrace_next(xfs_alloc_trace_buf, &kts);
9797 +       }
9798 +}
9799 +
9800 +/*
9801 + * Print out all the entries in the alloc trace buf corresponding
9802 + * to the given allocation group.
9803 + */
9804 +static void
9805 +xfsidbg_xalgtrace(xfs_agnumber_t agno)
9806 +{
9807 +       ktrace_entry_t  *ktep;
9808 +       ktrace_snap_t   kts;
9809 +
9810 +       if (xfs_alloc_trace_buf == NULL) {
9811 +               qprintf("The xfs alloc trace buffer is not initialized\n");
9812 +               return;
9813 +       }
9814 +
9815 +       ktep = ktrace_first(xfs_alloc_trace_buf, &kts);
9816 +       while (ktep != NULL) {
9817 +               if (  (__psint_t)ktep->val[0] &&
9818 +                     ((xfs_agnumber_t)((__psint_t)ktep->val[4])) == agno ) {
9819 +                       (void)xfs_alloc_trace_entry(ktep);
9820 +                       qprintf("\n");
9821 +               }
9822 +               ktep = ktrace_next(xfs_alloc_trace_buf, &kts);
9823 +       }
9824 +}
9825 +#endif
9826  
9827  /*
9828   * Print an allocation argument structure for XFS.
9829 @@ -3215,7 +4654,7 @@
9830                 args->wasfromfl, args->isfl, args->userdata);
9831  }
9832  
9833 -#ifdef DEBUG
9834 +#ifdef XFS_ALLOC_TRACE
9835  /*
9836   * Print out all the entries in the alloc trace buf corresponding
9837   * to the given mount point.
9838 @@ -3225,7 +4664,6 @@
9839  {
9840         ktrace_entry_t  *ktep;
9841         ktrace_snap_t   kts;
9842 -       extern ktrace_t *xfs_alloc_trace_buf;
9843  
9844         if (xfs_alloc_trace_buf == NULL) {
9845                 kdb_printf("The xfs alloc trace buffer is not initialized\n");
9846 @@ -3234,14 +4672,53 @@
9847  
9848         ktep = ktrace_first(xfs_alloc_trace_buf, &kts);
9849         while (ktep != NULL) {
9850 -               if ((__psint_t)ktep->val[0] && (xfs_mount_t *)ktep->val[3] == mp) {
9851 +               if ((__psint_t)ktep->val[0] &&
9852 +                   (xfs_mount_t *)ktep->val[3] == mp) {
9853                         (void)xfs_alloc_trace_entry(ktep);
9854                         kdb_printf("\n");
9855                 }
9856                 ktep = ktrace_next(xfs_alloc_trace_buf, &kts);
9857         }
9858  }
9859 -#endif /* DEBUG */
9860 +
9861 +/*
9862 + * Print out all the entries in the alloc trace buf corresponding
9863 + * to the given entry type.
9864 + */
9865 +static void
9866 +xfsidbg_xalttrace(int tag)
9867 +{
9868 +       ktrace_entry_t  *ktep;
9869 +       ktrace_snap_t   kts;
9870 +
9871 +       if (xfs_alloc_trace_buf == NULL) {
9872 +               qprintf("The xfs alloc trace buffer is not initialized\n");
9873 +               return;
9874 +       }
9875 +
9876 +       ktep = ktrace_first(xfs_alloc_trace_buf, &kts);
9877 +       while (ktep != NULL) {
9878 +               if ((__psint_t)ktep->val[0] &&
9879 +                   ((long)ktep->val[0] & 0xffffL) == (long)tag) {
9880 +                       (void)xfs_alloc_trace_entry(ktep);
9881 +                       qprintf("\n");
9882 +               }
9883 +               ktep = ktrace_next(xfs_alloc_trace_buf, &kts);
9884 +       }
9885 +}
9886 +#endif
9887 +
9888 +/*
9889 + * Set xtra argument, used by xchksum.
9890 + */
9891 +static void
9892 +xfsidbg_xarg(int xarg)
9893 +{
9894 +       if (xarg == -1)
9895 +               qprintf("xargument: %d\n", xargument);
9896 +       else
9897 +               xargument = xarg;
9898 +}       /* xfsidbg_xarg */
9899  
9900  /*
9901   * Print an attr_list() context structure.
9902 @@ -3368,41 +4845,232 @@
9903         }
9904  }
9905  
9906 -
9907 +#ifdef XFS_ATTR_TRACE
9908 +/*
9909 + * Print out the last "count" entries in the attribute trace buffer.
9910 + */
9911 +static void
9912 +xfsidbg_xattrtrace(int count)
9913 +{
9914 +       ktrace_entry_t  *ktep;
9915 +       ktrace_snap_t   kts;
9916 +       int          nentries;
9917 +       int          skip_entries;
9918 +
9919 +       if (xfs_attr_trace_buf == NULL) {
9920 +               qprintf("The xfs attribute trace buffer is not initialized\n");
9921 +               return;
9922 +       }
9923 +       nentries = ktrace_nentries(xfs_attr_trace_buf);
9924 +       if (count == -1) {
9925 +               count = nentries;
9926 +       }
9927 +       if ((count <= 0) || (count > nentries)) {
9928 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
9929 +               return;
9930 +       }
9931 +
9932 +       ktep = ktrace_first(xfs_attr_trace_buf, &kts);
9933 +       if (count != nentries) {
9934 +               /*
9935 +                * Skip the total minus the number to look at minus one
9936 +                * for the entry returned by ktrace_first().
9937 +                */
9938 +               skip_entries = nentries - count - 1;
9939 +               ktep = ktrace_skip(xfs_attr_trace_buf, skip_entries, &kts);
9940 +               if (ktep == NULL) {
9941 +                       qprintf("Skipped them all\n");
9942 +                       return;
9943 +               }
9944 +       }
9945 +       while (ktep != NULL) {
9946 +               xfs_attr_trace_entry(ktep);
9947 +               ktep = ktrace_next(xfs_attr_trace_buf, &kts);
9948 +       }
9949 +}
9950 +#endif
9951 +
9952 +/*
9953 + * Print xfs bmap internal record
9954 + */
9955 +static void
9956 +xfsidbg_xbirec(xfs_bmbt_irec_t *r)
9957 +{
9958 +       kdb_printf(
9959 +       "startoff %Ld startblock %Lx blockcount %Ld state %Ld\n",
9960 +               (__uint64_t)r->br_startoff,
9961 +               (__uint64_t)r->br_startblock,
9962 +               (__uint64_t)r->br_blockcount,
9963 +               (__uint64_t)r->br_state);
9964 +}
9965 +
9966 +#ifdef XFS_BLI_TRACE
9967 +/*
9968 + * Print out the buf log item trace for the given buf log item.
9969 + */
9970 +static void
9971 +xfsidbg_xblitrace(xfs_buf_log_item_t *bip)
9972 +{
9973 +       ktrace_entry_t  *ktep;
9974 +       ktrace_snap_t   kts;
9975 +       uint64_t        flags;
9976 +       static char *xbli_flags[] = {
9977 +               "hold",         /* 0x01 */
9978 +               "dirty",        /* 0x02 */
9979 +               "stale",        /* 0x04 */
9980 +               "logged",       /* 0x08 */
9981 +               0
9982 +               };
9983 +       static char *xli_flags[] = {
9984 +               "in ail",       /* 0x1 */
9985 +               0
9986 +               };
9987 +
9988 +       if (bip->bli_trace == NULL) {
9989 +               qprintf("The bli trace buffer is not initialized\n");
9990 +               return;
9991 +       }
9992 +
9993 +       ktep = ktrace_first(bip->bli_trace, &kts);
9994 +       while (ktep != NULL) {
9995 +               qprintf("%s bp 0x%p flags ",
9996 +                       (char *)ktep->val[0], ktep->val[1]);
9997 +               printflags((__psint_t)(ktep->val[2]), xbli_flags, "xbli");
9998 +               qprintf("\n");
9999 +               qprintf("recur %ld refcount %ld blkno 0x%lx bcount 0x%lx\n",
10000 +                       (long)ktep->val[3], (long)ktep->val[4],
10001 +                       (unsigned long)ktep->val[5],
10002 +                       (unsigned long)ktep->val[6]);
10003 +               flags = (((uint64_t)(unsigned long)ktep->val[7] << 32) &
10004 +                                       0xFFFFFFFF00000000ULL) |
10005 +                       (((uint64_t)(unsigned long)ktep->val[8]) &
10006 +                                       0x00000000FFFFFFFFULL);
10007 +               qprintf("bp flags ");
10008 +               printflags(flags, pb_flag_vals, 0);
10009 +               qprintf("\n");
10010 +               qprintf("fspriv 0x%p fspriv2 0x%p pincount %ld iodone 0x%p\n",
10011 +                       ktep->val[9], ktep->val[10],
10012 +                       (long)ktep->val[11], ktep->val[12]);
10013 +               qprintf("lockval %ld lid 0x%lx log item flags ",
10014 +                       (long)ktep->val[13], (unsigned long)ktep->val[14]);
10015 +               printflags((__psint_t)(ktep->val[15]), xli_flags, "xli");
10016 +               qprintf("\n");
10017 +
10018 +               ktep = ktrace_next(bip->bli_trace, &kts);
10019 +       }
10020 +}
10021 +#endif
10022 +
10023 +/*
10024 + * Print a bmap alloc argument structure for XFS.
10025 + */
10026 +static void
10027 +xfsidbg_xbmalla(xfs_bmalloca_t *a)
10028 +{
10029 +       kdb_printf("tp 0x%p ip 0x%p eof %d prevp 0x%p\n",
10030 +               a->tp, a->ip, a->eof, a->prevp);
10031 +       kdb_printf("gotp 0x%p firstblock %s alen %d total %d\n",
10032 +               a->gotp, xfs_fmtfsblock(a->firstblock, a->ip->i_mount),
10033 +               a->alen, a->total);
10034 +       kdb_printf("off %s wasdel %d userdata %d minlen %d\n",
10035 +               xfs_fmtfsblock(a->off, a->ip->i_mount), a->wasdel,
10036 +               a->userdata, a->minlen);
10037 +       kdb_printf("minleft %d low %d rval %s aeof %d\n",
10038 +               a->minleft, a->low, xfs_fmtfsblock(a->rval, a->ip->i_mount),
10039 +               a->aeof);
10040 +}
10041 +
10042 +#ifdef XFS_BMAP_TRACE
10043 +/*
10044 + * Print out the last "count" entries in the bmap btree trace buffer.
10045 + * The "a" is for "all" inodes.
10046 + */
10047 +static void
10048 +xfsidbg_xbmatrace(int count)
10049 +{
10050 +       ktrace_entry_t  *ktep;
10051 +       ktrace_snap_t   kts;
10052 +       int          nentries;
10053 +       int          skip_entries;
10054 +
10055 +       if (xfs_bmbt_trace_buf == NULL) {
10056 +               qprintf("The xfs bmap btree trace buffer is not initialized\n");                return;
10057 +       }
10058 +       nentries = ktrace_nentries(xfs_bmbt_trace_buf);
10059 +       if (count == -1) {
10060 +               count = nentries;
10061 +       }
10062 +       if ((count <= 0) || (count > nentries)) {
10063 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
10064 +               return;
10065 +       }
10066 +
10067 +       ktep = ktrace_first(xfs_bmbt_trace_buf, &kts);
10068 +       if (count != nentries) {
10069 +               /*
10070 +                * Skip the total minus the number to look at minus one
10071 +                * for the entry returned by ktrace_first().
10072 +                */
10073 +               skip_entries = nentries - count - 1;
10074 +               ktep = ktrace_skip(xfs_bmbt_trace_buf, skip_entries, &kts);
10075 +               if (ktep == NULL) {
10076 +                       qprintf("Skipped them all\n");
10077 +                       return;
10078 +               }
10079 +       }
10080 +       while (ktep != NULL) {
10081 +               if (xfs_bmbt_trace_entry(ktep))
10082 +                       qprintf("\n");
10083 +               ktep = ktrace_next(xfs_bmbt_trace_buf, &kts);
10084 +       }
10085 +}
10086 +
10087  /*
10088 - * Print xfs bmap internal record
10089 + * Print out the bmap btree trace buffer attached to the given inode.
10090   */
10091  static void
10092 -xfsidbg_xbirec(xfs_bmbt_irec_t *r)
10093 +xfsidbg_xbmitrace(xfs_inode_t *ip)
10094  {
10095 -       kdb_printf(
10096 -       "startoff %Ld startblock %Lx blockcount %Ld state %Ld\n",
10097 -               (__uint64_t)r->br_startoff,
10098 -               (__uint64_t)r->br_startblock,
10099 -               (__uint64_t)r->br_blockcount,
10100 -               (__uint64_t)r->br_state);
10101 -}
10102 +       ktrace_entry_t  *ktep;
10103 +       ktrace_snap_t   kts;
10104  
10105 +       if (ip->i_btrace == NULL) {
10106 +               qprintf("The inode trace buffer is not initialized\n");
10107 +               return;
10108 +       }
10109 +
10110 +       ktep = ktrace_first(ip->i_btrace, &kts);
10111 +       while (ktep != NULL) {
10112 +               if (xfs_bmbt_trace_entry(ktep))
10113 +                       qprintf("\n");
10114 +               ktep = ktrace_next(ip->i_btrace, &kts);
10115 +       }
10116 +}
10117  
10118  /*
10119 - * Print a bmap alloc argument structure for XFS.
10120 + * Print out all the entries in the bmap btree trace buf corresponding
10121 + * to the given inode.  The "s" is for "single" inode.
10122   */
10123  static void
10124 -xfsidbg_xbmalla(xfs_bmalloca_t *a)
10125 +xfsidbg_xbmstrace(xfs_inode_t *ip)
10126  {
10127 -       kdb_printf("tp 0x%p ip 0x%p eof %d prevp 0x%p\n",
10128 -               a->tp, a->ip, a->eof, a->prevp);
10129 -       kdb_printf("gotp 0x%p firstblock %s alen %d total %d\n",
10130 -               a->gotp, xfs_fmtfsblock(a->firstblock, a->ip->i_mount),
10131 -               a->alen, a->total);
10132 -       kdb_printf("off %s wasdel %d userdata %d minlen %d\n",
10133 -               xfs_fmtfsblock(a->off, a->ip->i_mount), a->wasdel,
10134 -               a->userdata, a->minlen);
10135 -       kdb_printf("minleft %d low %d rval %s aeof %d\n",
10136 -               a->minleft, a->low, xfs_fmtfsblock(a->rval, a->ip->i_mount),
10137 -               a->aeof);
10138 -}
10139 +       ktrace_entry_t  *ktep;
10140 +       ktrace_snap_t   kts;
10141  
10142 +       if (xfs_bmbt_trace_buf == NULL) {
10143 +               qprintf("The xfs bmap btree trace buffer is not initialized\n");                return;
10144 +       }
10145 +
10146 +       ktep = ktrace_first(xfs_bmbt_trace_buf, &kts);
10147 +       while (ktep != NULL) {
10148 +               if ((xfs_inode_t *)(ktep->val[2]) == ip) {
10149 +                       if (xfs_bmbt_trace_entry(ktep))
10150 +                               qprintf("\n");
10151 +               }
10152 +               ktep = ktrace_next(xfs_bmbt_trace_buf, &kts);
10153 +       }
10154 +}
10155 +#endif
10156  
10157  /*
10158   * Print xfs bmap record
10159 @@ -3667,6 +5335,286 @@
10160         }
10161  }
10162  
10163 +#ifdef XFS_BMAP_TRACE
10164 +/*
10165 + * Print out the last "count" entries in the bmap extent trace buffer.
10166 + * The "a" is for "all" inodes.
10167 + */
10168 +static void
10169 +xfsidbg_xbxatrace(int count)
10170 +{
10171 +       ktrace_entry_t  *ktep;
10172 +       ktrace_snap_t   kts;
10173 +       int          nentries;
10174 +       int          skip_entries;
10175 +
10176 +       if (xfs_bmap_trace_buf == NULL) {
10177 +               qprintf("The xfs bmap extent trace buffer is not initialized\n");
10178 +               return;
10179 +       }
10180 +       nentries = ktrace_nentries(xfs_bmap_trace_buf);
10181 +       if (count == -1) {
10182 +               count = nentries;
10183 +       }
10184 +       if ((count <= 0) || (count > nentries)) {
10185 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
10186 +               return;
10187 +       }
10188 +
10189 +       ktep = ktrace_first(xfs_bmap_trace_buf, &kts);
10190 +       if (count != nentries) {
10191 +               /*
10192 +                * Skip the total minus the number to look at minus one
10193 +                * for the entry returned by ktrace_first().
10194 +                */
10195 +               skip_entries = nentries - count - 1;
10196 +               ktep = ktrace_skip(xfs_bmap_trace_buf, skip_entries, &kts);
10197 +               if (ktep == NULL) {
10198 +                       qprintf("Skipped them all\n");
10199 +                       return;
10200 +               }
10201 +       }
10202 +       while (ktep != NULL) {
10203 +               if (xfs_bmap_trace_entry(ktep))
10204 +                       qprintf("\n");
10205 +               ktep = ktrace_next(xfs_bmap_trace_buf, &kts);
10206 +       }
10207 +}
10208 +
10209 +/*
10210 + * Print out the bmap extent trace buffer attached to the given inode.
10211 + */
10212 +static void
10213 +xfsidbg_xbxitrace(xfs_inode_t *ip)
10214 +{
10215 +       ktrace_entry_t  *ktep;
10216 +       ktrace_snap_t   kts;
10217 +       if (ip->i_xtrace == NULL) {
10218 +               qprintf("The inode trace buffer is not initialized\n");
10219 +               return;
10220 +       }
10221 +
10222 +       ktep = ktrace_first(ip->i_xtrace, &kts);
10223 +       while (ktep != NULL) {
10224 +               if (xfs_bmap_trace_entry(ktep))
10225 +                       qprintf("\n");
10226 +               ktep = ktrace_next(ip->i_xtrace, &kts);
10227 +       }
10228 +}
10229 +
10230 +/*
10231 + * Print out all the entries in the bmap extent trace buf corresponding
10232 + * to the given inode.  The "s" is for "single" inode.
10233 + */
10234 +static void
10235 +xfsidbg_xbxstrace(xfs_inode_t *ip)
10236 +{
10237 +       ktrace_entry_t  *ktep;
10238 +       ktrace_snap_t   kts;
10239 +
10240 +       if (xfs_bmap_trace_buf == NULL) {
10241 +               qprintf("The xfs bmap extent trace buffer is not initialized\n");
10242 +               return;
10243 +       }
10244 +
10245 +       ktep = ktrace_first(xfs_bmap_trace_buf, &kts);
10246 +       while (ktep != NULL) {
10247 +               if ((xfs_inode_t *)(ktep->val[3]) == ip) {
10248 +                       if (xfs_bmap_trace_entry(ktep))
10249 +                               qprintf("\n");
10250 +               }
10251 +               ktep = ktrace_next(xfs_bmap_trace_buf, &kts);
10252 +       }
10253 +}
10254 +#endif
10255 +
10256 +#ifdef XFS_ILOCK_TRACE
10257 +/*
10258 + * Print out the ilock trace buffer attached to the given inode.
10259 + */
10260 +static void
10261 +xfsidbg_xilock_trace_entry(ktrace_entry_t *ktep)
10262 +{
10263 +       static char     *xiflags[] = {
10264 +               "IOLOCK_EXCL",
10265 +               "IOLOCK_SHAR",
10266 +               "ILOCK_EXCL",
10267 +               "ILOCK_SHAR",
10268 +               "IUNLK_NONOT",
10269 +               0
10270 +       };
10271 +
10272 +       if ((__psint_t)ktep->val[0] &&
10273 +            (__psint_t)ktep->val[7] == 0) {
10274 +                printflags((__psint_t)ktep->val[2], xiflags,"Flags ");
10275 +               if ((__psint_t)ktep->val[1] == 1)
10276 +                        qprintf("LOCK\n");
10277 +               else if ((__psint_t)ktep->val[1] == 2)
10278 +                        qprintf("LOCK SHARED\n");
10279 +               else if ((__psint_t)ktep->val[1] == 3)
10280 +                        qprintf("UNLOCK\n");
10281 +               qprintf("ip 0x%p %llx %ld\n",
10282 +                       ktep->val[0],
10283 +                       (unsigned long long)((xfs_inode_t*)ktep->val[0])->i_ino,
10284 +                       (long)ktep->val[6]);
10285 +               qprintf("raddr 0x%p\n", ktep->val[3]);
10286 +               qprintf("  Pid %ld, cpu %ld\n",
10287 +                        (long)ktep->val[5],
10288 +                        (long)ktep->val[4]);
10289 +               qprintf("-----------------------\n");
10290 +
10291 +       } else if ((__psint_t)ktep->val[7] == 1) {
10292 +               if ((__psint_t)ktep->val[1] == 1)
10293 +                       qprintf("FlushLOCK ");
10294 +               else if ((__psint_t)ktep->val[1] == 2)
10295 +                       qprintf("FlushTRYLOCK %ld ",
10296 +                               (long)ktep->val[2]);
10297 +               else if ((__psint_t)ktep->val[1] == 3)
10298 +                       qprintf("FlushUNLOCK ");
10299 +               else if ((__psint_t)ktep->val[1] == 4)
10300 +                       qprintf("FlushInode 0x%p",
10301 +                               ktep->val[2]);
10302 +               else if ((__psint_t)ktep->val[1] == 5)
10303 +                       qprintf("FlushInodeInt ");
10304 +               else     qprintf("FlushUNKNOWN ");
10305 +               qprintf("ip 0x%p ino %llx @ %ld\n",
10306 +                       ktep->val[0],
10307 +                       (unsigned long long)((xfs_inode_t*)ktep->val[0])->i_ino,
10308 +                       (long)ktep->val[6]);
10309 +               qprintf("raddr 0x%p\n", ktep->val[3]);
10310 +               qprintf("  Pid %ld, cpu %ld\n",
10311 +                       (long)ktep->val[5],
10312 +                       (long)ktep->val[4]);
10313 +               qprintf("-----------------------\n");
10314 +       }
10315 +}
10316 +
10317 +static void
10318 +xfsidbg_xilock_trace(xfs_inode_t *ip)
10319 +{
10320 +       static char *xiflags[] = {
10321 +               "IOLOCK_EXCL",
10322 +               "IOLOCK_SHAR",
10323 +               "ILOCK_EXCL",
10324 +               "ILOCK_SHAR",
10325 +               "IUNLK_NONOT",
10326 +               0
10327 +       };
10328 +
10329 +       ktrace_entry_t  *ktep;
10330 +       ktrace_snap_t   kts;
10331 +       if (ip->i_lock_trace == NULL) {
10332 +               qprintf("The inode ilock trace buffer is not initialized\n");
10333 +               return;
10334 +       }
10335 +
10336 +       ktep = ktrace_first(ip->i_lock_trace, &kts);
10337 +       while (ktep != NULL) {
10338 +                if ((__psint_t)ktep->val[0] &&
10339 +                    (__psint_t)ktep->val[7] == 0) {
10340 +                        printflags((__psint_t)ktep->val[2], xiflags,"Flags ");
10341 +                        if ((__psint_t)ktep->val[1] == 1)
10342 +                                qprintf("LOCK\n");
10343 +                        else if ((__psint_t)ktep->val[1] == 2)
10344 +                                qprintf("LOCK SHARED\n");
10345 +                        else if ((__psint_t)ktep->val[1] == 3)
10346 +                                qprintf("UNLOCK\n");
10347 +                       qprintf("ip 0x%p %lld %ld\n",
10348 +                               ktep->val[0], (unsigned long long)
10349 +                               ((xfs_inode_t*)ktep->val[0])->i_ino,
10350 +                               (long)ktep->val[6]);
10351 +                        qprintf("raddr 0x%p\n", ktep->val[3]);
10352 +                        qprintf("  Pid %ld, cpu %ld\n",
10353 +                                (long)ktep->val[5],
10354 +                                (long)ktep->val[4]);
10355 +                        qprintf("-----------------------\n");
10356 +                } else if ((__psint_t)ktep->val[7] == 1) {
10357 +                       if ((__psint_t)ktep->val[1] == 1)
10358 +                               qprintf("LOCK ");
10359 +                       else if ((__psint_t)ktep->val[1] == 2)
10360 +                               qprintf("TRYLOCK %ld ",
10361 +                                       (long)ktep->val[2]);
10362 +                       else if ((__psint_t)ktep->val[1] == 3)
10363 +                               qprintf("UNLOCK ");
10364 +                       else     qprintf("UNKNOWN ");
10365 +                       qprintf("ip 0x%p %lld %ld\n",
10366 +                               ktep->val[0], (unsigned long long)
10367 +                               ((xfs_inode_t*)ktep->val[0])->i_ino,
10368 +                               (long)ktep->val[6]);
10369 +                       qprintf("raddr 0x%p\n", ktep->val[3]);
10370 +                       qprintf("  Pid %ld, cpu %ld\n",
10371 +                               (long)ktep->val[5],
10372 +                               (long)ktep->val[4]);
10373 +                       qprintf("-----------------------\n");
10374 +                }
10375 +
10376 +                ktep = ktrace_next(ip->i_lock_trace, &kts);
10377 +       }
10378 +}
10379 +
10380 +/*
10381 + * Print out the last "count" entries in the inode lock trace buffer.
10382 + * The "a" is for "all" entries.
10383 + */
10384 +static void
10385 +xfsidbg_xailock_trace(int count)
10386 +{
10387 +       ktrace_entry_t  *ktep;
10388 +       ktrace_snap_t   kts;
10389 +       int          nentries;
10390 +       int          skip_entries;
10391 +
10392 +       if (xfs_ilock_trace_buf == NULL) {
10393 +               qprintf("The xfs inode lock trace buffer is not initialized\n");                return;
10394 +       }
10395 +       nentries = ktrace_nentries(xfs_ilock_trace_buf);
10396 +       if (count == -1) {
10397 +               count = nentries;
10398 +       }
10399 +       if ((count <= 0) || (count > nentries)) {
10400 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
10401 +               return;
10402 +       }
10403 +
10404 +       ktep = ktrace_first(xfs_ilock_trace_buf, &kts);
10405 +       if (count != nentries) {
10406 +               /*
10407 +                * Skip the total minus the number to look at minus one
10408 +                * for the entry returned by ktrace_first().
10409 +                */
10410 +               skip_entries = nentries - count - 1;
10411 +               ktep = ktrace_skip(xfs_ilock_trace_buf, skip_entries, &kts);
10412 +               if (ktep == NULL) {
10413 +                       qprintf("Skipped them all\n");
10414 +                       return;
10415 +               }
10416 +       }
10417 +       while (ktep != NULL) {
10418 +               xfsidbg_xilock_trace_entry(ktep);
10419 +               ktep = ktrace_next(xfs_ilock_trace_buf, &kts);
10420 +       }
10421 +}
10422 +#endif
10423 +
10424 +/*
10425 + * Compute & print buffer's checksum.
10426 + */
10427 +static void
10428 +xfsidbg_xchksum(uint *addr)
10429 +{
10430 +       uint i, chksum = 0;
10431 +
10432 +       if (((__psint_t)addr) == ((__psint_t)-1)) {
10433 +               qprintf("USAGE xchksum <address>\n");
10434 +               qprintf("       length is set with xarg\n");
10435 +       } else {
10436 +               for (i=0; i<xargument; i++) {
10437 +                       chksum ^= *addr;
10438 +                       addr++;
10439 +               }
10440 +               qprintf("chksum (0x%x)  length (%d)\n", chksum, xargument);
10441 +       }
10442 +}       /* xfsidbg_xchksum */
10443  
10444  /*
10445   * Print an xfs_da_args structure.
10446 @@ -3740,9 +5688,8 @@
10447                 kdb_printf(" %d:0x%p", i, dabuf->bps[i]);
10448         kdb_printf("\n");
10449  #ifdef XFS_DABUF_DEBUG
10450 -       kdb_printf(" ra 0x%x prev 0x%x next 0x%x dev %s blkno 0x%x\n",
10451 -               dabuf->ra, dabuf->prev, dabuf->next,
10452 -               XFS_BUFTARG_NAME(dabuf->dev), dabuf->blkno);
10453 +       kdb_printf(" ra 0x%x prev 0x%x next 0x%x dev 0x%x blkno 0x%x\n",
10454 +               dabuf->ra, dabuf->prev, dabuf->next, dabuf->dev, dabuf->blkno);
10455  #endif
10456  }
10457  
10458 @@ -4012,6 +5959,119 @@
10459         }
10460  }
10461  
10462 +#ifdef XFS_DIR_TRACE
10463 +/*
10464 + * Print out the last "count" entries in the directory trace buffer.
10465 + */
10466 +static void
10467 +xfsidbg_xdirtrace(int count)
10468 +{
10469 +       ktrace_entry_t  *ktep;
10470 +       ktrace_snap_t   kts;
10471 +       int          nentries;
10472 +       int          skip_entries;
10473 +
10474 +       if (xfs_dir_trace_buf == NULL) {
10475 +               qprintf("The xfs directory trace buffer is not initialized\n");
10476 +               return;
10477 +       }
10478 +       nentries = ktrace_nentries(xfs_dir_trace_buf);
10479 +       if (count == -1) {
10480 +               count = nentries;
10481 +       }
10482 +       if ((count <= 0) || (count > nentries)) {
10483 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
10484 +               return;
10485 +       }
10486 +
10487 +       ktep = ktrace_first(xfs_dir_trace_buf, &kts);
10488 +       if (count != nentries) {
10489 +               /*
10490 +                * Skip the total minus the number to look at minus one
10491 +                * for the entry returned by ktrace_first().
10492 +                */
10493 +               skip_entries = nentries - count - 1;
10494 +               ktep = ktrace_skip(xfs_dir_trace_buf, skip_entries, &kts);
10495 +               if (ktep == NULL) {
10496 +                       qprintf("Skipped them all\n");
10497 +                       return;
10498 +               }
10499 +       }
10500 +       while (ktep != NULL) {
10501 +               if (xfs_dir_trace_entry(ktep))
10502 +                       qprintf("\n");
10503 +               ktep = ktrace_next(xfs_dir_trace_buf, &kts);
10504 +       }
10505 +}
10506 +#endif
10507 +
10508 +#ifdef XFS_DIR2_TRACE
10509 +/*
10510 + * Print out the last "count" entries in the directory v2 trace buffer.
10511 + */
10512 +static void
10513 +xfsidbg_xdir2atrace(int count)
10514 +{
10515 +       ktrace_entry_t  *ktep;
10516 +       ktrace_snap_t   kts;
10517 +       int          nentries;
10518 +       int          skip_entries;
10519 +
10520 +       if (xfs_dir2_trace_buf == NULL) {
10521 +               qprintf("The xfs dirv2 trace buffer is not initialized\n");
10522 +               return;
10523 +       }
10524 +       nentries = ktrace_nentries(xfs_dir2_trace_buf);
10525 +       if (count == -1) {
10526 +               count = nentries;
10527 +       }
10528 +       if ((count <= 0) || (count > nentries)) {
10529 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
10530 +               return;
10531 +       }
10532 +
10533 +       ktep = ktrace_first(xfs_dir2_trace_buf, &kts);
10534 +       if (count != nentries) {
10535 +               /*
10536 +                * Skip the total minus the number to look at minus one
10537 +                * for the entry returned by ktrace_first().
10538 +                */
10539 +               skip_entries = nentries - count - 1;
10540 +               ktep = ktrace_skip(xfs_dir2_trace_buf, skip_entries, &kts);
10541 +               if (ktep == NULL) {
10542 +                       qprintf("Skipped them all\n");
10543 +                       return;
10544 +               }
10545 +       }
10546 +       while (ktep != NULL) {
10547 +               if (xfs_dir2_trace_entry(ktep))
10548 +                       qprintf("\n");
10549 +               ktep = ktrace_next(xfs_dir2_trace_buf, &kts);
10550 +       }
10551 +}
10552 +
10553 +/*
10554 + * Print out the directory v2 trace buffer attached to the given inode.
10555 + */
10556 +static void
10557 +xfsidbg_xdir2itrace(xfs_inode_t *ip)
10558 +{
10559 +       ktrace_entry_t  *ktep;
10560 +       ktrace_snap_t   kts;
10561 +
10562 +       if (ip->i_dir_trace == NULL) {
10563 +               qprintf("The inode trace buffer is not initialized\n");
10564 +               return;
10565 +       }
10566 +
10567 +       ktep = ktrace_first(ip->i_dir_trace, &kts);
10568 +       while (ktep != NULL) {
10569 +               if (xfs_dir2_trace_entry(ktep))
10570 +                       qprintf("\n");
10571 +               ktep = ktrace_next(ip->i_dir_trace, &kts);
10572 +       }
10573 +}
10574 +#endif
10575  
10576  /*
10577   * Print xfs extent list.
10578 @@ -4095,13 +6155,18 @@
10579         kdb_printf("log: 0x%p  callb: 0x%p  callb_tail: 0x%p  roundoff: %d\n",
10580                 iclog->ic_log, iclog->ic_callback, iclog->ic_callback_tail,
10581                 iclog->ic_roundoff);
10582 -       kdb_printf("size: %d (OFFSET: %d) refcnt: %d  bwritecnt: %d",
10583 +       kdb_printf("size: %d (OFFSET: %d) trace: 0x%p refcnt: %d bwritecnt: %d",
10584                 iclog->ic_size, iclog->ic_offset,
10585 +#ifdef XFS_LOG_TRACE
10586 +               iclog->ic_trace,
10587 +#else
10588 +               NULL,
10589 +#endif
10590                 iclog->ic_refcnt, iclog->ic_bwritecnt);
10591         if (iclog->ic_state & XLOG_STATE_ALL)
10592 -               printflags(iclog->ic_state, ic_flags, "state:");
10593 +               printflags(iclog->ic_state, ic_flags, " state:");
10594         else
10595 -               kdb_printf("state: INVALID 0x%x", iclog->ic_state);
10596 +               kdb_printf(" state: INVALID 0x%x", iclog->ic_state);
10597         kdb_printf("\n");
10598  }      /* xfsidbg_xiclog */
10599  
10600 @@ -4150,6 +6215,44 @@
10601         }
10602  }
10603  
10604 +#ifdef XFS_LOG_TRACE
10605 +/*
10606 + * Print trace from incore log.
10607 + */
10608 +static void
10609 +xfsidbg_xiclogtrace(xlog_in_core_t *iclog)
10610 +{
10611 +       ktrace_entry_t  *ktep;
10612 +       ktrace_snap_t   kts;
10613 +       ktrace_t        *kt = iclog->ic_trace;
10614 +
10615 +       qprintf("iclog->ic_trace 0x%p\n", kt);
10616 +       ktep = ktrace_first(kt, &kts);
10617 +       while (ktep != NULL) {
10618 +               switch ((__psint_t)ktep->val[0]) {
10619 +                   case XLOG_TRACE_GRAB_FLUSH: {
10620 +                           qprintf("grabbing semaphore\n");
10621 +                           break;
10622 +                   }
10623 +                   case XLOG_TRACE_REL_FLUSH: {
10624 +                           qprintf("releasing semaphore\n");
10625 +                           break;
10626 +                   }
10627 +                   case XLOG_TRACE_SLEEP_FLUSH: {
10628 +                           qprintf("sleeping on semaphore\n");
10629 +                           break;
10630 +                   }
10631 +                   case XLOG_TRACE_WAKE_FLUSH: {
10632 +                           qprintf("waking up on semaphore\n");
10633 +                           break;
10634 +                   }
10635 +                   default: {
10636 +                   }
10637 +               }
10638 +               ktep = ktrace_next(kt, &kts);
10639 +       }
10640 +}       /* xfsidbg_xiclogtrace */
10641 +#endif
10642  
10643  /*
10644   * Print all of the inodes attached to the given mount structure.
10645 @@ -4270,8 +6373,8 @@
10646                         xfsidbg_get_cstate(log->l_covered_state));
10647         kdb_printf("flags: ");
10648         printflags(log->l_flags, t_flags,"log");
10649 -       kdb_printf("  dev: %s logBBstart: %lld logsize: %d logBBsize: %d\n",
10650 -               XFS_BUFTARG_NAME(log->l_targ), (long long) log->l_logBBstart,
10651 +       kdb_printf("  logBBstart: %lld logsize: %d logBBsize: %d\n",
10652 +               (long long) log->l_logBBstart,
10653                 log->l_logsize,log->l_logBBsize);
10654         kdb_printf("curr_cycle: %d  prev_cycle: %d  curr_block: %d  prev_block: %d\n",
10655              log->l_curr_cycle, log->l_prev_cycle, log->l_curr_block,
10656 @@ -4290,11 +6393,50 @@
10657                 log->l_grant_write_cycle, log->l_grant_write_bytes);
10658         rbytes = log->l_grant_reserve_bytes + log->l_roundoff;
10659         wbytes = log->l_grant_write_bytes + log->l_roundoff;
10660 -       kdb_printf("GResBlocks: %d  GResRemain: %d  GWrBlocks: %d  GWrRemain: %d\n",
10661 +       qprintf("GResBlocks: %d GResRemain: %d  GWrBlocks: %d GWrRemain: %d\n",
10662                rbytes / BBSIZE, rbytes % BBSIZE,
10663                wbytes / BBSIZE, wbytes % BBSIZE);
10664 +#ifdef XFS_LOG_TRACE
10665 +       qprintf("trace: 0x%p  grant_trace: use xlog value\n", log->l_trace);
10666 +#endif
10667  }      /* xfsidbg_xlog */
10668  
10669 +#ifdef XFS_LOG_TRACE
10670 +/*
10671 + * Print grant trace for a log.
10672 + */
10673 +static void
10674 +xfsidbg_xlog_granttrace(xlog_t *log)
10675 +{
10676 +       ktrace_entry_t  *ktep;
10677 +       ktrace_snap_t   kts;
10678 +       ktrace_t        *kt;
10679 +
10680 +       if (((__psint_t)log) == ((__psint_t)-1)) {
10681 +               qprintf("Usage: xl_grtr <log>\n");
10682 +               return;
10683 +       }
10684 +       if ((kt = log->l_grant_trace))
10685 +               qprintf("log->l_grant_trace 0x%p\n", kt);
10686 +       else {
10687 +               qprintf("log->l_grant_trace is empty!\n");
10688 +               return;
10689 +       }
10690 +       ktep = ktrace_first(kt, &kts);
10691 +       while (ktep != NULL) {
10692 +               qprintf("%s\n", (char *)ktep->val[11]);
10693 +               qprintf("  tic:0x%p resQ:0x%p wrQ:0x%p ",
10694 +                       ktep->val[0], ktep->val[1], ktep->val[2]);
10695 +               qprintf("  GrResC:%ld GrResB:%ld GrWrC:%ld GrWrB:%ld \n",
10696 +                       (long)ktep->val[3], (long)ktep->val[4],
10697 +                       (long)ktep->val[5], (long)ktep->val[6]);
10698 +               qprintf("  HeadC:%ld HeadB:%ld TailC:%ld TailB:%ld\n",
10699 +                       (long)ktep->val[7], (long)ktep->val[8],
10700 +                       (long)ktep->val[9], (long)ktep->val[10]);
10701 +               ktep = ktrace_next(kt, &kts);
10702 +       }
10703 +}       /* xfsidbg_xlog_granttrace */
10704 +#endif
10705  
10706  /*
10707   * Print out an XFS recovery transaction
10708 @@ -4488,10 +6630,10 @@
10709                 lip->li_mountp);
10710         printflags((uint)(lip->li_flags), li_flags,"log");
10711         kdb_printf("\n");
10712 -       kdb_printf("ail forw 0x%p ail back 0x%p lsn %s desc %p ops 0x%p\n",
10713 +       kdb_printf("ail forw 0x%p ail back 0x%p lsn %s\ndesc %p ops 0x%p",
10714                 lip->li_ail.ail_forw, lip->li_ail.ail_back,
10715                 xfs_fmtlsn(&(lip->li_lsn)), lip->li_desc, lip->li_ops);
10716 -       kdb_printf("iodonefunc &0x%p\n", lip->li_cb);
10717 +       kdb_printf(" iodonefunc &0x%p\n", lip->li_cb);
10718         if (lip->li_type == XFS_LI_BUF) {
10719                 bio_lip = lip->li_bio_list;
10720                 if (bio_lip != NULL) {
10721 @@ -4547,7 +6689,7 @@
10722                 "6-1-buf",      /* 7 */
10723                 "inode",        /* 8 */
10724                 "buf",          /* 9 */
10725 -               "dquot",        /* 10 */
10726 +               "dquot",        /* 10 */
10727                 0
10728                 };
10729         static char *li_flags[] = {
10730 @@ -4609,7 +6751,7 @@
10731         static char *xmount_flags[] = {
10732                 "WSYNC",        /* 0x0001 */
10733                 "INO64",        /* 0x0002 */
10734 -               "RQCHK",        /* 0x0004 */
10735 +               "RQCHK",        /* 0x0004 */
10736                 "FSCLEAN",      /* 0x0008 */
10737                 "FSSHUTDN",     /* 0x0010 */
10738                 "NOATIME",      /* 0x0020 */
10739 @@ -4646,14 +6788,11 @@
10740                 XFS_MTOVFS(mp), mp->m_tid, &mp->m_ail_lock, &mp->m_ail);
10741         kdb_printf("ail_gen 0x%x &sb 0x%p\n",
10742                 mp->m_ail_gen, &mp->m_sb);
10743 -       kdb_printf("sb_lock 0x%p sb_bp 0x%p dev %s logdev %s rtdev %s\n",
10744 +       kdb_printf("sb_lock 0x%p sb_bp 0x%p dev 0x%x logdev 0x%x rtdev 0x%x\n",
10745                 &mp->m_sb_lock, mp->m_sb_bp,
10746 -               mp->m_ddev_targp ?
10747 -                       XFS_BUFTARG_NAME(mp->m_ddev_targp) : "none",
10748 -               mp->m_logdev_targp ?
10749 -                       XFS_BUFTARG_NAME(mp->m_logdev_targp) : "none",
10750 -               mp->m_rtdev_targp ?
10751 -                       XFS_BUFTARG_NAME(mp->m_rtdev_targp) : "none");
10752 +               mp->m_ddev_targp ? mp->m_ddev_targp->pbr_dev : 0,
10753 +               mp->m_logdev_targp ? mp->m_logdev_targp->pbr_dev : 0,
10754 +               mp->m_rtdev_targp ? mp->m_rtdev_targp->pbr_dev : 0);
10755         kdb_printf("bsize %d agfrotor %d agirotor %d ihash 0x%p ihsize %d\n",
10756                 mp->m_bsize, mp->m_agfrotor, mp->m_agirotor,
10757                 mp->m_ihash, mp->m_ihsize);
10758 @@ -4825,8 +6964,8 @@
10759                 ip->i_mnext,
10760                 ip->i_mprev,
10761                 XFS_ITOV_NULL(ip));
10762 -       kdb_printf("dev %s ino %s\n",
10763 -               XFS_BUFTARG_NAME(ip->i_mount->m_ddev_targp),
10764 +       kdb_printf("dev %x ino %s\n",
10765 +               ip->i_mount->m_dev,
10766                 xfs_fmtino(ip->i_ino, ip->i_mount));
10767         kdb_printf("blkno 0x%llx len 0x%x boffset 0x%x\n",
10768                 (long long) ip->i_blkno,
10769 @@ -4835,7 +6974,7 @@
10770         kdb_printf("transp 0x%p &itemp 0x%p\n",
10771                 ip->i_transp,
10772                 ip->i_itemp);
10773 -       kdb_printf("&lock 0x%p &iolock 0x%p",
10774 +       kdb_printf("&lock 0x%p &iolock 0x%p ",
10775                 &ip->i_lock,
10776                 &ip->i_iolock);
10777         kdb_printf("&flock 0x%p (%d) pincount 0x%x\n",
10778 @@ -4843,14 +6982,29 @@
10779                 xfs_ipincount(ip));
10780         kdb_printf("udquotp 0x%p gdquotp 0x%p\n",
10781                 ip->i_udquot, ip->i_gdquot);
10782 -       kdb_printf("new_size %Lx\n", ip->i_iocore.io_new_size);
10783 +       kdb_printf("new_size %Ld\n", ip->i_iocore.io_new_size);
10784         printflags((int)ip->i_flags, tab_flags, "flags");
10785         kdb_printf("\n");
10786 -       kdb_printf("update_core 0x%x update size 0x%x\n",
10787 +       kdb_printf("update_core %d update size %d\n",
10788                 (int)(ip->i_update_core), (int) ip->i_update_size);
10789         kdb_printf("gen 0x%x delayed blks %d",
10790                 ip->i_gen,
10791                 ip->i_delayed_blks);
10792 +#ifdef XFS_BMAP_TRACE
10793 +       qprintf(" bmap_trace 0x%p\n", ip->i_xtrace);
10794 +#endif
10795 +#ifdef XFS_BMBT_TRACE
10796 +       qprintf(" bmbt trace 0x%p\n", ip->i_btrace);
10797 +#endif  
10798 +#ifdef XFS_RW_TRACE
10799 +       qprintf(" rw trace 0x%p\n", ip->i_rwtrace);
10800 +#endif  
10801 +#ifdef XFS_ILOCK_TRACE
10802 +       qprintf(" ilock trace 0x%p\n", ip->i_lock_trace);
10803 +#endif
10804 +#ifdef XFS_DIR2_TRACE
10805 +       qprintf(" dir trace 0x%p\n", ip->i_dir_trace);
10806 +#endif  
10807         kdb_printf("\n");
10808         kdb_printf("chash 0x%p cnext 0x%p cprev 0x%p\n",
10809                 ip->i_chash,
10810 @@ -5032,6 +7186,9 @@
10811                 &dqp->q_flock,
10812                 (valusema(&dqp->q_flock) <= 0) ? "LCK" : "UNLKD",
10813                 dqp->q_pincount);
10814 +#ifdef XFS_DQUOT_TRACE
10815 +       qprintf("dqtrace 0x%p\n", dqp->q_trace);
10816 +#endif
10817         kdb_printf("disk-dquot 0x%p\n", &dqp->q_core);
10818         xfsidbg_xqm_diskdq(&dqp->q_core);
10819  
10820 @@ -5076,7 +7233,7 @@
10821         kdb_printf("\nNumber of inodes with dquots attached: %d\n", n);
10822  }
10823  
10824 -#ifdef CONFIG_XFS_QUOTA
10825 +#ifdef CONFIG_XFS_QUOTA
10826  static void
10827  xfsidbg_xqm_freelist_print(xfs_frlist_t *qlist, char *title)
10828  {
10829 @@ -5130,6 +7287,80 @@
10830  }
10831  #endif
10832  
10833 +#ifdef XFS_DQUOT_TRACE
10834 +static int
10835 +xfsidbg_xqm_pr_dqentry(ktrace_entry_t *ktep)
10836 +{
10837 +       static char *xdq_flags[] = {
10838 +               "USR",    /* 0x1 */
10839 +               "PRJ",    /* 0x2 */
10840 +               "LCKD",  /* 0x4 */
10841 +               "GRP",    /* 0x8 */
10842 +               "FLOCKD",       /* 0x08 */
10843 +               "DIRTY",        /* 0x10 */
10844 +               "WANT",  /* 0x20 */
10845 +               "INACT",        /* 0x40 */
10846 +               "MARKER",       /* 0x80 */
10847 +               0
10848 +       };
10849 +
10850 +       if ((__psint_t)ktep->val[0] == 0)
10851 +               return 0;
10852 +       switch ((__psint_t)ktep->val[0]) {
10853 +             case DQUOT_KTRACE_ENTRY:
10854 +               qprintf("[%ld] %s\t",
10855 +                       (long)ktep->val[12], /* pid */
10856 +                       (char *)ktep->val[1]);
10857 +               printflags((__psint_t)ktep->val[3], xdq_flags,"flgs ");
10858 +               qprintf("\nnrefs = %u, "
10859 +                       "flags = 0x%x, "
10860 +                       "id = %d, "
10861 +                       "res_bc = 0x%x\n"
10862 +                       "bcnt = 0x%x [0x%x | 0x%x], "
10863 +                       "icnt = 0x%x [0x%x | 0x%x]\n"
10864 +                       "@ %ld\n",
10865 +                       (unsigned int)(long)ktep->val[2], /* nrefs */
10866 +                       (unsigned int)(long)ktep->val[3], /* flags */
10867 +                       (unsigned int)(long)ktep->val[11], /* ID */
10868 +                       (unsigned int)(long)ktep->val[4], /* res_bc */
10869 +                       (unsigned int)(long)ktep->val[5], /* bcnt */
10870 +                       (unsigned int)(long)ktep->val[8], /* bsoft */
10871 +                       (unsigned int)(long)ktep->val[7], /* bhard */
10872 +                       (unsigned int)(long)ktep->val[6], /* icnt */
10873 +                       (unsigned int)(long)ktep->val[10], /* isoft */
10874 +                       (unsigned int)(long)ktep->val[9], /* ihard */
10875 +                       (long) ktep->val[13] /* time */
10876 +                       );
10877 +               break;
10878 +
10879 +             default:
10880 +               qprintf("unknown dqtrace record\n");
10881 +               break;
10882 +       }
10883 +       return (1);
10884 +}
10885 +
10886 +void
10887 +xfsidbg_xqm_dqtrace(xfs_dquot_t *dqp)
10888 +{
10889 +       ktrace_entry_t  *ktep;
10890 +       ktrace_snap_t   kts;
10891 +
10892 +       if (dqp->q_trace == NULL) {
10893 +               qprintf("The xfs dquot trace buffer is not initialized\n");
10894 +               return;
10895 +       }
10896 +       qprintf("xdqtrace dquot 0x%p\n", dqp);
10897 +
10898 +       ktep = ktrace_first(dqp->q_trace, &kts);
10899 +       while (ktep != NULL) {
10900 +               if (xfsidbg_xqm_pr_dqentry(ktep))
10901 +                       qprintf("---------------------------------\n");
10902 +               ktep = ktrace_next(dqp->q_trace, &kts);
10903 +       }
10904 +}
10905 +#endif
10906 +
10907  static void
10908  xfsidbg_xqm_mplist(xfs_mount_t *mp)
10909  {
10910 @@ -5206,7 +7437,54 @@
10911  
10912  }
10913  
10914 +#ifdef XFS_RW_TRACE
10915 +/*
10916 + * Print out the read/write trace buffer attached to the given inode.
10917 + */
10918 +static void
10919 +xfsidbg_xrwtrace(xfs_inode_t *ip)
10920 +{
10921 +       ktrace_entry_t  *ktep;
10922 +       ktrace_snap_t   kts;
10923 +       int             nentries;
10924 +       int             skip_entries;
10925 +       int             count = xargument;
10926 +
10927 +       if (ip->i_rwtrace == NULL) {
10928 +               qprintf("The inode trace buffer is not initialized\n");
10929 +               return;
10930 +       }
10931 +       qprintf("i_rwtrace = 0x%p\n", ip->i_rwtrace);
10932 +
10933 +       nentries = ktrace_nentries(ip->i_rwtrace);
10934 +       if (count == -1) {
10935 +               count = nentries;
10936 +       }
10937 +       if ((count <= 0) || (count > nentries)) {
10938 +               qprintf("Invalid count.  There are %d entries.\n", nentries);
10939 +               return;
10940 +       }
10941  
10942 +       ktep = ktrace_first(ip->i_rwtrace, &kts);
10943 +       if (count != nentries) {
10944 +               /*
10945 +                * Skip the total minus the number to look at minus one
10946 +                * for the entry returned by ktrace_first().
10947 +                */
10948 +               skip_entries = count - nentries - 1;
10949 +               ktep = ktrace_skip(ip->i_rwtrace, skip_entries, &kts);
10950 +               if (ktep == NULL) {
10951 +                       qprintf("Skipped them all\n");
10952 +                       return;
10953 +               }
10954 +       }
10955 +       while (ktep != NULL) {
10956 +               if (xfs_rw_trace_entry(ktep))
10957 +                       qprintf("\n");
10958 +               ktep = ktrace_next(ip->i_rwtrace, &kts);
10959 +       }
10960 +}
10961 +#endif
10962  
10963  /*
10964   * Print xfs superblock.
10965 @@ -5284,7 +7562,7 @@
10966                 "dirty",        /* 0x1 */
10967                 "sb_dirty",     /* 0x2 */
10968                 "perm_log_res", /* 0x4 */
10969 -               "sync",         /* 0x08 */
10970 +               "sync",          /* 0x08 */
10971                 "dq_dirty",     /* 0x10 */
10972                 0
10973                 };
10974 @@ -5298,7 +7576,7 @@
10975  
10976         kdb_printf("tp 0x%p type ", tp);
10977         switch (tp->t_type) {
10978 -       case XFS_TRANS_SETATTR_NOT_SIZE: kdb_printf("SETATTR_NOT_SIZE");        break;
10979 +       case XFS_TRANS_SETATTR_NOT_SIZE: kdb_printf("SETATTR_NOT_SIZE");break;
10980         case XFS_TRANS_SETATTR_SIZE:    kdb_printf("SETATTR_SIZE");     break;
10981         case XFS_TRANS_INACTIVE:        kdb_printf("INACTIVE");         break;
10982         case XFS_TRANS_CREATE:          kdb_printf("CREATE");           break;
10983 @@ -5310,32 +7588,31 @@
10984         case XFS_TRANS_MKDIR:           kdb_printf("MKDIR");            break;
10985         case XFS_TRANS_RMDIR:           kdb_printf("RMDIR");            break;
10986         case XFS_TRANS_SYMLINK:         kdb_printf("SYMLINK");          break;
10987 -       case XFS_TRANS_SET_DMATTRS:     kdb_printf("SET_DMATTRS");              break;
10988 +       case XFS_TRANS_SET_DMATTRS:     kdb_printf("SET_DMATTRS");      break;
10989         case XFS_TRANS_GROWFS:          kdb_printf("GROWFS");           break;
10990 -       case XFS_TRANS_STRAT_WRITE:     kdb_printf("STRAT_WRITE");              break;
10991 +       case XFS_TRANS_STRAT_WRITE:     kdb_printf("STRAT_WRITE");      break;
10992         case XFS_TRANS_DIOSTRAT:        kdb_printf("DIOSTRAT");         break;
10993 -       case XFS_TRANS_WRITE_SYNC:      kdb_printf("WRITE_SYNC");               break;
10994 +       case XFS_TRANS_WRITE_SYNC:      kdb_printf("WRITE_SYNC");       break;
10995         case XFS_TRANS_WRITEID:         kdb_printf("WRITEID");          break;
10996         case XFS_TRANS_ADDAFORK:        kdb_printf("ADDAFORK");         break;
10997 -       case XFS_TRANS_ATTRINVAL:       kdb_printf("ATTRINVAL");                break;
10998 -       case XFS_TRANS_ATRUNCATE:       kdb_printf("ATRUNCATE");                break;
10999 +       case XFS_TRANS_ATTRINVAL:       kdb_printf("ATTRINVAL");        break;
11000 +       case XFS_TRANS_ATRUNCATE:       kdb_printf("ATRUNCATE");        break;
11001         case XFS_TRANS_ATTR_SET:        kdb_printf("ATTR_SET");         break;
11002         case XFS_TRANS_ATTR_RM:         kdb_printf("ATTR_RM");          break;
11003 -       case XFS_TRANS_ATTR_FLAG:       kdb_printf("ATTR_FLAG");                break;
11004 -       case XFS_TRANS_CLEAR_AGI_BUCKET:  kdb_printf("CLEAR_AGI_BUCKET");       break;
11005 +       case XFS_TRANS_ATTR_FLAG:       kdb_printf("ATTR_FLAG");        break;
11006 +       case XFS_TRANS_CLEAR_AGI_BUCKET:kdb_printf("CLEAR_AGI_BUCKET"); break;
11007         case XFS_TRANS_QM_SBCHANGE:     kdb_printf("QM_SBCHANGE");      break;
11008         case XFS_TRANS_QM_QUOTAOFF:     kdb_printf("QM_QUOTAOFF");      break;
11009 -       case XFS_TRANS_QM_DQALLOC:      kdb_printf("QM_DQALLOC");               break;
11010 -       case XFS_TRANS_QM_SETQLIM:      kdb_printf("QM_SETQLIM");               break;
11011 +       case XFS_TRANS_QM_DQALLOC:      kdb_printf("QM_DQALLOC");       break;
11012 +       case XFS_TRANS_QM_SETQLIM:      kdb_printf("QM_SETQLIM");       break;
11013         case XFS_TRANS_QM_DQCLUSTER:    kdb_printf("QM_DQCLUSTER");     break;
11014         case XFS_TRANS_QM_QINOCREATE:   kdb_printf("QM_QINOCREATE");    break;
11015 -       case XFS_TRANS_QM_QUOTAOFF_END: kdb_printf("QM_QOFF_END");              break;
11016 +       case XFS_TRANS_QM_QUOTAOFF_END: kdb_printf("QM_QOFF_END");      break;
11017         case XFS_TRANS_SB_UNIT:         kdb_printf("SB_UNIT");          break;
11018         case XFS_TRANS_FSYNC_TS:        kdb_printf("FSYNC_TS");         break;
11019         case XFS_TRANS_GROWFSRT_ALLOC:  kdb_printf("GROWFSRT_ALLOC");   break;
11020         case XFS_TRANS_GROWFSRT_ZERO:   kdb_printf("GROWFSRT_ZERO");    break;
11021         case XFS_TRANS_GROWFSRT_FREE:   kdb_printf("GROWFSRT_FREE");    break;
11022 -
11023         default:                        kdb_printf("0x%x", tp->t_type); break;
11024         }
11025         kdb_printf(" mount 0x%p\n", tp->t_mountp);
11026 diff -urN linux.org/fs/xfs/xfs_iget.c linux/fs/xfs/xfs_iget.c
11027 --- linux.org/fs/xfs/xfs_iget.c 2003-12-31 05:48:38.000000000 +0100
11028 +++ linux/fs/xfs/xfs_iget.c     2004-01-02 04:21:44.000000000 +0100
11029 @@ -445,18 +445,17 @@
11030  retry:
11031         XFS_STATS_INC(xs_ig_attempts);
11032  
11033 -       if ((inode = iget_locked(XFS_MTOVFS(mp)->vfs_super, ino))) {
11034 +       if ((inode = VFS_GET_INODE(XFS_MTOVFS(mp), ino, 0))) {
11035                 bhv_desc_t      *bdp;
11036                 xfs_inode_t     *ip;
11037                 int             newnode;
11038  
11039 -
11040                 vp = LINVFS_GET_VP(inode);
11041                 if (inode->i_state & I_NEW) {
11042  inode_allocate:
11043                         vn_initialize(inode);
11044                         error = xfs_iget_core(vp, mp, tp, ino,
11045 -                                                       lock_flags, ipp, bno);
11046 +                                               lock_flags, ipp, bno);
11047                         if (error) {
11048                                 make_bad_inode(inode);
11049                                 if (inode->i_state & I_NEW)
11050 @@ -506,9 +505,6 @@
11051         mrlock_init(&ip->i_lock, MRLOCK_ALLOW_EQUAL_PRI|MRLOCK_BARRIER,
11052                      "xfsino", (long)vp->v_number);
11053         mrlock_init(&ip->i_iolock, MRLOCK_BARRIER, "xfsio", vp->v_number);
11054 -#ifdef NOTYET
11055 -       mutex_init(&ip->i_range_lock.r_spinlock, MUTEX_SPIN, "xrange");
11056 -#endif /* NOTYET */
11057         init_waitqueue_head(&ip->i_ipin_wait);
11058         atomic_set(&ip->i_pincount, 0);
11059         init_sema(&ip->i_flock, 1, "xfsfino", vp->v_number);
11060 @@ -830,9 +826,7 @@
11061         } else if (lock_flags & XFS_ILOCK_SHARED) {
11062                 mraccess(&ip->i_lock);
11063         }
11064 -#ifdef XFS_ILOCK_TRACE
11065 -       xfs_ilock_trace(ip, 1, lock_flags, (inst_t *)return_address);
11066 -#endif
11067 +       xfs_ilock_trace(ip, 1, lock_flags, (inst_t *)__return_address);
11068  }
11069  
11070  /*
11071 @@ -895,9 +889,7 @@
11072                         return 0;
11073                 }
11074         }
11075 -#ifdef XFS_ILOCK_TRACE
11076         xfs_ilock_trace(ip, 2, lock_flags, (inst_t *)__return_address);
11077 -#endif
11078         return 1;
11079  }
11080  
11081 @@ -955,9 +947,7 @@
11082                                                 (xfs_log_item_t*)(ip->i_itemp));
11083                 }
11084         }
11085 -#ifdef XFS_ILOCK_TRACE
11086         xfs_ilock_trace(ip, 3, lock_flags, (inst_t *)__return_address);
11087 -#endif
11088  }
11089  
11090  /*
11091 diff -urN linux.org/fs/xfs/xfs_inode.c linux/fs/xfs/xfs_inode.c
11092 --- linux.org/fs/xfs/xfs_inode.c        2003-12-31 05:48:38.000000000 +0100
11093 +++ linux/fs/xfs/xfs_inode.c    2004-01-02 04:21:44.000000000 +0100
11094 @@ -908,9 +908,6 @@
11095  #ifdef XFS_RW_TRACE
11096         ip->i_rwtrace = ktrace_alloc(XFS_RW_KTRACE_SIZE, KM_SLEEP);
11097  #endif
11098 -#ifdef XFS_STRAT_TRACE
11099 -       ip->i_strat_trace = ktrace_alloc(XFS_STRAT_KTRACE_SIZE, KM_SLEEP);
11100 -#endif
11101  #ifdef XFS_ILOCK_TRACE
11102         ip->i_lock_trace = ktrace_alloc(XFS_ILOCK_KTRACE_SIZE, KM_SLEEP);
11103  #endif
11104 @@ -1144,8 +1141,8 @@
11105         ip->i_d.di_onlink = 0;
11106         ip->i_d.di_nlink = nlink;
11107         ASSERT(ip->i_d.di_nlink == nlink);
11108 -       ip->i_d.di_uid = current->fsuid;
11109 -       ip->i_d.di_gid = current->fsgid;
11110 +       ip->i_d.di_uid = current_fsuid(cr);
11111 +       ip->i_d.di_gid = current_fsgid(cr);
11112         ip->i_d.di_projid = prid;
11113         memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
11114  
11115 @@ -1362,16 +1359,16 @@
11116         ktrace_enter(ip->i_rwtrace,
11117                      (void*)((long)tag),
11118                      (void*)ip,
11119 -                    (void*)((ip->i_d.di_size >> 32) & 0xffffffff),
11120 -                    (void*)(ip->i_d.di_size & 0xffffffff),
11121 +                    (void*)(unsigned long)((ip->i_d.di_size >> 32) & 0xffffffff),
11122 +                    (void*)(unsigned long)(ip->i_d.di_size & 0xffffffff),
11123                      (void*)((long)flag),
11124 -                    (void*)((new_size >> 32) & 0xffffffff),
11125 -                    (void*)(new_size & 0xffffffff),
11126 -                    (void*)((toss_start >> 32) & 0xffffffff),
11127 -                    (void*)(toss_start & 0xffffffff),
11128 -                    (void*)((toss_finish >> 32) & 0xffffffff),
11129 -                    (void*)(toss_finish & 0xffffffff),
11130 -                    (void*)((long)private.p_cpuid),
11131 +                    (void*)(unsigned long)((new_size >> 32) & 0xffffffff),
11132 +                    (void*)(unsigned long)(new_size & 0xffffffff),
11133 +                    (void*)(unsigned long)((toss_start >> 32) & 0xffffffff),
11134 +                    (void*)(unsigned long)(toss_start & 0xffffffff),
11135 +                    (void*)(unsigned long)((toss_finish >> 32) & 0xffffffff),
11136 +                    (void*)(unsigned long)(toss_finish & 0xffffffff),
11137 +                    (void*)(unsigned long)current_cpu(),
11138                      (void*)0,
11139                      (void*)0,
11140                      (void*)0,
11141 @@ -2755,17 +2752,8 @@
11142         }
11143         if (ip->i_afp)
11144                 xfs_idestroy_fork(ip, XFS_ATTR_FORK);
11145 -#ifdef NOTYET
11146 -       if (ip->i_range_lock.r_sleep != NULL) {
11147 -               freesema(ip->i_range_lock.r_sleep);
11148 -               kmem_free(ip->i_range_lock.r_sleep, sizeof(sema_t));
11149 -       }
11150 -#endif /* NOTYET */
11151         mrfree(&ip->i_lock);
11152         mrfree(&ip->i_iolock);
11153 -#ifdef NOTYET
11154 -       mutex_destroy(&ip->i_range_lock.r_spinlock);
11155 -#endif /* NOTYET */
11156         freesema(&ip->i_flock);
11157  #ifdef XFS_BMAP_TRACE
11158         ktrace_free(ip->i_xtrace);
11159 @@ -2776,9 +2764,6 @@
11160  #ifdef XFS_RW_TRACE
11161         ktrace_free(ip->i_rwtrace);
11162  #endif
11163 -#ifdef XFS_STRAT_TRACE
11164 -       ktrace_free(ip->i_strat_trace);
11165 -#endif
11166  #ifdef XFS_ILOCK_TRACE
11167         ktrace_free(ip->i_lock_trace);
11168  #endif
11169 @@ -3707,7 +3692,7 @@
11170         if ((error = _ACL_XFS_IACCESS(ip, mode, cr)) != -1)
11171                 return error ? XFS_ERROR(error) : 0;
11172  
11173 -       if (current->fsuid != ip->i_d.di_uid) {
11174 +       if (current_fsuid(cr) != ip->i_d.di_uid) {
11175                 mode >>= 3;
11176                 if (!in_group_p((gid_t)ip->i_d.di_gid))
11177                         mode >>= 3;
11178 @@ -3814,7 +3799,7 @@
11179          * We're not supposed to change timestamps in readonly-mounted
11180          * filesystems.  Throw it away if anyone asks us.
11181          */
11182 -       if (vp->v_vfsp->vfs_flag & VFS_RDONLY)
11183 +       if (unlikely(vp->v_vfsp->vfs_flag & VFS_RDONLY))
11184                 return;
11185  
11186         /*
11187 @@ -3828,17 +3813,17 @@
11188  
11189         nanotime(&tv);
11190         if (flags & XFS_ICHGTIME_MOD) {
11191 -               inode->i_mtime = tv;
11192 +               VN_MTIMESET(vp, &tv);
11193                 ip->i_d.di_mtime.t_sec = (__int32_t)tv.tv_sec;
11194                 ip->i_d.di_mtime.t_nsec = (__int32_t)tv.tv_nsec;
11195         }
11196         if (flags & XFS_ICHGTIME_ACC) {
11197 -               inode->i_atime  = tv;
11198 +               VN_ATIMESET(vp, &tv);
11199                 ip->i_d.di_atime.t_sec = (__int32_t)tv.tv_sec;
11200                 ip->i_d.di_atime.t_nsec = (__int32_t)tv.tv_nsec;
11201         }
11202         if (flags & XFS_ICHGTIME_CHG) {
11203 -               inode->i_ctime  = tv;
11204 +               VN_CTIMESET(vp, &tv);
11205                 ip->i_d.di_ctime.t_sec = (__int32_t)tv.tv_sec;
11206                 ip->i_d.di_ctime.t_nsec = (__int32_t)tv.tv_nsec;
11207         }
11208 @@ -3859,17 +3844,18 @@
11209  }
11210  
11211  #ifdef XFS_ILOCK_TRACE
11212 +ktrace_t       *xfs_ilock_trace_buf;
11213 +
11214  void
11215  xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags, inst_t *ra)
11216  {
11217         ktrace_enter(ip->i_lock_trace,
11218                      (void *)ip,
11219 -                     (void *)(__psint_t)lock,          /* 1 = LOCK, 3=UNLOCK, etc */
11220 -                    (void *)(__psint_t)lockflags,      /* XFS_ILOCK_EXCL etc */
11221 -                    (void *)ra,                        /* caller of ilock */
11222 -                    (void *)(__psint_t)cpuid(),
11223 -                    (void *)(__psint_t)current_pid(),
11224 +                    (void *)(unsigned long)lock, /* 1 = LOCK, 3=UNLOCK, etc */
11225 +                    (void *)(unsigned long)lockflags, /* XFS_ILOCK_EXCL etc */
11226 +                    (void *)ra,                /* caller of ilock */
11227 +                    (void *)(unsigned long)current_cpu(),
11228 +                    (void *)(unsigned long)current_pid(),
11229                      0,0,0,0,0,0,0,0,0,0);
11230 -
11231  }
11232 -#endif /* ILOCK_TRACE */
11233 +#endif
11234 diff -urN linux.org/fs/xfs/xfs_inode.h linux/fs/xfs/xfs_inode.h
11235 --- linux.org/fs/xfs/xfs_inode.h        2003-12-31 05:48:01.000000000 +0100
11236 +++ linux/fs/xfs/xfs_inode.h    2004-01-02 04:21:44.000000000 +0100
11237 @@ -99,6 +99,13 @@
11238  struct xfs_trans;
11239  struct xfs_dquot;
11240  
11241 +#if defined(XFS_ILOCK_TRACE)
11242 +#define XFS_ILOCK_KTRACE_SIZE  32
11243 +extern ktrace_t *xfs_ilock_trace_buf;
11244 +extern void xfs_ilock_trace(struct xfs_inode *, int, unsigned int, inst_t *);
11245 +#else
11246 +#define        xfs_ilock_trace(i,n,f,ra)
11247 +#endif
11248  
11249  /*
11250   * This structure is used to communicate which extents of a file
11251 @@ -264,7 +271,10 @@
11252         sema_t                  i_flock;        /* inode flush lock */
11253         atomic_t                i_pincount;     /* inode pin count */
11254         wait_queue_head_t       i_ipin_wait;    /* inode pinning wait queue */
11255 -
11256 +#ifdef HAVE_REFCACHE
11257 +       struct xfs_inode        **i_refcache;   /* ptr to entry in ref cache */
11258 +       struct xfs_inode        *i_release;     /* inode to unref */
11259 +#endif
11260         /* I/O state */
11261         xfs_iocore_t            i_iocore;       /* I/O core */
11262  
11263 @@ -280,15 +290,22 @@
11264         struct xfs_inode        *i_cnext;       /* cluster hash link forward */
11265         struct xfs_inode        *i_cprev;       /* cluster hash link backward */
11266  
11267 -#ifdef DEBUG
11268         /* Trace buffers per inode. */
11269 +#ifdef XFS_BMAP_TRACE
11270         struct ktrace           *i_xtrace;      /* inode extent list trace */
11271 +#endif
11272 +#ifdef XFS_BMBT_TRACE
11273         struct ktrace           *i_btrace;      /* inode bmap btree trace */
11274 +#endif
11275 +#ifdef XFS_RW_TRACE
11276         struct ktrace           *i_rwtrace;     /* inode read/write trace */
11277 -       struct ktrace           *i_strat_trace; /* inode strat_write trace */
11278 +#endif
11279 +#ifdef XFS_ILOCK_TRACE
11280         struct ktrace           *i_lock_trace;  /* inode lock/unlock trace */
11281 +#endif
11282 +#ifdef XFS_DIR2_TRACE
11283         struct ktrace           *i_dir_trace;   /* inode directory trace */
11284 -#endif /* DEBUG */
11285 +#endif
11286  } xfs_inode_t;
11287  
11288  #endif /* __KERNEL__ */
11289 @@ -536,12 +553,6 @@
11290  extern struct kmem_zone        *xfs_ili_zone;
11291  extern struct vnodeops xfs_vnodeops;
11292  
11293 -#ifdef XFS_ILOCK_TRACE
11294 -#define XFS_ILOCK_KTRACE_SIZE  32
11295 -void   xfs_ilock_trace(xfs_inode_t *ip, int lock, unsigned int lockflags,
11296 -                       inst_t *ra);
11297 -#endif
11298 -
11299  #endif /* __KERNEL__ */
11300  
11301  #endif /* __XFS_INODE_H__ */
11302 diff -urN linux.org/fs/xfs/xfs_iocore.c linux/fs/xfs/xfs_iocore.c
11303 --- linux.org/fs/xfs/xfs_iocore.c       2003-12-31 05:48:05.000000000 +0100
11304 +++ linux/fs/xfs/xfs_iocore.c   2004-01-02 04:21:44.000000000 +0100
11305 @@ -61,6 +61,7 @@
11306  #include "xfs_rw.h"
11307  #include "xfs_quota.h"
11308  #include "xfs_trans_space.h"
11309 +#include "xfs_iomap.h"
11310  
11311  
11312  STATIC xfs_fsize_t
11313 diff -urN linux.org/fs/xfs/xfs_iomap.h linux/fs/xfs/xfs_iomap.h
11314 --- linux.org/fs/xfs/xfs_iomap.h        1970-01-01 01:00:00.000000000 +0100
11315 +++ linux/fs/xfs/xfs_iomap.h    2004-01-02 04:21:44.000000000 +0100
11316 @@ -0,0 +1,107 @@
11317 +/*
11318 + * Copyright (c) 2003 Silicon Graphics, Inc.  All Rights Reserved.
11319 + *
11320 + * This program is free software; you can redistribute it and/or modify it
11321 + * under the terms of version 2 of the GNU General Public License as
11322 + * published by the Free Software Foundation.
11323 + *
11324 + * This program is distributed in the hope that it would be useful, but
11325 + * WITHOUT ANY WARRANTY; without even the implied warranty of
11326 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11327 + *
11328 + * Further, this software is distributed without any warranty that it is
11329 + * free of the rightful claim of any third person regarding infringement
11330 + * or the like.  Any license provided herein, whether implied or
11331 + * otherwise, applies only to this software file.  Patent licenses, if
11332 + * any, provided herein do not apply to combinations of this program with
11333 + * other software, or any other product whatsoever.
11334 + *
11335 + * You should have received a copy of the GNU General Public License along
11336 + * with this program; if not, write the Free Software Foundation, Inc., 59
11337 + * Temple Place - Suite 330, Boston MA 02111-1307, USA.
11338 + *
11339 + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
11340 + * Mountain View, CA  94043, or:
11341 + *
11342 + * http://www.sgi.com
11343 + *
11344 + * For further information regarding this notice, see:
11345 + *
11346 + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
11347 + */
11348 +
11349 +
11350 +
11351 +#ifndef __XFS_IOMAP_H__
11352 +#define __XFS_IOMAP_H__
11353 +
11354 +#define IOMAP_DADDR_NULL ((xfs_daddr_t) (-1LL))
11355 +
11356 +
11357 +typedef enum {                         /* iomap_flags values */
11358 +       IOMAP_EOF =             0x01,   /* mapping contains EOF   */
11359 +       IOMAP_HOLE =            0x02,   /* mapping covers a hole  */
11360 +       IOMAP_DELAY =           0x04,   /* mapping covers delalloc region  */
11361 +       IOMAP_UNWRITTEN =       0x20,   /* mapping covers allocated */
11362 +                                       /* but uninitialized file data  */
11363 +       IOMAP_NEW =             0x40    /* just allocate */
11364 +} iomap_flags_t;
11365 +
11366 +typedef enum {
11367 +       /* base extent manipulation calls */
11368 +       BMAPI_READ = (1 << 0),          /* read extents */
11369 +       BMAPI_WRITE = (1 << 1),         /* create extents */
11370 +       BMAPI_ALLOCATE = (1 << 2),      /* delayed allocate to real extents */
11371 +       BMAPI_UNWRITTEN  = (1 << 3),    /* unwritten extents to real extents */
11372 +       /* modifiers */
11373 +       BMAPI_IGNSTATE = (1 << 4),      /* ignore unwritten state on read */
11374 +       BMAPI_DIRECT = (1 << 5),                /* direct instead of buffered write */
11375 +       BMAPI_MMAP = (1 << 6),          /* allocate for mmap write */
11376 +       BMAPI_SYNC = (1 << 7),          /* sync write */
11377 +       BMAPI_TRYLOCK = (1 << 8),       /* non-blocking request */
11378 +       BMAPI_DEVICE = (1 << 9),        /* we only want to know the device */
11379 +} bmapi_flags_t;
11380 +
11381 +
11382 +/*
11383 + * xfs_iomap_t:  File system I/O map
11384 + *
11385 + * The iomap_bn, iomap_offset and iomap_length fields are expressed in disk blocks.
11386 + * The iomap_length field specifies the size of the underlying backing store
11387 + * for the particular mapping.
11388 + *
11389 + * The iomap_bsize, iomap_size and iomap_delta fields are in bytes and indicate
11390 + * the size of the mapping, the number of bytes that are valid to access
11391 + * (read or write), and the offset into the mapping, given the offset
11392 + * supplied to the file I/O map routine.  iomap_delta is the offset of the
11393 + * desired data from the beginning of the mapping.
11394 + *
11395 + * When a request is made to read beyond the logical end of the object,
11396 + * iomap_size may be set to 0, but iomap_offset and iomap_length should be set to
11397 + * the actual amount of underlying storage that has been allocated, if any.
11398 + */
11399 +
11400 +typedef struct xfs_iomap {
11401 +       xfs_daddr_t             iomap_bn;
11402 +       xfs_buftarg_t           *iomap_target;
11403 +       loff_t                  iomap_offset;
11404 +       size_t                  iomap_delta;
11405 +       size_t                  iomap_bsize;
11406 +       iomap_flags_t           iomap_flags;
11407 +} xfs_iomap_t;
11408 +
11409 +struct xfs_iocore;
11410 +struct xfs_inode;
11411 +struct xfs_bmbt_irec;
11412 +
11413 +extern int xfs_iomap(struct xfs_iocore *, xfs_off_t, ssize_t, int,
11414 +                    struct xfs_iomap *, int *);
11415 +extern int xfs_iomap_write_direct(struct xfs_inode *, loff_t, size_t,
11416 +                                 int, struct xfs_bmbt_irec *, int *, int);
11417 +extern int xfs_iomap_write_delay(struct xfs_inode *, loff_t, size_t, int,
11418 +                                struct xfs_bmbt_irec *, int *);
11419 +extern int xfs_iomap_write_allocate(struct xfs_inode *,
11420 +                               struct xfs_bmbt_irec *, int *);
11421 +extern int xfs_iomap_write_unwritten(struct xfs_inode *, loff_t, size_t);
11422 +
11423 +#endif /* __XFS_IOMAP_H__*/
11424 diff -urN linux.org/fs/xfs/xfs_itable.c linux/fs/xfs/xfs_itable.c
11425 --- linux.org/fs/xfs/xfs_itable.c       2003-12-31 05:46:26.000000000 +0100
11426 +++ linux/fs/xfs/xfs_itable.c   2004-01-02 04:21:44.000000000 +0100
11427 @@ -65,7 +65,10 @@
11428         xfs_trans_t     *tp,            /* transaction pointer */
11429         xfs_ino_t       ino,            /* inode number to get data for */
11430         void            *buffer,        /* buffer to place output in */
11431 +       int             ubsize,         /* size of buffer */
11432 +       void            *private_data,  /* my private data */
11433         xfs_daddr_t     bno,            /* starting bno of inode cluster */
11434 +       int             *ubused,        /* bytes used by me */
11435         void            *dibuff,        /* on-disk inode buffer */
11436         int             *stat)          /* BULKSTAT_RV_... */
11437  {
11438 @@ -86,6 +89,10 @@
11439                 *stat = BULKSTAT_RV_NOTHING;
11440                 return XFS_ERROR(EINVAL);
11441         }
11442 +       if (ubsize < sizeof(*buf)) {
11443 +               *stat = BULKSTAT_RV_NOTHING;
11444 +               return XFS_ERROR(ENOMEM);
11445 +       }
11446  
11447         if (dip == NULL) {
11448                 /* We're not being passed a pointer to a dinode.  This happens
11449 @@ -218,6 +225,8 @@
11450         }
11451  
11452         *stat = BULKSTAT_RV_DIDONE;
11453 +       if (ubused)
11454 +               *ubused = sizeof(*buf);
11455         return 0;
11456  }
11457  
11458 @@ -231,6 +240,7 @@
11459         xfs_ino_t               *lastinop, /* last inode returned */
11460         int                     *ubcountp, /* size of buffer/count returned */
11461         bulkstat_one_pf         formatter, /* func that'd fill a single buf */
11462 +       void                    *private_data,/* private data for formatter */
11463         size_t                  statstruct_size, /* sizeof struct filling */
11464         xfs_caddr_t             ubuffer, /* buffer with inode stats */
11465         int                     flags,  /* defined in xfs_itable.h */
11466 @@ -265,8 +275,10 @@
11467         int                     rval;   /* return value error code */
11468         int                     tmp;    /* result value from btree calls */
11469         int                     ubcount; /* size of user's buffer */
11470 -       int                     ubleft; /* spaces left in user's buffer */
11471 +       int                     ubleft; /* bytes left in user's buffer */
11472         xfs_caddr_t             ubufp;  /* current pointer into user's buffer */
11473 +       int                     ubelem; /* spaces used in user's buffer */
11474 +       int                     ubused; /* bytes used by formatter */
11475         xfs_buf_t               *bp;    /* ptr to on-disk inode cluster buf */
11476         xfs_dinode_t            *dip;   /* ptr into bp for specific inode */
11477         xfs_inode_t             *ip;    /* ptr to in-core inode struct */
11478 @@ -284,8 +296,9 @@
11479                 *ubcountp = 0;
11480                 return 0;
11481         }
11482 -       ubcount = ubleft = *ubcountp;
11483 -       *ubcountp = 0;
11484 +       ubcount = *ubcountp; /* statstruct's */
11485 +       ubleft = ubcount * statstruct_size; /* bytes */
11486 +       *ubcountp = ubelem = 0;
11487         *done = 0;
11488         fmterror = 0;
11489         ubufp = ubuffer;
11490 @@ -317,7 +330,7 @@
11491          * inode returned; 0 means start of the allocation group.
11492          */
11493         rval = 0;
11494 -       while (ubleft > 0 && agno < mp->m_sb.sb_agcount) {
11495 +       while ((ubleft/statstruct_size) > 0 && agno < mp->m_sb.sb_agcount) {
11496                 bp = NULL;
11497                 down_read(&mp->m_peraglock);
11498                 error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
11499 @@ -402,7 +415,7 @@
11500                  * Loop through inode btree records in this ag,
11501                  * until we run out of inodes or space in the buffer.
11502                  */
11503 -               while (irbp < irbufend && icount < ubcount) {
11504 +               while (irbp < irbufend && icount < (ubleft/statstruct_size)) {
11505                         /*
11506                          * Loop as long as we're unable to read the
11507                          * inode btree.
11508 @@ -453,7 +466,8 @@
11509                  * Now format all the good inodes into the user's buffer.
11510                  */
11511                 irbufend = irbp;
11512 -               for (irbp = irbuf; irbp < irbufend && ubleft > 0; irbp++) {
11513 +               for (irbp = irbuf;
11514 +                    irbp < irbufend && (ubleft/statstruct_size) > 0; irbp++) {
11515                         /*
11516                          * Read-ahead the next chunk's worth of inodes.
11517                          */
11518 @@ -561,14 +575,19 @@
11519                                  * Get the inode and fill in a single buffer.
11520                                  * BULKSTAT_FG_QUICK uses dip to fill it in.
11521                                  * BULKSTAT_FG_IGET uses igets.
11522 -                                * See: xfs_bulkstat_one & dm_bulkstat_one.
11523 +                                * See: xfs_bulkstat_one & xfs_dm_bulkstat_one.
11524                                  * This is also used to count inodes/blks, etc
11525                                  * in xfs_qm_quotacheck.
11526                                  */
11527 -                               error = formatter(mp, tp, ino, ubufp, bno, dip,
11528 -                                       &fmterror);
11529 -                               if (fmterror == BULKSTAT_RV_NOTHING)
11530 +                               ubused = statstruct_size;
11531 +                               error = formatter(mp, tp, ino, ubufp,
11532 +                                               ubleft, private_data,
11533 +                                               bno, &ubused, dip, &fmterror);
11534 +                               if (fmterror == BULKSTAT_RV_NOTHING) {
11535 +                                       if (error == ENOMEM)
11536 +                                               ubleft = 0;
11537                                         continue;
11538 +                               }
11539                                 if (fmterror == BULKSTAT_RV_GIVEUP) {
11540                                         ubleft = 0;
11541                                         ASSERT(error);
11542 @@ -576,8 +595,9 @@
11543                                         break;
11544                                 }
11545                                 if (ubufp)
11546 -                                       ubufp += statstruct_size;
11547 -                               ubleft--;
11548 +                                       ubufp += ubused;
11549 +                               ubleft -= ubused;
11550 +                               ubelem++;
11551                                 lastino = ino;
11552                         }
11553                 }
11554 @@ -605,7 +625,7 @@
11555         if (ubuffer)
11556                 unuseracc(ubuffer, ubcount * statstruct_size, (B_READ|B_PHYS));
11557  #endif
11558 -       *ubcountp = ubcount - ubleft;
11559 +       *ubcountp = ubelem;
11560         if (agno >= mp->m_sb.sb_agcount) {
11561                 /*
11562                  * If we ran out of filesystem, mark lastino as off
11563 @@ -647,7 +667,8 @@
11564          */
11565  
11566         ino = (xfs_ino_t)*lastinop;
11567 -       error = xfs_bulkstat_one(mp, NULL, ino, &bstat, 0, 0, &res);
11568 +       error = xfs_bulkstat_one(mp, NULL, ino, &bstat, sizeof(bstat),
11569 +                                NULL, 0, NULL, NULL, &res);
11570         if (error) {
11571                 /*
11572                  * Special case way failed, do it the "long" way
11573 @@ -656,6 +677,7 @@
11574                 (*lastinop)--;
11575                 count = 1;
11576                 if (xfs_bulkstat(mp, NULL, lastinop, &count, xfs_bulkstat_one,
11577 +                               NULL,
11578                                 sizeof(bstat), buffer, BULKSTAT_FG_IGET, done))
11579                         return error;
11580                 if (count == 0 || (xfs_ino_t)*lastinop != ino)
11581 diff -urN linux.org/fs/xfs/xfs_itable.h linux/fs/xfs/xfs_itable.h
11582 --- linux.org/fs/xfs/xfs_itable.h       2003-12-31 05:48:36.000000000 +0100
11583 +++ linux/fs/xfs/xfs_itable.h   2004-01-02 04:21:42.000000000 +0100
11584 @@ -36,15 +36,19 @@
11585   * xfs_bulkstat() is used to fill in xfs_bstat structures as well as dm_stat
11586   * structures (by the dmi library). This is a pointer to a formatter function
11587   * that will iget the inode and fill in the appropriate structure.
11588 - * see xfs_bulkstat_one() and dm_bulkstat_one() in dmi_xfs.c
11589 + * see xfs_bulkstat_one() and xfs_dm_bulkstat_one() in dmapi_xfs.c
11590   */
11591  typedef int (*bulkstat_one_pf)(struct xfs_mount        *mp,
11592                                struct xfs_trans *tp,
11593                                xfs_ino_t        ino,
11594                                void             *buffer,
11595 +                              int              ubsize,
11596 +                              void             *private_data,
11597                                xfs_daddr_t      bno,
11598 +                              int              *ubused,
11599                                void             *dip,
11600                                int              *stat);
11601 +
11602  /*
11603   * Values for stat return value.
11604   */
11605 @@ -69,6 +73,7 @@
11606         xfs_ino_t       *lastino,       /* last inode returned */
11607         int             *count,         /* size of buffer/count returned */
11608         bulkstat_one_pf formatter,      /* func that'd fill a single buf */
11609 +       void            *private_data,  /* private data for formatter */
11610         size_t          statstruct_size,/* sizeof struct that we're filling */
11611         xfs_caddr_t     ubuffer,        /* buffer with inode stats */
11612         int             flags,          /* flag to control access method */
11613 @@ -87,7 +92,10 @@
11614         xfs_trans_t             *tp,
11615         xfs_ino_t               ino,
11616         void                    *buffer,
11617 +       int                     ubsize,
11618 +       void                    *private_data,
11619         xfs_daddr_t             bno,
11620 +       int                     *ubused,
11621         void                    *dibuff,
11622         int                     *stat);
11623  
11624 diff -urN linux.org/fs/xfs/xfs_log.c linux/fs/xfs/xfs_log.c
11625 --- linux.org/fs/xfs/xfs_log.c  2003-12-31 05:48:47.000000000 +0100
11626 +++ linux/fs/xfs/xfs_log.c      2004-01-02 04:21:42.000000000 +0100
11627 @@ -159,11 +159,15 @@
11628  #endif
11629  
11630  #if defined(XFS_LOG_TRACE)
11631 +
11632  void
11633  xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string)
11634  {
11635 -       if (! log->l_grant_trace)
11636 -               log->l_grant_trace = ktrace_alloc(1024, KM_SLEEP);
11637 +       if (! log->l_grant_trace) {
11638 +               log->l_grant_trace = ktrace_alloc(1024, KM_NOSLEEP);
11639 +               if (! log->l_grant_trace)
11640 +                       return;
11641 +       }
11642  
11643         ktrace_enter(log->l_grant_trace,
11644                      (void *)tic,
11645 @@ -185,31 +189,6 @@
11646  }
11647  
11648  void
11649 -xlog_trace_tic(xlog_t *log, xlog_ticket_t *tic)
11650 -{
11651 -       if (! log->l_trace)
11652 -               log->l_trace = ktrace_alloc(256, KM_SLEEP);
11653 -
11654 -       ktrace_enter(log->l_trace,
11655 -                    (void *)tic,
11656 -                    (void *)((unsigned long)tic->t_curr_res),
11657 -                    (void *)((unsigned long)tic->t_unit_res),
11658 -                    (void *)((unsigned long)tic->t_ocnt),
11659 -                    (void *)((unsigned long)tic->t_cnt),
11660 -                    (void *)((unsigned long)tic->t_flags),
11661 -                    (void *)((unsigned long)7),
11662 -                    (void *)((unsigned long)8),
11663 -                    (void *)((unsigned long)9),
11664 -                    (void *)((unsigned long)10),
11665 -                    (void *)((unsigned long)11),
11666 -                    (void *)((unsigned long)12),
11667 -                    (void *)((unsigned long)13),
11668 -                    (void *)((unsigned long)14),
11669 -                    (void *)((unsigned long)15),
11670 -                    (void *)((unsigned long)16));
11671 -}
11672 -
11673 -void
11674  xlog_trace_iclog(xlog_in_core_t *iclog, uint state)
11675  {
11676         pid_t pid;
11677 @@ -1044,7 +1023,6 @@
11678   *
11679   * If the filesystem blocksize is too large, we may need to choose a
11680   * larger size since the directory code currently logs entire blocks.
11681 - * XXXmiken XXXcurtis
11682   */
11683  
11684  STATIC void
11685 @@ -1059,7 +1037,7 @@
11686          * When logbufs == 0, someone has disabled the log from the FSTAB
11687          * file.  This is not a documented feature.  We need to set xlog_debug
11688          * to zero (this deactivates the log) and set xlog_target to the
11689 -        * appropriate dev_t.  Only one filesystem may be affected as such
11690 +        * appropriate device.  Only one filesystem may be affected as such
11691          * since this is just a performance hack to test what we might be able
11692          * to get if the log were not present.
11693          */
11694 @@ -1078,7 +1056,7 @@
11695                         if (xfs_physmem <= btoc(128*1024*1024)) { 
11696                                 log->l_iclog_bufs = XLOG_MIN_ICLOGS; 
11697                         } else if (xfs_physmem <= btoc(400*1024*1024)) { 
11698 -                               log->l_iclog_bufs = XLOG_MED_ICLOGS;; 
11699 +                               log->l_iclog_bufs = XLOG_MED_ICLOGS; 
11700                         } else {
11701                                 /* 256K with 32K bufs */
11702                                 log->l_iclog_bufs = XLOG_MAX_ICLOGS;
11703 @@ -1087,9 +1065,9 @@
11704                         log->l_iclog_bufs = mp->m_logbufs;
11705  
11706  #if defined(DEBUG) || defined(XLOG_NOLOG)
11707 -               /* We are reactivating a filesystem after it was active */
11708 +               /* We are reactivating a filesystem after it was inactive */
11709                 if (log->l_targ == xlog_target) {
11710 -                       xlog_target = 1; /* XXX(hch): WTF? */
11711 +                       xlog_target = NULL;
11712                         xlog_debug = 1;
11713                 }
11714  #endif
11715 @@ -1578,7 +1556,7 @@
11716                 sv_destroy(&iclog->ic_forcesema);
11717                 sv_destroy(&iclog->ic_writesema);
11718                 xfs_buf_free(iclog->ic_bp);
11719 -#ifdef DEBUG
11720 +#ifdef XFS_LOG_TRACE
11721                 if (iclog->ic_trace != NULL) {
11722                         ktrace_free(iclog->ic_trace);
11723                 }
11724 @@ -1609,7 +1587,7 @@
11725                 }
11726         }
11727         xfs_buf_free(log->l_xbuf);
11728 -#ifdef DEBUG
11729 +#ifdef XFS_LOG_TRACE
11730         if (log->l_trace != NULL) {
11731                 ktrace_free(log->l_trace);
11732         }
11733 diff -urN linux.org/fs/xfs/xfs_log.h linux/fs/xfs/xfs_log.h
11734 --- linux.org/fs/xfs/xfs_log.h  2003-12-31 05:48:56.000000000 +0100
11735 +++ linux/fs/xfs/xfs_log.h      2004-01-02 04:21:42.000000000 +0100
11736 @@ -53,8 +53,8 @@
11737   * endian issues in treating two 32 bit numbers as one 64 bit number
11738   */
11739  static
11740 -#if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 95)
11741 -__attribute__((unused))        /* gcc 2.95 miscompiles this when inlined */
11742 +#if defined(__GNUC__) && (__GNUC__ == 2) && ( (__GNUC_MINOR__ == 95) || (__GNUC_MINOR__ == 96))
11743 +__attribute__((unused))        /* gcc 2.95, 2.96 miscompile this when inlined */
11744  #else
11745  __inline__
11746  #endif
11747 diff -urN linux.org/fs/xfs/xfs_log_priv.h linux/fs/xfs/xfs_log_priv.h
11748 --- linux.org/fs/xfs/xfs_log_priv.h     2003-12-31 05:46:29.000000000 +0100
11749 +++ linux/fs/xfs/xfs_log_priv.h 2004-01-02 04:21:42.000000000 +0100
11750 @@ -32,14 +32,6 @@
11751  #ifndef        __XFS_LOG_PRIV_H__
11752  #define __XFS_LOG_PRIV_H__
11753  
11754 -#if defined(XFS_ALL_TRACE)
11755 -#define        XFS_LOG_TRACE
11756 -#endif
11757 -
11758 -#if !defined(DEBUG)
11759 -#undef XFS_LOG_TRACE
11760 -#endif
11761 -
11762  struct xfs_buf;
11763  struct ktrace;
11764  struct log;
11765 @@ -109,6 +101,7 @@
11766  
11767  
11768  #ifdef __KERNEL__
11769 +
11770  /*
11771   * get client id from packed copy.
11772   *
11773 @@ -434,7 +427,7 @@
11774         struct log              *ic_log;
11775         xfs_log_callback_t      *ic_callback;
11776         xfs_log_callback_t      **ic_callback_tail;
11777 -#ifdef DEBUG
11778 +#ifdef XFS_LOG_TRACE
11779         struct ktrace           *ic_trace;
11780  #endif
11781         int                     ic_size;
11782 @@ -531,7 +524,7 @@
11783         int                     l_grant_write_bytes;
11784  
11785         /* The following fields don't need locking */
11786 -#ifdef DEBUG
11787 +#ifdef XFS_LOG_TRACE
11788         struct ktrace           *l_trace;
11789         struct ktrace           *l_grant_trace;
11790  #endif
11791 diff -urN linux.org/fs/xfs/xfs_mount.c linux/fs/xfs/xfs_mount.c
11792 --- linux.org/fs/xfs/xfs_mount.c        2003-12-31 05:46:55.000000000 +0100
11793 +++ linux/fs/xfs/xfs_mount.c    2004-01-02 04:21:42.000000000 +0100
11794 @@ -903,7 +903,7 @@
11795          *  File systems that don't support user level file handles (i.e.
11796          *  all of them except for XFS) will leave vfs_altfsid as NULL.
11797          */
11798 -       vfsp->vfs_altfsid = (fsid_t *)mp->m_fixedfsid;
11799 +       vfsp->vfs_altfsid = (xfs_fsid_t *)mp->m_fixedfsid;
11800         mp->m_dmevmask = 0;     /* not persistent; set after each mount */
11801  
11802         /*
11803 diff -urN linux.org/fs/xfs/xfs_qmops.c linux/fs/xfs/xfs_qmops.c
11804 --- linux.org/fs/xfs/xfs_qmops.c        2003-12-31 05:46:56.000000000 +0100
11805 +++ linux/fs/xfs/xfs_qmops.c    2004-01-02 04:21:43.000000000 +0100
11806 @@ -44,7 +44,6 @@
11807  #include "xfs_mount.h"
11808  
11809  
11810 -#ifndef CONFIG_XFS_QUOTA
11811  STATIC struct xfs_dquot *
11812  xfs_dqvopchown_default(
11813         struct xfs_trans        *tp,
11814 @@ -70,4 +69,3 @@
11815         .xfs_dqvopchown         = xfs_dqvopchown_default,
11816         .xfs_dqvopchownresv     = (xfs_dqvopchownresv_t) fs_noerr,
11817  };
11818 -#endif /* CONFIG_XFS_QUOTA */
11819 diff -urN linux.org/fs/xfs/xfs_refcache.c linux/fs/xfs/xfs_refcache.c
11820 --- linux.org/fs/xfs/xfs_refcache.c     1970-01-01 01:00:00.000000000 +0100
11821 +++ linux/fs/xfs/xfs_refcache.c 2004-01-02 04:21:43.000000000 +0100
11822 @@ -0,0 +1,439 @@
11823 +/*
11824 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
11825 + *
11826 + * This program is free software; you can redistribute it and/or modify it
11827 + * under the terms of version 2 of the GNU General Public License as
11828 + * published by the Free Software Foundation.
11829 + *
11830 + * This program is distributed in the hope that it would be useful, but
11831 + * WITHOUT ANY WARRANTY; without even the implied warranty of
11832 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11833 + *
11834 + * Further, this software is distributed without any warranty that it is
11835 + * free of the rightful claim of any third person regarding infringement
11836 + * or the like.  Any license provided herein, whether implied or
11837 + * otherwise, applies only to this software file.  Patent licenses, if
11838 + * any, provided herein do not apply to combinations of this program with
11839 + * other software, or any other product whatsoever.
11840 + *
11841 + * You should have received a copy of the GNU General Public License along
11842 + * with this program; if not, write the Free Software Foundation, Inc., 59
11843 + * Temple Place - Suite 330, Boston MA 02111-1307, USA.
11844 + *
11845 + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
11846 + * Mountain View, CA  94043, or:
11847 + *
11848 + * http://www.sgi.com
11849 + *
11850 + * For further information regarding this notice, see:
11851 + *
11852 + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
11853 + */
11854 +
11855 +#include "xfs.h"
11856 +#include "xfs_macros.h"
11857 +#include "xfs_types.h"
11858 +#include "xfs_inum.h"
11859 +#include "xfs_log.h"
11860 +#include "xfs_trans.h"
11861 +#include "xfs_sb.h"
11862 +#include "xfs_ag.h"
11863 +#include "xfs_dir.h"
11864 +#include "xfs_dir2.h"
11865 +#include "xfs_dmapi.h"
11866 +#include "xfs_mount.h"
11867 +#include "xfs_alloc_btree.h"
11868 +#include "xfs_bmap_btree.h"
11869 +#include "xfs_ialloc_btree.h"
11870 +#include "xfs_itable.h"
11871 +#include "xfs_btree.h"
11872 +#include "xfs_alloc.h"
11873 +#include "xfs_ialloc.h"
11874 +#include "xfs_attr.h"
11875 +#include "xfs_attr_sf.h"
11876 +#include "xfs_dir_sf.h"
11877 +#include "xfs_dir2_sf.h"
11878 +#include "xfs_dinode.h"
11879 +#include "xfs_inode_item.h"
11880 +#include "xfs_inode.h"
11881 +#include "xfs_bmap.h"
11882 +#include "xfs_error.h"
11883 +#include "xfs_buf_item.h"
11884 +#include "xfs_refcache.h"
11885 +
11886 +STATIC spinlock_t      xfs_refcache_lock = SPIN_LOCK_UNLOCKED;
11887 +STATIC xfs_inode_t     **xfs_refcache;
11888 +STATIC int             xfs_refcache_index;
11889 +STATIC int             xfs_refcache_busy;
11890 +STATIC int             xfs_refcache_count;
11891 +
11892 +/*
11893 + * Insert the given inode into the reference cache.
11894 + */
11895 +void
11896 +xfs_refcache_insert(
11897 +       xfs_inode_t     *ip)
11898 +{
11899 +       vnode_t         *vp;
11900 +       xfs_inode_t     *release_ip;
11901 +       xfs_inode_t     **refcache;
11902 +
11903 +       ASSERT(ismrlocked(&(ip->i_iolock), MR_UPDATE));
11904 +
11905 +       /*
11906 +        * If an unmount is busy blowing entries out of the cache,
11907 +        * then don't bother.
11908 +        */
11909 +       if (xfs_refcache_busy) {
11910 +               return;
11911 +       }
11912 +
11913 +       /*
11914 +        * If we tuned the refcache down to zero, don't do anything.
11915 +        */
11916 +        if (!xfs_refcache_size) {
11917 +               return;
11918 +       }
11919 +
11920 +       /*
11921 +        * The inode is already in the refcache, so don't bother
11922 +        * with it.
11923 +        */
11924 +       if (ip->i_refcache != NULL) {
11925 +               return;
11926 +       }
11927 +
11928 +       vp = XFS_ITOV(ip);
11929 +       /* ASSERT(vp->v_count > 0); */
11930 +       VN_HOLD(vp);
11931 +
11932 +       /*
11933 +        * We allocate the reference cache on use so that we don't
11934 +        * waste the memory on systems not being used as NFS servers.
11935 +        */
11936 +       if (xfs_refcache == NULL) {
11937 +               refcache = (xfs_inode_t **)kmem_zalloc(XFS_REFCACHE_SIZE_MAX *
11938 +                                                      sizeof(xfs_inode_t *),
11939 +                                                      KM_SLEEP);
11940 +       } else {
11941 +               refcache = NULL;
11942 +       }
11943 +
11944 +       spin_lock(&xfs_refcache_lock);
11945 +
11946 +       /*
11947 +        * If we allocated memory for the refcache above and it still
11948 +        * needs it, then use the memory we allocated.  Otherwise we'll
11949 +        * free the memory below.
11950 +        */
11951 +       if (refcache != NULL) {
11952 +               if (xfs_refcache == NULL) {
11953 +                       xfs_refcache = refcache;
11954 +                       refcache = NULL;
11955 +               }
11956 +       }
11957 +
11958 +       /*
11959 +        * If an unmount is busy clearing out the cache, don't add new
11960 +        * entries to it.
11961 +        */
11962 +       if (xfs_refcache_busy) {
11963 +               spin_unlock(&xfs_refcache_lock);
11964 +               VN_RELE(vp);
11965 +               /*
11966 +                * If we allocated memory for the refcache above but someone
11967 +                * else beat us to using it, then free the memory now.
11968 +                */
11969 +               if (refcache != NULL) {
11970 +                       kmem_free(refcache,
11971 +                                 XFS_REFCACHE_SIZE_MAX * sizeof(xfs_inode_t *));
11972 +               }
11973 +               return;
11974 +       }
11975 +       release_ip = xfs_refcache[xfs_refcache_index];
11976 +       if (release_ip != NULL) {
11977 +               release_ip->i_refcache = NULL;
11978 +               xfs_refcache_count--;
11979 +               ASSERT(xfs_refcache_count >= 0);
11980 +       }
11981 +       xfs_refcache[xfs_refcache_index] = ip;
11982 +       ASSERT(ip->i_refcache == NULL);
11983 +       ip->i_refcache = &(xfs_refcache[xfs_refcache_index]);
11984 +       xfs_refcache_count++;
11985 +       ASSERT(xfs_refcache_count <= xfs_refcache_size);
11986 +       xfs_refcache_index++;
11987 +       if (xfs_refcache_index == xfs_refcache_size) {
11988 +               xfs_refcache_index = 0;
11989 +       }
11990 +       spin_unlock(&xfs_refcache_lock);
11991 +
11992 +       /*
11993 +        * Save the pointer to the inode to be released so that we can
11994 +        * VN_RELE it once we've dropped our inode locks in xfs_rwunlock().
11995 +        * The pointer may be NULL, but that's OK.
11996 +        */
11997 +       ip->i_release = release_ip;
11998 +
11999 +       /*
12000 +        * If we allocated memory for the refcache above but someone
12001 +        * else beat us to using it, then free the memory now.
12002 +        */
12003 +       if (refcache != NULL) {
12004 +               kmem_free(refcache,
12005 +                         XFS_REFCACHE_SIZE_MAX * sizeof(xfs_inode_t *));
12006 +       }
12007 +}
12008 +
12009 +
12010 +/*
12011 + * If the given inode is in the reference cache, purge its entry and
12012 + * release the reference on the vnode.
12013 + */
12014 +void
12015 +xfs_refcache_purge_ip(
12016 +       xfs_inode_t     *ip)
12017 +{
12018 +       vnode_t *vp;
12019 +       int     error;
12020 +
12021 +       /*
12022 +        * If we're not pointing to our entry in the cache, then
12023 +        * we must not be in the cache.
12024 +        */
12025 +       if (ip->i_refcache == NULL) {
12026 +               return;
12027 +       }
12028 +
12029 +       spin_lock(&xfs_refcache_lock);
12030 +       if (ip->i_refcache == NULL) {
12031 +               spin_unlock(&xfs_refcache_lock);
12032 +               return;
12033 +       }
12034 +
12035 +       /*
12036 +        * Clear both our pointer to the cache entry and its pointer
12037 +        * back to us.
12038 +        */
12039 +       ASSERT(*(ip->i_refcache) == ip);
12040 +       *(ip->i_refcache) = NULL;
12041 +       ip->i_refcache = NULL;
12042 +       xfs_refcache_count--;
12043 +       ASSERT(xfs_refcache_count >= 0);
12044 +       spin_unlock(&xfs_refcache_lock);
12045 +
12046 +       vp = XFS_ITOV(ip);
12047 +       /* ASSERT(vp->v_count > 1); */
12048 +       VOP_RELEASE(vp, error);
12049 +       VN_RELE(vp);
12050 +}
12051 +
12052 +
12053 +/*
12054 + * This is called from the XFS unmount code to purge all entries for the
12055 + * given mount from the cache.  It uses the refcache busy counter to
12056 + * make sure that new entries are not added to the cache as we purge them.
12057 + */
12058 +void
12059 +xfs_refcache_purge_mp(
12060 +       xfs_mount_t     *mp)
12061 +{
12062 +       vnode_t         *vp;
12063 +       int             error, i;
12064 +       xfs_inode_t     *ip;
12065 +
12066 +       if (xfs_refcache == NULL) {
12067 +               return;
12068 +       }
12069 +
12070 +       spin_lock(&xfs_refcache_lock);
12071 +       /*
12072 +        * Bumping the busy counter keeps new entries from being added
12073 +        * to the cache.  We use a counter since multiple unmounts could
12074 +        * be in here simultaneously.
12075 +        */
12076 +       xfs_refcache_busy++;
12077 +
12078 +       for (i = 0; i < xfs_refcache_size; i++) {
12079 +               ip = xfs_refcache[i];
12080 +               if ((ip != NULL) && (ip->i_mount == mp)) {
12081 +                       xfs_refcache[i] = NULL;
12082 +                       ip->i_refcache = NULL;
12083 +                       xfs_refcache_count--;
12084 +                       ASSERT(xfs_refcache_count >= 0);
12085 +                       spin_unlock(&xfs_refcache_lock);
12086 +                       vp = XFS_ITOV(ip);
12087 +                       VOP_RELEASE(vp, error);
12088 +                       VN_RELE(vp);
12089 +                       spin_lock(&xfs_refcache_lock);
12090 +               }
12091 +       }
12092 +
12093 +       xfs_refcache_busy--;
12094 +       ASSERT(xfs_refcache_busy >= 0);
12095 +       spin_unlock(&xfs_refcache_lock);
12096 +}
12097 +
12098 +
12099 +/*
12100 + * This is called from the XFS sync code to ensure that the refcache
12101 + * is emptied out over time.  We purge a small number of entries with
12102 + * each call.
12103 + */
12104 +void
12105 +xfs_refcache_purge_some(xfs_mount_t *mp)
12106 +{
12107 +       int             error, i;
12108 +       xfs_inode_t     *ip;
12109 +       int             iplist_index;
12110 +       xfs_inode_t     **iplist;
12111 +
12112 +       if ((xfs_refcache == NULL) || (xfs_refcache_count == 0)) {
12113 +               return;
12114 +       }
12115 +
12116 +       iplist_index = 0;
12117 +       iplist = (xfs_inode_t **)kmem_zalloc(xfs_refcache_purge_count *
12118 +                                         sizeof(xfs_inode_t *), KM_SLEEP);
12119 +
12120 +       spin_lock(&xfs_refcache_lock);
12121 +
12122 +       /*
12123 +        * Store any inodes we find in the next several entries
12124 +        * into the iplist array to be released after dropping
12125 +        * the spinlock.  We always start looking from the currently
12126 +        * oldest place in the cache.  We move the refcache index
12127 +        * forward as we go so that we are sure to eventually clear
12128 +        * out the entire cache when the system goes idle.
12129 +        */
12130 +       for (i = 0; i < xfs_refcache_purge_count; i++) {
12131 +               ip = xfs_refcache[xfs_refcache_index];
12132 +               if (ip != NULL) {
12133 +                       xfs_refcache[xfs_refcache_index] = NULL;
12134 +                       ip->i_refcache = NULL;
12135 +                       xfs_refcache_count--;
12136 +                       ASSERT(xfs_refcache_count >= 0);
12137 +                       iplist[iplist_index] = ip;
12138 +                       iplist_index++;
12139 +               }
12140 +               xfs_refcache_index++;
12141 +               if (xfs_refcache_index == xfs_refcache_size) {
12142 +                       xfs_refcache_index = 0;
12143 +               }
12144 +       }
12145 +
12146 +       spin_unlock(&xfs_refcache_lock);
12147 +
12148 +       /*
12149 +        * Now drop the inodes we collected.
12150 +        */
12151 +       for (i = 0; i < iplist_index; i++) {
12152 +               VOP_RELEASE(XFS_ITOV(iplist[i]), error);
12153 +               VN_RELE(XFS_ITOV(iplist[i]));
12154 +       }
12155 +
12156 +       kmem_free(iplist, xfs_refcache_purge_count *
12157 +                         sizeof(xfs_inode_t *));
12158 +}
12159 +
12160 +/*
12161 + * This is called when the refcache is dynamically resized
12162 + * via a sysctl.
12163 + *
12164 + * If the new size is smaller than the old size, purge all
12165 + * entries in slots greater than the new size, and move
12166 + * the index if necessary.
12167 + *
12168 + * If the refcache hasn't even been allocated yet, or the
12169 + * new size is larger than the old size, just set the value
12170 + * of xfs_refcache_size.
12171 + */
12172 +
12173 +void
12174 +xfs_refcache_resize(int xfs_refcache_new_size)
12175 +{
12176 +       int             i;
12177 +       xfs_inode_t     *ip;
12178 +       int             iplist_index = 0;
12179 +       xfs_inode_t     **iplist;
12180 +       int             error;
12181 +
12182 +       /*
12183 +        * If the new size is smaller than the current size,
12184 +        * purge entries to create smaller cache, and
12185 +        * reposition index if necessary.
12186 +        * Don't bother if no refcache yet.
12187 +        */
12188 +       if (xfs_refcache && (xfs_refcache_new_size < xfs_refcache_size)) {
12189 +
12190 +               iplist = (xfs_inode_t **)kmem_zalloc(XFS_REFCACHE_SIZE_MAX *
12191 +                               sizeof(xfs_inode_t *), KM_SLEEP);
12192 +
12193 +               spin_lock(&xfs_refcache_lock);
12194 +
12195 +               for (i = xfs_refcache_new_size; i < xfs_refcache_size; i++) {
12196 +                       ip = xfs_refcache[i];
12197 +                       if (ip != NULL) {
12198 +                               xfs_refcache[i] = NULL;
12199 +                               ip->i_refcache = NULL;
12200 +                               xfs_refcache_count--;
12201 +                               ASSERT(xfs_refcache_count >= 0);
12202 +                               iplist[iplist_index] = ip;
12203 +                               iplist_index++;
12204 +                       }
12205 +               }
12206 +
12207 +               xfs_refcache_size = xfs_refcache_new_size;
12208 +
12209 +               /*
12210 +                * Move index to beginning of cache if it's now past the end
12211 +                */
12212 +               if (xfs_refcache_index >= xfs_refcache_new_size)
12213 +                       xfs_refcache_index = 0;
12214 +
12215 +               spin_unlock(&xfs_refcache_lock);
12216 +
12217 +               /*
12218 +                * Now drop the inodes we collected.
12219 +                */
12220 +               for (i = 0; i < iplist_index; i++) {
12221 +                       VOP_RELEASE(XFS_ITOV(iplist[i]), error);
12222 +                       VN_RELE(XFS_ITOV(iplist[i]));
12223 +               }
12224 +
12225 +               kmem_free(iplist, XFS_REFCACHE_SIZE_MAX *
12226 +                                 sizeof(xfs_inode_t *));
12227 +       } else {
12228 +               spin_lock(&xfs_refcache_lock);
12229 +               xfs_refcache_size = xfs_refcache_new_size;
12230 +               spin_unlock(&xfs_refcache_lock);
12231 +       }
12232 +}
12233 +
12234 +void
12235 +xfs_refcache_iunlock(
12236 +       xfs_inode_t     *ip,
12237 +       uint            lock_flags)
12238 +{
12239 +       xfs_inode_t     *release_ip;
12240 +       int             error;
12241 +
12242 +       release_ip = ip->i_release;
12243 +       ip->i_release = NULL;
12244 +
12245 +       xfs_iunlock(ip, lock_flags);
12246 +
12247 +       if (release_ip != NULL) {
12248 +               VOP_RELEASE(XFS_ITOV(release_ip), error);
12249 +               VN_RELE(XFS_ITOV(release_ip));
12250 +       }
12251 +}
12252 +
12253 +void
12254 +xfs_refcache_destroy(void)
12255 +{
12256 +       if (xfs_refcache) {
12257 +               kmem_free(xfs_refcache,
12258 +                       XFS_REFCACHE_SIZE_MAX * sizeof(xfs_inode_t *));
12259 +               xfs_refcache = NULL;
12260 +       }
12261 +}
12262 diff -urN linux.org/fs/xfs/xfs_refcache.h linux/fs/xfs/xfs_refcache.h
12263 --- linux.org/fs/xfs/xfs_refcache.h     1970-01-01 01:00:00.000000000 +0100
12264 +++ linux/fs/xfs/xfs_refcache.h 2004-01-02 04:21:43.000000000 +0100
12265 @@ -0,0 +1,66 @@
12266 +/*
12267 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
12268 + *
12269 + * This program is free software; you can redistribute it and/or modify it
12270 + * under the terms of version 2 of the GNU General Public License as
12271 + * published by the Free Software Foundation.
12272 + *
12273 + * This program is distributed in the hope that it would be useful, but
12274 + * WITHOUT ANY WARRANTY; without even the implied warranty of
12275 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12276 + *
12277 + * Further, this software is distributed without any warranty that it is
12278 + * free of the rightful claim of any third person regarding infringement
12279 + * or the like.  Any license provided herein, whether implied or
12280 + * otherwise, applies only to this software file.  Patent licenses, if
12281 + * any, provided herein do not apply to combinations of this program with
12282 + * other software, or any other product whatsoever.
12283 + *
12284 + * You should have received a copy of the GNU General Public License along
12285 + * with this program; if not, write the Free Software Foundation, Inc., 59
12286 + * Temple Place - Suite 330, Boston MA 02111-1307, USA.
12287 + *
12288 + * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
12289 + * Mountain View, CA  94043, or:
12290 + *
12291 + * http://www.sgi.com
12292 + *
12293 + * For further information regarding this notice, see:
12294 + *
12295 + * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
12296 + */
12297 +#ifndef __XFS_REFCACHE_H__
12298 +#define __XFS_REFCACHE_H__
12299 +
12300 +#ifdef HAVE_REFCACHE
12301 +/*
12302 + * Maximum size (in inodes) for the NFS reference cache
12303 + */
12304 +#define XFS_REFCACHE_SIZE_MAX  512
12305 +
12306 +struct xfs_inode;
12307 +struct xfs_mount;
12308 +
12309 +extern void xfs_refcache_insert(struct xfs_inode *);
12310 +extern void xfs_refcache_purge_ip(struct xfs_inode *);
12311 +extern void xfs_refcache_purge_mp(struct xfs_mount *);
12312 +extern void xfs_refcache_purge_some(struct xfs_mount *);
12313 +extern void xfs_refcache_resize(int);
12314 +extern void xfs_refcache_destroy(void);
12315 +
12316 +extern void xfs_refcache_iunlock(struct xfs_inode *, uint);
12317 +
12318 +#else
12319 +
12320 +#define xfs_refcache_insert(ip)                do { } while (0)
12321 +#define xfs_refcache_purge_ip(ip)      do { } while (0)
12322 +#define xfs_refcache_purge_mp(mp)      do { } while (0)
12323 +#define xfs_refcache_purge_some(mp)    do { } while (0)
12324 +#define xfs_refcache_resize(size)      do { } while (0)
12325 +#define xfs_refcache_destroy()         do { } while (0)
12326 +
12327 +#define xfs_refcache_iunlock(ip, flags)        xfs_iunlock(ip, flags)
12328 +
12329 +#endif
12330 +
12331 +#endif /* __XFS_REFCACHE_H__ */
12332 diff -urN linux.org/fs/xfs/xfs_rename.c linux/fs/xfs/xfs_rename.c
12333 --- linux.org/fs/xfs/xfs_rename.c       2003-12-31 05:47:23.000000000 +0100
12334 +++ linux/fs/xfs/xfs_rename.c   2004-01-02 04:21:43.000000000 +0100
12335 @@ -1,5 +1,5 @@
12336  /*
12337 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
12338 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
12339   *
12340   * This program is free software; you can redistribute it and/or modify it
12341   * under the terms of version 2 of the GNU General Public License as
12342 @@ -51,7 +51,7 @@
12343  #include "xfs_bmap.h"
12344  #include "xfs_error.h"
12345  #include "xfs_quota.h"
12346 -#include "xfs_rw.h"
12347 +#include "xfs_refcache.h"
12348  #include "xfs_utils.h"
12349  #include "xfs_trans_space.h"
12350  #include "xfs_da_btree.h"
12351 @@ -343,8 +343,7 @@
12352         src_is_directory = ((src_ip->i_d.di_mode & S_IFMT) == S_IFDIR);
12353  
12354         /*
12355 -        * Drop the locks on our inodes so that we can do the ancestor
12356 -        * check if necessary and start the transaction.
12357 +        * Drop the locks on our inodes so that we can start the transaction.
12358          */
12359         xfs_rename_unlock4(inodes, XFS_ILOCK_SHARED);
12360  
12361 @@ -486,7 +485,7 @@
12362                 error = xfs_droplink(tp, target_ip);
12363                 if (error) {
12364                         rename_which_error_return = __LINE__;
12365 -                       goto abort_return;;
12366 +                       goto abort_return;
12367                 }
12368                 target_ip_dropped = 1;
12369  
12370 @@ -627,6 +626,7 @@
12371          */
12372         error = xfs_trans_commit(tp, XFS_TRANS_RELEASE_LOG_RES, NULL);
12373         if (target_ip != NULL) {
12374 +               xfs_refcache_purge_ip(target_ip);
12375                 IRELE(target_ip);
12376         }
12377         /*
12378 diff -urN linux.org/fs/xfs/xfs_rw.c linux/fs/xfs/xfs_rw.c
12379 --- linux.org/fs/xfs/xfs_rw.c   2003-12-31 05:48:40.000000000 +0100
12380 +++ linux/fs/xfs/xfs_rw.c       2004-01-02 04:21:43.000000000 +0100
12381 @@ -1,5 +1,5 @@
12382  /*
12383 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
12384 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
12385   *
12386   * This program is free software; you can redistribute it and/or modify it
12387   * under the terms of version 2 of the GNU General Public License as
12388 @@ -149,6 +149,9 @@
12389                 xfs_cmn_err(XFS_PTAG_SHUTDOWN_CORRUPT, CE_ALERT, mp,
12390      "Corruption of in-memory data detected.  Shutting down filesystem: %s",
12391                         mp->m_fsname);
12392 +               if (XFS_ERRLEVEL_HIGH <= xfs_error_level) {
12393 +                       xfs_stack_trace();
12394 +               }
12395         } else if (!(flags & XFS_FORCE_UMOUNT)) {
12396                 if (logerror) {
12397                         xfs_cmn_err(XFS_PTAG_SHUTDOWN_LOGERROR, CE_ALERT, mp,
12398 @@ -351,54 +354,3 @@
12399         }
12400         return (error);
12401  }
12402 -
12403 -/*
12404 - * xfs_inval_cached_pages()
12405 - * This routine is responsible for keeping direct I/O and buffered I/O
12406 - * somewhat coherent.  From here we make sure that we're at least
12407 - * temporarily holding the inode I/O lock exclusively and then call
12408 - * the page cache to flush and invalidate any cached pages.  If there
12409 - * are no cached pages this routine will be very quick.
12410 - */
12411 -void
12412 -xfs_inval_cached_pages(
12413 -       vnode_t         *vp,
12414 -       xfs_iocore_t    *io,
12415 -       xfs_off_t       offset,
12416 -       int             write,
12417 -       int             relock)
12418 -{
12419 -       xfs_mount_t     *mp;
12420 -
12421 -       if (!VN_CACHED(vp)) {
12422 -               return;
12423 -       }
12424 -
12425 -       mp = io->io_mount;
12426 -
12427 -       /*
12428 -        * We need to get the I/O lock exclusively in order
12429 -        * to safely invalidate pages and mappings.
12430 -        */
12431 -       if (relock) {
12432 -               XFS_IUNLOCK(mp, io, XFS_IOLOCK_SHARED);
12433 -               XFS_ILOCK(mp, io, XFS_IOLOCK_EXCL);
12434 -       }
12435 -
12436 -       /* Writing beyond EOF creates a hole that must be zeroed */
12437 -       if (write && (offset > XFS_SIZE(mp, io))) {
12438 -               xfs_fsize_t     isize;
12439 -
12440 -               XFS_ILOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
12441 -               isize = XFS_SIZE(mp, io);
12442 -               if (offset > isize) {
12443 -                       xfs_zero_eof(vp, io, offset, isize, offset);
12444 -               }
12445 -               XFS_IUNLOCK(mp, io, XFS_ILOCK_EXCL|XFS_EXTSIZE_RD);
12446 -       }
12447 -
12448 -       VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(offset)), -1, FI_REMAPF_LOCKED);
12449 -       if (relock) {
12450 -               XFS_ILOCK_DEMOTE(mp, io, XFS_IOLOCK_EXCL);
12451 -       }
12452 -}
12453 diff -urN linux.org/fs/xfs/xfs_rw.h linux/fs/xfs/xfs_rw.h
12454 --- linux.org/fs/xfs/xfs_rw.h   2003-12-31 05:46:29.000000000 +0100
12455 +++ linux/fs/xfs/xfs_rw.h       2004-01-02 04:21:43.000000000 +0100
12456 @@ -1,5 +1,5 @@
12457  /*
12458 - * Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
12459 + * Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
12460   *
12461   * This program is free software; you can redistribute it and/or modify it
12462   * under the terms of version 2 of the GNU General Public License as
12463 @@ -32,16 +32,9 @@
12464  #ifndef        __XFS_RW_H__
12465  #define        __XFS_RW_H__
12466  
12467 -struct bhv_desc;
12468 -struct bmapval;
12469  struct xfs_buf;
12470 -struct cred;
12471 -struct uio;
12472 -struct vnode;
12473  struct xfs_inode;
12474 -struct xfs_iocore;
12475  struct xfs_mount;
12476 -struct xfs_trans;
12477  
12478  /*
12479   * Maximum count of bmaps used by read and write paths.
12480 @@ -91,44 +84,6 @@
12481                  XFS_FSB_TO_DADDR((io)->io_mount, (fsb)))
12482  
12483  /*
12484 - * Defines for the trace mechanisms in xfs_rw.c.
12485 - */
12486 -#define        XFS_RW_KTRACE_SIZE      64
12487 -#define        XFS_STRAT_KTRACE_SIZE   64
12488 -#define        XFS_STRAT_GTRACE_SIZE   512
12489 -
12490 -#define        XFS_READ_ENTER          1
12491 -#define        XFS_WRITE_ENTER         2
12492 -#define XFS_IOMAP_READ_ENTER   3
12493 -#define        XFS_IOMAP_WRITE_ENTER   4
12494 -#define        XFS_IOMAP_READ_MAP      5
12495 -#define        XFS_IOMAP_WRITE_MAP     6
12496 -#define        XFS_IOMAP_WRITE_NOSPACE 7
12497 -#define        XFS_ITRUNC_START        8
12498 -#define        XFS_ITRUNC_FINISH1      9
12499 -#define        XFS_ITRUNC_FINISH2      10
12500 -#define        XFS_CTRUNC1             11
12501 -#define        XFS_CTRUNC2             12
12502 -#define        XFS_CTRUNC3             13
12503 -#define        XFS_CTRUNC4             14
12504 -#define        XFS_CTRUNC5             15
12505 -#define        XFS_CTRUNC6             16
12506 -#define        XFS_BUNMAPI             17
12507 -#define        XFS_INVAL_CACHED        18
12508 -#define        XFS_DIORD_ENTER         19
12509 -#define        XFS_DIOWR_ENTER         20
12510 -
12511 -#if defined(XFS_ALL_TRACE)
12512 -#define        XFS_RW_TRACE
12513 -#define        XFS_STRAT_TRACE
12514 -#endif
12515 -
12516 -#if !defined(DEBUG)
12517 -#undef XFS_RW_TRACE
12518 -#undef XFS_STRAT_TRACE
12519 -#endif
12520 -
12521 -/*
12522   * Prototypes for functions in xfs_rw.c.
12523   */
12524  
12525 @@ -141,14 +96,6 @@
12526         struct xfs_mount        *mp,
12527         struct xfs_buf          *bp);
12528  
12529 -void
12530 -xfs_inval_cached_pages(
12531 -       struct vnode            *vp,
12532 -       struct xfs_iocore       *io,
12533 -       xfs_off_t               offset,
12534 -       int                     write,
12535 -       int                     relock);
12536 -
12537  int
12538  xfs_bioerror(
12539         struct xfs_buf          *b);
12540 diff -urN linux.org/fs/xfs/xfs_trans.c linux/fs/xfs/xfs_trans.c
12541 --- linux.org/fs/xfs/xfs_trans.c        2003-12-31 05:47:13.000000000 +0100
12542 +++ linux/fs/xfs/xfs_trans.c    2004-01-02 04:21:43.000000000 +0100
12543 @@ -142,9 +142,9 @@
12544         uint            type)
12545  {
12546         xfs_trans_t     *tp;
12547 +
12548         ASSERT(xfs_trans_zone != NULL);
12549         tp = kmem_zone_zalloc(xfs_trans_zone, KM_SLEEP);
12550 -       tp->t_dqinfo = NULL;
12551  
12552         /*
12553          * Initialize the transaction structure.
12554 diff -urN linux.org/fs/xfs/xfs_vfsops.c linux/fs/xfs/xfs_vfsops.c
12555 --- linux.org/fs/xfs/xfs_vfsops.c       2003-12-31 05:46:41.000000000 +0100
12556 +++ linux/fs/xfs/xfs_vfsops.c   2004-01-02 04:21:43.000000000 +0100
12557 @@ -60,6 +60,7 @@
12558  #include "xfs_bmap.h"
12559  #include "xfs_da_btree.h"
12560  #include "xfs_rw.h"
12561 +#include "xfs_refcache.h"
12562  #include "xfs_buf_item.h"
12563  #include "xfs_extfree_item.h"
12564  #include "xfs_quota.h"
12565 @@ -74,24 +75,11 @@
12566  int
12567  xfs_init(void)
12568  {
12569 -       extern kmem_zone_t      *xfs_da_state_zone;
12570         extern kmem_zone_t      *xfs_bmap_free_item_zone;
12571         extern kmem_zone_t      *xfs_btree_cur_zone;
12572 -       extern kmem_zone_t      *xfs_inode_zone;
12573 -       extern kmem_zone_t      *xfs_chashlist_zone;
12574         extern kmem_zone_t      *xfs_trans_zone;
12575         extern kmem_zone_t      *xfs_buf_item_zone;
12576 -       extern kmem_zone_t      *xfs_efd_zone;
12577 -       extern kmem_zone_t      *xfs_efi_zone;
12578         extern kmem_zone_t      *xfs_dabuf_zone;
12579 -#ifdef DEBUG_NOT
12580 -       extern ktrace_t         *xfs_alloc_trace_buf;
12581 -       extern ktrace_t         *xfs_bmap_trace_buf;
12582 -       extern ktrace_t         *xfs_bmbt_trace_buf;
12583 -       extern ktrace_t         *xfs_dir_trace_buf;
12584 -       extern ktrace_t         *xfs_attr_trace_buf;
12585 -       extern ktrace_t         *xfs_dir2_trace_buf;
12586 -#endif /* DEBUG */
12587  #ifdef XFS_DABUF_DEBUG
12588         extern lock_t           xfs_dabuf_global_lock;
12589         spinlock_init(&xfs_dabuf_global_lock, "xfsda");
12590 @@ -132,14 +120,6 @@
12591                                             "xfs_chashlist");
12592         _ACL_ZONE_INIT(xfs_acl_zone, "xfs_acl");
12593  
12594 -#ifdef CONFIG_XFS_VNODE_TRACING
12595 -       ktrace_init(VNODE_TRACE_SIZE);
12596 -#else
12597 -#ifdef DEBUG
12598 -       ktrace_init(64);
12599 -#endif
12600 -#endif
12601 -
12602         /*
12603          * Allocate global trace buffers.
12604          */
12605 @@ -189,6 +169,7 @@
12606  
12607         xfs_cleanup_procfs();
12608         xfs_sysctl_unregister();
12609 +       xfs_refcache_destroy();
12610  
12611         kmem_cache_destroy(xfs_bmap_free_item_zone);
12612         kmem_cache_destroy(xfs_btree_cur_zone);
12613 @@ -203,9 +184,6 @@
12614         kmem_cache_destroy(xfs_ili_zone);
12615         kmem_cache_destroy(xfs_chashlist_zone);
12616         _ACL_ZONE_DESTROY(xfs_acl_zone);
12617 -#if  (defined(DEBUG) || defined(CONFIG_XFS_VNODE_TRACING))
12618 -       ktrace_uninit();
12619 -#endif
12620  }
12621  
12622  /*
12623 @@ -547,6 +525,12 @@
12624                                         0 : DM_FLAGS_UNWANTED;
12625         }
12626  
12627 +       /*
12628 +        * First blow any referenced inode from this file system
12629 +        * out of the reference cache, and delete the timer.
12630 +        */
12631 +       xfs_refcache_purge_mp(mp);
12632 +
12633         XFS_bflush(mp->m_ddev_targp);
12634         error = xfs_unmount_flush(mp, 0);
12635         if (error)
12636 @@ -617,6 +601,7 @@
12637         }
12638  
12639         if (*flags & MS_RDONLY) {
12640 +               xfs_refcache_purge_mp(mp);
12641                 pagebuf_delwri_flush(mp->m_ddev_targp, 0, NULL);
12642                 xfs_finish_reclaim_all(mp, 0);
12643  
12644 @@ -758,7 +743,7 @@
12645  STATIC int
12646  xfs_statvfs(
12647         bhv_desc_t      *bdp,
12648 -       struct kstatfs  *statp,
12649 +       xfs_statfs_t    *statp,
12650         vnode_t         *vp)
12651  {
12652         __uint64_t      fakeinos;
12653 @@ -766,7 +751,6 @@
12654         xfs_mount_t     *mp;
12655         xfs_sb_t        *sbp;
12656         unsigned long   s;
12657 -       u64 id;
12658  
12659         mp = XFS_BHVTOM(bdp);
12660         sbp = &(mp->m_sb);
12661 @@ -793,9 +777,8 @@
12662         statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
12663         XFS_SB_UNLOCK(mp, s);
12664  
12665 -       id = huge_encode_dev(mp->m_dev);
12666 -       statp->f_fsid.val[0] = (u32)id;
12667 -       statp->f_fsid.val[1] = (u32)(id >> 32);
12668 +       statp->f_fsid.val[0] = mp->m_dev;
12669 +       statp->f_fsid.val[1] = 0;
12670         statp->f_namelen = MAXNAMELEN - 1;
12671  
12672         return 0;
12673 @@ -1489,8 +1472,18 @@
12674         }
12675  
12676         /*
12677 +        * If this is the periodic sync, then kick some entries out of
12678 +        * the reference cache.  This ensures that idle entries are
12679 +        * eventually kicked out of the cache.
12680 +        */
12681 +       if (flags & SYNC_REFCACHE) {
12682 +               xfs_refcache_purge_some(mp);
12683 +       }
12684 +
12685 +       /*
12686          * Now check to see if the log needs a "dummy" transaction.
12687          */
12688 +
12689         if (!(flags & SYNC_REMOUNT) && xfs_log_need_covered(mp)) {
12690                 xfs_trans_t *tp;
12691                 xfs_inode_t *ip;
12692 @@ -1598,8 +1591,9 @@
12693  #define MNTOPT_NORECOVERY   "norecovery"   /* don't run XFS recovery */
12694  #define MNTOPT_NOLOGFLUSH   "nologflush"   /* don't hard flush on log writes */
12695  #define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */
12696 -#define MNTOPT_64BITINODE   "inode64"  /* inodes can be allocated anywhere */
12697 -#define MNTOPT_IKEEP   "ikeep"         /* free empty inode clusters */
12698 +#define MNTOPT_64BITINODE   "inode64"  /* inodes can be allocated anywhere */
12699 +#define MNTOPT_IKEEP   "ikeep"         /* do not free empty inode clusters */
12700 +#define MNTOPT_NOIKEEP "noikeep"       /* free empty inode clusters */
12701  
12702  
12703  int
12704 @@ -1614,7 +1608,9 @@
12705         int                     dsunit, dswidth, vol_dsunit, vol_dswidth;
12706         int                     iosize;
12707  
12708 +#if 0  /* XXX: off by default, until some remaining issues ironed out */
12709         args->flags |= XFSMNT_IDELETE; /* default to on */
12710 +#endif
12711  
12712         if (!options)
12713                 return 0;
12714 @@ -1722,6 +1718,8 @@
12715                         args->flags |= XFSMNT_NOLOGFLUSH;
12716                 } else if (!strcmp(this_char, MNTOPT_IKEEP)) {
12717                         args->flags &= ~XFSMNT_IDELETE;
12718 +               } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
12719 +                       args->flags |= XFSMNT_IDELETE;
12720                 } else if (!strcmp(this_char, "osyncisdsync")) {
12721                         /* no-op, this is now the default */
12722  printk("XFS: osyncisdsync is now the default, option is deprecated.\n");
12723 @@ -1784,10 +1782,14 @@
12724                 char    *str;
12725         } xfs_info[] = {
12726                 /* the few simple ones we can get from the mount struct */
12727 +               { XFS_MOUNT_WSYNC,              "," MNTOPT_WSYNC },
12728 +               { XFS_MOUNT_INO64,              "," MNTOPT_INO64 },
12729                 { XFS_MOUNT_NOALIGN,            "," MNTOPT_NOALIGN },
12730 +               { XFS_MOUNT_NOUUID,             "," MNTOPT_NOUUID },
12731                 { XFS_MOUNT_NORECOVERY,         "," MNTOPT_NORECOVERY },
12732                 { XFS_MOUNT_OSYNCISOSYNC,       "," MNTOPT_OSYNCISOSYNC },
12733 -               { XFS_MOUNT_NOUUID,             "," MNTOPT_NOUUID },
12734 +               { XFS_MOUNT_NOLOGFLUSH,         "," MNTOPT_NOLOGFLUSH },
12735 +               { XFS_MOUNT_IDELETE,            "," MNTOPT_NOIKEEP },
12736                 { 0, NULL }
12737         };
12738         struct proc_xfs_info    *xfs_infop;
12739 @@ -1823,6 +1825,9 @@
12740                 seq_printf(m, "," MNTOPT_SWIDTH "=%d",
12741                                 (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
12742  
12743 +       if (!(mp->m_flags & XFS_MOUNT_32BITINOOPT))
12744 +               seq_printf(m, "," MNTOPT_64BITINODE);
12745 +       
12746         return 0;
12747  }
12748  
12749 @@ -1840,6 +1845,7 @@
12750         .vfs_vget               = xfs_vget,
12751         .vfs_dmapiops           = (vfs_dmapiops_t)fs_nosys,
12752         .vfs_quotactl           = (vfs_quotactl_t)fs_nosys,
12753 +       .vfs_get_inode          = xfs_get_inode,
12754         .vfs_init_vnode         = xfs_initialize_vnode,
12755         .vfs_force_shutdown     = xfs_do_force_shutdown,
12756  };
12757 diff -urN linux.org/fs/xfs/xfs_vnodeops.c linux/fs/xfs/xfs_vnodeops.c
12758 --- linux.org/fs/xfs/xfs_vnodeops.c     2003-12-31 05:48:49.000000000 +0100
12759 +++ linux/fs/xfs/xfs_vnodeops.c 2004-01-02 04:21:43.000000000 +0100
12760 @@ -59,6 +59,7 @@
12761  #include "xfs_da_btree.h"
12762  #include "xfs_attr.h"
12763  #include "xfs_rw.h"
12764 +#include "xfs_refcache.h"
12765  #include "xfs_error.h"
12766  #include "xfs_bit.h"
12767  #include "xfs_rtalloc.h"
12768 @@ -77,10 +78,6 @@
12769   */
12770  #define SYMLINK_MAPS 2
12771  
12772 -extern int xfs_ioctl(bhv_desc_t *, struct inode *, struct file *,
12773 -                       int, unsigned int, unsigned long);
12774 -
12775 -
12776  /*
12777   * For xfs, we check that the file isn't too big to be opened by this kernel.
12778   * No other open action is required for regular files.  Devices are handled
12779 @@ -434,7 +431,7 @@
12780         }
12781  
12782         /* boolean: are we the file owner? */
12783 -       file_owner = (current->fsuid == ip->i_d.di_uid);
12784 +       file_owner = (current_fsuid(credp) == ip->i_d.di_uid);
12785  
12786         /*
12787          * Change various properties of a file.
12788 @@ -1660,6 +1657,12 @@
12789         if (vp->v_vfsp->vfs_flag & VFS_RDONLY)
12790                 return 0;
12791  
12792 +#ifdef HAVE_REFCACHE
12793 +       /* If we are in the NFS reference cache then don't do this now */
12794 +       if (ip->i_refcache)
12795 +               return 0;
12796 +#endif
12797 +
12798         mp = ip->i_mount;
12799  
12800         if (ip->i_d.di_nlink != 0) {
12801 @@ -2004,7 +2007,8 @@
12802         /*
12803          * Make sure that we have allocated dquot(s) on disk.
12804          */
12805 -       error = XFS_QM_DQVOPALLOC(mp, dp, current->fsuid, current->fsgid,
12806 +       error = XFS_QM_DQVOPALLOC(mp, dp,
12807 +                       current_fsuid(credp), current_fsgid(credp),
12808                         XFS_QMOPT_QUOTALL|XFS_QMOPT_INHERIT, &udqp, &gdqp);
12809         if (error)
12810                 goto std_return;
12811 @@ -2613,6 +2617,14 @@
12812                 goto std_return;
12813         }
12814  
12815 +       /*
12816 +        * Before we drop our extra reference to the inode, purge it
12817 +        * from the refcache if it is there.  By waiting until afterwards
12818 +        * to do the IRELE, we ensure that we won't go inactive in the
12819 +        * xfs_refcache_purge_ip routine (although that would be OK).
12820 +        */
12821 +       xfs_refcache_purge_ip(ip);
12822 +
12823         vn_trace_exit(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
12824  
12825         /*
12826 @@ -2652,6 +2664,14 @@
12827         cancel_flags |= XFS_TRANS_ABORT;
12828         xfs_trans_cancel(tp, cancel_flags);
12829  
12830 +       /*
12831 +        * Before we drop our extra reference to the inode, purge it
12832 +        * from the refcache if it is there.  By waiting until afterwards
12833 +        * to do the IRELE, we ensure that we won't go inactive in the
12834 +        * xfs_refcache_purge_ip routine (although that would be OK).
12835 +        */
12836 +       xfs_refcache_purge_ip(ip);
12837 +
12838         IRELE(ip);
12839  
12840         goto std_return;
12841 @@ -2899,7 +2919,8 @@
12842         /*
12843          * Make sure that we have allocated dquot(s) on disk.
12844          */
12845 -       error = XFS_QM_DQVOPALLOC(mp, dp, current->fsuid, current->fsgid,
12846 +       error = XFS_QM_DQVOPALLOC(mp, dp,
12847 +                       current_fsuid(credp), current_fsgid(credp),
12848                         XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
12849         if (error)
12850                 goto std_return;
12851 @@ -3456,7 +3477,8 @@
12852         /*
12853          * Make sure that we have allocated dquot(s) on disk.
12854          */
12855 -       error = XFS_QM_DQVOPALLOC(mp, dp, current->fsuid, current->fsgid,
12856 +       error = XFS_QM_DQVOPALLOC(mp, dp,
12857 +                       current_fsuid(credp), current_fsgid(credp),
12858                         XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
12859         if (error)
12860                 goto std_return;
12861 @@ -3743,7 +3765,14 @@
12862                 return;
12863         ip = XFS_BHVTOI(bdp);
12864         if (locktype == VRWLOCK_WRITE) {
12865 -               xfs_iunlock (ip, XFS_IOLOCK_EXCL);
12866 +               /*
12867 +                * In the write case, we may have added a new entry to
12868 +                * the reference cache.  This might store a pointer to
12869 +                * an inode to be released in this inode.  If it is there,
12870 +                * clear the pointer and release the inode after unlocking
12871 +                * this one.
12872 +                */
12873 +               xfs_refcache_iunlock(ip, XFS_IOLOCK_EXCL);
12874         } else {
12875                 ASSERT((locktype == VRWLOCK_READ) ||
12876                        (locktype == VRWLOCK_WRITE_DIRECT));
12877 @@ -4738,7 +4767,9 @@
12878         BHV_IDENTITY_INIT(VN_BHV_XFS,VNODE_POSITION_XFS),
12879         .vop_open               = xfs_open,
12880         .vop_read               = xfs_read,
12881 +#ifdef HAVE_SENDFILE
12882         .vop_sendfile           = xfs_sendfile,
12883 +#endif
12884         .vop_write              = xfs_write,
12885         .vop_ioctl              = xfs_ioctl,
12886         .vop_getattr            = xfs_getattr,
This page took 1.181362 seconds and 3 git commands to generate.