Skip to content

Commit dfdebc2

Browse files
committed
Merge tag 'for-linus-v3.8-rc4' of git://oss.sgi.com/xfs/xfs
Pull xfs bugfixes from Ben Myers: - fix(es) for compound buffers - fix for dquot soft timer asserts due to overflow of d_blk_softlimit - fix for regression in dir v2 code introduced in commit 20f7e9f ("xfs: factor dir2 block read operations") * tag 'for-linus-v3.8-rc4' of git://oss.sgi.com/xfs/xfs: xfs: recalculate leaf entry pointer after compacting a dir2 block xfs: remove int casts from debug dquot soft limit timer asserts xfs: fix the multi-segment log buffer format xfs: fix segment in xfs_buf_item_format_segment xfs: rename bli_format to avoid confusion with bli_formats xfs: use b_maps[] for discontiguous buffers
2 parents 309b51e + 37f1356 commit dfdebc2

File tree

7 files changed

+64
-42
lines changed

7 files changed

+64
-42
lines changed

fs/xfs/xfs_buf.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ xfs_buf_get_maps(
175175
bp->b_map_count = map_count;
176176

177177
if (map_count == 1) {
178-
bp->b_maps = &bp->b_map;
178+
bp->b_maps = &bp->__b_map;
179179
return 0;
180180
}
181181

@@ -193,7 +193,7 @@ static void
193193
xfs_buf_free_maps(
194194
struct xfs_buf *bp)
195195
{
196-
if (bp->b_maps != &bp->b_map) {
196+
if (bp->b_maps != &bp->__b_map) {
197197
kmem_free(bp->b_maps);
198198
bp->b_maps = NULL;
199199
}
@@ -377,8 +377,8 @@ xfs_buf_allocate_memory(
377377
}
378378

379379
use_alloc_page:
380-
start = BBTOB(bp->b_map.bm_bn) >> PAGE_SHIFT;
381-
end = (BBTOB(bp->b_map.bm_bn + bp->b_length) + PAGE_SIZE - 1)
380+
start = BBTOB(bp->b_maps[0].bm_bn) >> PAGE_SHIFT;
381+
end = (BBTOB(bp->b_maps[0].bm_bn + bp->b_length) + PAGE_SIZE - 1)
382382
>> PAGE_SHIFT;
383383
page_count = end - start;
384384
error = _xfs_buf_get_pages(bp, page_count, flags);
@@ -640,7 +640,7 @@ _xfs_buf_read(
640640
xfs_buf_flags_t flags)
641641
{
642642
ASSERT(!(flags & XBF_WRITE));
643-
ASSERT(bp->b_map.bm_bn != XFS_BUF_DADDR_NULL);
643+
ASSERT(bp->b_maps[0].bm_bn != XFS_BUF_DADDR_NULL);
644644

645645
bp->b_flags &= ~(XBF_WRITE | XBF_ASYNC | XBF_READ_AHEAD);
646646
bp->b_flags |= flags & (XBF_READ | XBF_ASYNC | XBF_READ_AHEAD);
@@ -1709,7 +1709,7 @@ xfs_buf_cmp(
17091709
struct xfs_buf *bp = container_of(b, struct xfs_buf, b_list);
17101710
xfs_daddr_t diff;
17111711

1712-
diff = ap->b_map.bm_bn - bp->b_map.bm_bn;
1712+
diff = ap->b_maps[0].bm_bn - bp->b_maps[0].bm_bn;
17131713
if (diff < 0)
17141714
return -1;
17151715
if (diff > 0)

fs/xfs/xfs_buf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ typedef struct xfs_buf {
151151
struct page **b_pages; /* array of page pointers */
152152
struct page *b_page_array[XB_PAGES]; /* inline pages */
153153
struct xfs_buf_map *b_maps; /* compound buffer map */
154-
struct xfs_buf_map b_map; /* inline compound buffer map */
154+
struct xfs_buf_map __b_map; /* inline compound buffer map */
155155
int b_map_count;
156156
int b_io_length; /* IO size in BBs */
157157
atomic_t b_pin_count; /* pin count */
@@ -330,8 +330,8 @@ void xfs_buf_stale(struct xfs_buf *bp);
330330
* In future, uncached buffers will pass the block number directly to the io
331331
* request function and hence these macros will go away at that point.
332332
*/
333-
#define XFS_BUF_ADDR(bp) ((bp)->b_map.bm_bn)
334-
#define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_map.bm_bn = (xfs_daddr_t)(bno))
333+
#define XFS_BUF_ADDR(bp) ((bp)->b_maps[0].bm_bn)
334+
#define XFS_BUF_SET_ADDR(bp, bno) ((bp)->b_maps[0].bm_bn = (xfs_daddr_t)(bno))
335335

336336
static inline void xfs_buf_set_ref(struct xfs_buf *bp, int lru_ref)
337337
{

fs/xfs/xfs_buf_item.c

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ xfs_buf_item_log_debug(
7171
chunk_num = byte >> XFS_BLF_SHIFT;
7272
word_num = chunk_num >> BIT_TO_WORD_SHIFT;
7373
bit_num = chunk_num & (NBWORD - 1);
74-
wordp = &(bip->bli_format.blf_data_map[word_num]);
74+
wordp = &(bip->__bli_format.blf_data_map[word_num]);
7575
bit_set = *wordp & (1 << bit_num);
7676
ASSERT(bit_set);
7777
byte++;
@@ -237,7 +237,7 @@ xfs_buf_item_size(
237237
* cancel flag in it.
238238
*/
239239
trace_xfs_buf_item_size_stale(bip);
240-
ASSERT(bip->bli_format.blf_flags & XFS_BLF_CANCEL);
240+
ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL);
241241
return bip->bli_format_count;
242242
}
243243

@@ -278,7 +278,7 @@ xfs_buf_item_format_segment(
278278
uint buffer_offset;
279279

280280
/* copy the flags across from the base format item */
281-
blfp->blf_flags = bip->bli_format.blf_flags;
281+
blfp->blf_flags = bip->__bli_format.blf_flags;
282282

283283
/*
284284
* Base size is the actual size of the ondisk structure - it reflects
@@ -287,6 +287,17 @@ xfs_buf_item_format_segment(
287287
*/
288288
base_size = offsetof(struct xfs_buf_log_format, blf_data_map) +
289289
(blfp->blf_map_size * sizeof(blfp->blf_data_map[0]));
290+
291+
nvecs = 0;
292+
first_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0);
293+
if (!(bip->bli_flags & XFS_BLI_STALE) && first_bit == -1) {
294+
/*
295+
* If the map is not be dirty in the transaction, mark
296+
* the size as zero and do not advance the vector pointer.
297+
*/
298+
goto out;
299+
}
300+
290301
vecp->i_addr = blfp;
291302
vecp->i_len = base_size;
292303
vecp->i_type = XLOG_REG_TYPE_BFORMAT;
@@ -301,15 +312,13 @@ xfs_buf_item_format_segment(
301312
*/
302313
trace_xfs_buf_item_format_stale(bip);
303314
ASSERT(blfp->blf_flags & XFS_BLF_CANCEL);
304-
blfp->blf_size = nvecs;
305-
return vecp;
315+
goto out;
306316
}
307317

308318
/*
309319
* Fill in an iovec for each set of contiguous chunks.
310320
*/
311-
first_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0);
312-
ASSERT(first_bit != -1);
321+
313322
last_bit = first_bit;
314323
nbits = 1;
315324
for (;;) {
@@ -371,7 +380,8 @@ xfs_buf_item_format_segment(
371380
nbits++;
372381
}
373382
}
374-
bip->bli_format.blf_size = nvecs;
383+
out:
384+
blfp->blf_size = nvecs;
375385
return vecp;
376386
}
377387

@@ -405,7 +415,7 @@ xfs_buf_item_format(
405415
if (bip->bli_flags & XFS_BLI_INODE_BUF) {
406416
if (!((bip->bli_flags & XFS_BLI_INODE_ALLOC_BUF) &&
407417
xfs_log_item_in_current_chkpt(lip)))
408-
bip->bli_format.blf_flags |= XFS_BLF_INODE_BUF;
418+
bip->__bli_format.blf_flags |= XFS_BLF_INODE_BUF;
409419
bip->bli_flags &= ~XFS_BLI_INODE_BUF;
410420
}
411421

@@ -485,7 +495,7 @@ xfs_buf_item_unpin(
485495
ASSERT(bip->bli_flags & XFS_BLI_STALE);
486496
ASSERT(xfs_buf_islocked(bp));
487497
ASSERT(XFS_BUF_ISSTALE(bp));
488-
ASSERT(bip->bli_format.blf_flags & XFS_BLF_CANCEL);
498+
ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL);
489499

490500
trace_xfs_buf_item_unpin_stale(bip);
491501

@@ -601,7 +611,7 @@ xfs_buf_item_unlock(
601611
{
602612
struct xfs_buf_log_item *bip = BUF_ITEM(lip);
603613
struct xfs_buf *bp = bip->bli_buf;
604-
int aborted;
614+
int aborted, clean, i;
605615
uint hold;
606616

607617
/* Clear the buffer's association with this transaction. */
@@ -631,7 +641,7 @@ xfs_buf_item_unlock(
631641
*/
632642
if (bip->bli_flags & XFS_BLI_STALE) {
633643
trace_xfs_buf_item_unlock_stale(bip);
634-
ASSERT(bip->bli_format.blf_flags & XFS_BLF_CANCEL);
644+
ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL);
635645
if (!aborted) {
636646
atomic_dec(&bip->bli_refcount);
637647
return;
@@ -644,8 +654,15 @@ xfs_buf_item_unlock(
644654
* If the buf item isn't tracking any data, free it, otherwise drop the
645655
* reference we hold to it.
646656
*/
647-
if (xfs_bitmap_empty(bip->bli_format.blf_data_map,
648-
bip->bli_format.blf_map_size))
657+
clean = 1;
658+
for (i = 0; i < bip->bli_format_count; i++) {
659+
if (!xfs_bitmap_empty(bip->bli_formats[i].blf_data_map,
660+
bip->bli_formats[i].blf_map_size)) {
661+
clean = 0;
662+
break;
663+
}
664+
}
665+
if (clean)
649666
xfs_buf_item_relse(bp);
650667
else
651668
atomic_dec(&bip->bli_refcount);
@@ -716,7 +733,7 @@ xfs_buf_item_get_format(
716733
bip->bli_format_count = count;
717734

718735
if (count == 1) {
719-
bip->bli_formats = &bip->bli_format;
736+
bip->bli_formats = &bip->__bli_format;
720737
return 0;
721738
}
722739

@@ -731,7 +748,7 @@ STATIC void
731748
xfs_buf_item_free_format(
732749
struct xfs_buf_log_item *bip)
733750
{
734-
if (bip->bli_formats != &bip->bli_format) {
751+
if (bip->bli_formats != &bip->__bli_format) {
735752
kmem_free(bip->bli_formats);
736753
bip->bli_formats = NULL;
737754
}

fs/xfs/xfs_buf_item.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ typedef struct xfs_buf_log_item {
104104
#endif
105105
int bli_format_count; /* count of headers */
106106
struct xfs_buf_log_format *bli_formats; /* array of in-log header ptrs */
107-
struct xfs_buf_log_format bli_format; /* embedded in-log header */
107+
struct xfs_buf_log_format __bli_format; /* embedded in-log header */
108108
} xfs_buf_log_item_t;
109109

110110
void xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *);

fs/xfs/xfs_dir2_block.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,12 @@ xfs_dir2_block_addname(
355355
/*
356356
* If need to compact the leaf entries, do it now.
357357
*/
358-
if (compact)
358+
if (compact) {
359359
xfs_dir2_block_compact(tp, bp, hdr, btp, blp, &needlog,
360360
&lfloghigh, &lfloglow);
361-
else if (btp->stale) {
361+
/* recalculate blp post-compaction */
362+
blp = xfs_dir2_block_leaf_p(btp);
363+
} else if (btp->stale) {
362364
/*
363365
* Set leaf logging boundaries to impossible state.
364366
* For the no-stale case they're set explicitly.

fs/xfs/xfs_qm_syscalls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,11 +784,11 @@ xfs_qm_scall_getquota(
784784
(XFS_IS_OQUOTA_ENFORCED(mp) &&
785785
(dst->d_flags & (FS_PROJ_QUOTA | FS_GROUP_QUOTA)))) &&
786786
dst->d_id != 0) {
787-
if (((int) dst->d_bcount > (int) dst->d_blk_softlimit) &&
787+
if ((dst->d_bcount > dst->d_blk_softlimit) &&
788788
(dst->d_blk_softlimit > 0)) {
789789
ASSERT(dst->d_btimer != 0);
790790
}
791-
if (((int) dst->d_icount > (int) dst->d_ino_softlimit) &&
791+
if ((dst->d_icount > dst->d_ino_softlimit) &&
792792
(dst->d_ino_softlimit > 0)) {
793793
ASSERT(dst->d_itimer != 0);
794794
}

fs/xfs/xfs_trans_buf.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ _xfs_trans_bjoin(
9393
xfs_buf_item_init(bp, tp->t_mountp);
9494
bip = bp->b_fspriv;
9595
ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
96-
ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_CANCEL));
96+
ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_CANCEL));
9797
ASSERT(!(bip->bli_flags & XFS_BLI_LOGGED));
9898
if (reset_recur)
9999
bip->bli_recur = 0;
@@ -432,7 +432,7 @@ xfs_trans_brelse(xfs_trans_t *tp,
432432
bip = bp->b_fspriv;
433433
ASSERT(bip->bli_item.li_type == XFS_LI_BUF);
434434
ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
435-
ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_CANCEL));
435+
ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_CANCEL));
436436
ASSERT(atomic_read(&bip->bli_refcount) > 0);
437437

438438
trace_xfs_trans_brelse(bip);
@@ -519,7 +519,7 @@ xfs_trans_bhold(xfs_trans_t *tp,
519519
ASSERT(bp->b_transp == tp);
520520
ASSERT(bip != NULL);
521521
ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
522-
ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_CANCEL));
522+
ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_CANCEL));
523523
ASSERT(atomic_read(&bip->bli_refcount) > 0);
524524

525525
bip->bli_flags |= XFS_BLI_HOLD;
@@ -539,7 +539,7 @@ xfs_trans_bhold_release(xfs_trans_t *tp,
539539
ASSERT(bp->b_transp == tp);
540540
ASSERT(bip != NULL);
541541
ASSERT(!(bip->bli_flags & XFS_BLI_STALE));
542-
ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_CANCEL));
542+
ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_CANCEL));
543543
ASSERT(atomic_read(&bip->bli_refcount) > 0);
544544
ASSERT(bip->bli_flags & XFS_BLI_HOLD);
545545

@@ -598,7 +598,7 @@ xfs_trans_log_buf(xfs_trans_t *tp,
598598
bip->bli_flags &= ~XFS_BLI_STALE;
599599
ASSERT(XFS_BUF_ISSTALE(bp));
600600
XFS_BUF_UNSTALE(bp);
601-
bip->bli_format.blf_flags &= ~XFS_BLF_CANCEL;
601+
bip->__bli_format.blf_flags &= ~XFS_BLF_CANCEL;
602602
}
603603

604604
tp->t_flags |= XFS_TRANS_DIRTY;
@@ -643,6 +643,7 @@ xfs_trans_binval(
643643
xfs_buf_t *bp)
644644
{
645645
xfs_buf_log_item_t *bip = bp->b_fspriv;
646+
int i;
646647

647648
ASSERT(bp->b_transp == tp);
648649
ASSERT(bip != NULL);
@@ -657,8 +658,8 @@ xfs_trans_binval(
657658
*/
658659
ASSERT(XFS_BUF_ISSTALE(bp));
659660
ASSERT(!(bip->bli_flags & (XFS_BLI_LOGGED | XFS_BLI_DIRTY)));
660-
ASSERT(!(bip->bli_format.blf_flags & XFS_BLF_INODE_BUF));
661-
ASSERT(bip->bli_format.blf_flags & XFS_BLF_CANCEL);
661+
ASSERT(!(bip->__bli_format.blf_flags & XFS_BLF_INODE_BUF));
662+
ASSERT(bip->__bli_format.blf_flags & XFS_BLF_CANCEL);
662663
ASSERT(bip->bli_item.li_desc->lid_flags & XFS_LID_DIRTY);
663664
ASSERT(tp->t_flags & XFS_TRANS_DIRTY);
664665
return;
@@ -668,10 +669,12 @@ xfs_trans_binval(
668669

669670
bip->bli_flags |= XFS_BLI_STALE;
670671
bip->bli_flags &= ~(XFS_BLI_INODE_BUF | XFS_BLI_LOGGED | XFS_BLI_DIRTY);
671-
bip->bli_format.blf_flags &= ~XFS_BLF_INODE_BUF;
672-
bip->bli_format.blf_flags |= XFS_BLF_CANCEL;
673-
memset((char *)(bip->bli_format.blf_data_map), 0,
674-
(bip->bli_format.blf_map_size * sizeof(uint)));
672+
bip->__bli_format.blf_flags &= ~XFS_BLF_INODE_BUF;
673+
bip->__bli_format.blf_flags |= XFS_BLF_CANCEL;
674+
for (i = 0; i < bip->bli_format_count; i++) {
675+
memset(bip->bli_formats[i].blf_data_map, 0,
676+
(bip->bli_formats[i].blf_map_size * sizeof(uint)));
677+
}
675678
bip->bli_item.li_desc->lid_flags |= XFS_LID_DIRTY;
676679
tp->t_flags |= XFS_TRANS_DIRTY;
677680
}
@@ -775,5 +778,5 @@ xfs_trans_dquot_buf(
775778
type == XFS_BLF_GDQUOT_BUF);
776779
ASSERT(atomic_read(&bip->bli_refcount) > 0);
777780

778-
bip->bli_format.blf_flags |= type;
781+
bip->__bli_format.blf_flags |= type;
779782
}

0 commit comments

Comments
 (0)