aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <david@fromorbit.com>2014-06-09 17:32:56 -0400
committerDave Chinner <david@fromorbit.com>2014-06-09 17:32:56 -0400
commit7691283d0561a350b7517be94818669fb5e3d910 (patch)
tree3b939ee86e763c22c6ead988bf62de58e1981915
parent8612c7e594808e4a67bc2d4661f5925df2be3f51 (diff)
parent30265117ee1e23fa91920f337a3ea91207f700dc (diff)
Merge branch 'xfs-misc-fixes-3-for-3.16' into for-next
-rw-r--r--fs/xfs/xfs_alloc.c19
-rw-r--r--fs/xfs/xfs_aops.c6
-rw-r--r--fs/xfs/xfs_bit.h7
-rw-r--r--fs/xfs/xfs_bmap_util.c16
-rw-r--r--fs/xfs/xfs_bmap_util.h13
-rw-r--r--fs/xfs/xfs_btree.c12
-rw-r--r--fs/xfs/xfs_buf.h5
-rw-r--r--fs/xfs/xfs_buf_item.c2
-rw-r--r--fs/xfs/xfs_dquot.c6
-rw-r--r--fs/xfs/xfs_ialloc.c1
-rw-r--r--fs/xfs/xfs_log.c2
-rw-r--r--fs/xfs/xfs_mount.c23
-rw-r--r--fs/xfs/xfs_rtbitmap.c1
13 files changed, 60 insertions, 53 deletions
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index c1cf6a336a72..d43813267a80 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -257,16 +257,14 @@ xfs_alloc_fix_len(
257 k = rlen % args->prod; 257 k = rlen % args->prod;
258 if (k == args->mod) 258 if (k == args->mod)
259 return; 259 return;
260 if (k > args->mod) { 260 if (k > args->mod)
261 if ((int)(rlen = rlen - k - args->mod) < (int)args->minlen) 261 rlen = rlen - (k - args->mod);
262 return; 262 else
263 } else { 263 rlen = rlen - args->prod + (args->mod - k);
264 if ((int)(rlen = rlen - args->prod - (args->mod - k)) < 264 if ((int)rlen < (int)args->minlen)
265 (int)args->minlen) 265 return;
266 return; 266 ASSERT(rlen >= args->minlen && rlen <= args->maxlen);
267 } 267 ASSERT(rlen % args->prod == args->mod);
268 ASSERT(rlen >= args->minlen);
269 ASSERT(rlen <= args->maxlen);
270 args->len = rlen; 268 args->len = rlen;
271} 269}
272 270
@@ -541,7 +539,6 @@ xfs_alloc_read_agfl(
541 XFS_FSS_TO_BB(mp, 1), 0, &bp, &xfs_agfl_buf_ops); 539 XFS_FSS_TO_BB(mp, 1), 0, &bp, &xfs_agfl_buf_ops);
542 if (error) 540 if (error)
543 return error; 541 return error;
544 ASSERT(!xfs_buf_geterror(bp));
545 xfs_buf_set_ref(bp, XFS_AGFL_REF); 542 xfs_buf_set_ref(bp, XFS_AGFL_REF);
546 *bpp = bp; 543 *bpp = bp;
547 return 0; 544 return 0;
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index d1b99b692ccb..e32640eedea6 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -975,7 +975,7 @@ xfs_vm_writepage(
975 * Given that we do not allow direct reclaim to call us, we should 975 * Given that we do not allow direct reclaim to call us, we should
976 * never be called while in a filesystem transaction. 976 * never be called while in a filesystem transaction.
977 */ 977 */
978 if (WARN_ON(current->flags & PF_FSTRANS)) 978 if (WARN_ON_ONCE(current->flags & PF_FSTRANS))
979 goto redirty; 979 goto redirty;
980 980
981 /* Is this page beyond the end of the file? */ 981 /* Is this page beyond the end of the file? */
@@ -1225,9 +1225,9 @@ xfs_vm_releasepage(
1225 1225
1226 xfs_count_page_state(page, &delalloc, &unwritten); 1226 xfs_count_page_state(page, &delalloc, &unwritten);
1227 1227
1228 if (WARN_ON(delalloc)) 1228 if (WARN_ON_ONCE(delalloc))
1229 return 0; 1229 return 0;
1230 if (WARN_ON(unwritten)) 1230 if (WARN_ON_ONCE(unwritten))
1231 return 0; 1231 return 0;
1232 1232
1233 return try_to_free_buffers(page); 1233 return try_to_free_buffers(page);
diff --git a/fs/xfs/xfs_bit.h b/fs/xfs/xfs_bit.h
index f1e3c907044d..e1649c0d3e02 100644
--- a/fs/xfs/xfs_bit.h
+++ b/fs/xfs/xfs_bit.h
@@ -66,8 +66,11 @@ static inline int xfs_lowbit64(__uint64_t v)
66 n = ffs(w); 66 n = ffs(w);
67 } else { /* upper bits */ 67 } else { /* upper bits */
68 w = (__uint32_t)(v >> 32); 68 w = (__uint32_t)(v >> 32);
69 if (w && (n = ffs(w))) 69 if (w) {
70 n += 32; 70 n = ffs(w);
71 if (n)
72 n += 32;
73 }
71 } 74 }
72 return n - 1; 75 return n - 1;
73} 76}
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 057f671811d6..703b3ec1796c 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -258,14 +258,23 @@ xfs_bmapi_allocate_worker(
258 struct xfs_bmalloca *args = container_of(work, 258 struct xfs_bmalloca *args = container_of(work,
259 struct xfs_bmalloca, work); 259 struct xfs_bmalloca, work);
260 unsigned long pflags; 260 unsigned long pflags;
261 unsigned long new_pflags = PF_FSTRANS;
261 262
262 /* we are in a transaction context here */ 263 /*
263 current_set_flags_nested(&pflags, PF_FSTRANS); 264 * we are in a transaction context here, but may also be doing work
265 * in kswapd context, and hence we may need to inherit that state
266 * temporarily to ensure that we don't block waiting for memory reclaim
267 * in any way.
268 */
269 if (args->kswapd)
270 new_pflags |= PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD;
271
272 current_set_flags_nested(&pflags, new_pflags);
264 273
265 args->result = __xfs_bmapi_allocate(args); 274 args->result = __xfs_bmapi_allocate(args);
266 complete(args->done); 275 complete(args->done);
267 276
268 current_restore_flags_nested(&pflags, PF_FSTRANS); 277 current_restore_flags_nested(&pflags, new_pflags);
269} 278}
270 279
271/* 280/*
@@ -284,6 +293,7 @@ xfs_bmapi_allocate(
284 293
285 294
286 args->done = &done; 295 args->done = &done;
296 args->kswapd = current_is_kswapd();
287 INIT_WORK_ONSTACK(&args->work, xfs_bmapi_allocate_worker); 297 INIT_WORK_ONSTACK(&args->work, xfs_bmapi_allocate_worker);
288 queue_work(xfs_alloc_wq, &args->work); 298 queue_work(xfs_alloc_wq, &args->work);
289 wait_for_completion(&done); 299 wait_for_completion(&done);
diff --git a/fs/xfs/xfs_bmap_util.h b/fs/xfs/xfs_bmap_util.h
index 935ed2b24edf..075f72232a64 100644
--- a/fs/xfs/xfs_bmap_util.h
+++ b/fs/xfs/xfs_bmap_util.h
@@ -50,12 +50,13 @@ struct xfs_bmalloca {
50 xfs_extlen_t total; /* total blocks needed for xaction */ 50 xfs_extlen_t total; /* total blocks needed for xaction */
51 xfs_extlen_t minlen; /* minimum allocation size (blocks) */ 51 xfs_extlen_t minlen; /* minimum allocation size (blocks) */
52 xfs_extlen_t minleft; /* amount must be left after alloc */ 52 xfs_extlen_t minleft; /* amount must be left after alloc */
53 char eof; /* set if allocating past last extent */ 53 bool eof; /* set if allocating past last extent */
54 char wasdel; /* replacing a delayed allocation */ 54 bool wasdel; /* replacing a delayed allocation */
55 char userdata;/* set if is user data */ 55 bool userdata;/* set if is user data */
56 char aeof; /* allocated space at eof */ 56 bool aeof; /* allocated space at eof */
57 char conv; /* overwriting unwritten extents */ 57 bool conv; /* overwriting unwritten extents */
58 char stack_switch; 58 bool stack_switch;
59 bool kswapd; /* allocation in kswapd context */
59 int flags; 60 int flags;
60 struct completion *done; 61 struct completion *done;
61 struct work_struct work; 62 struct work_struct work;
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index 182bac2bb276..bf810c6baf2b 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -553,14 +553,11 @@ xfs_btree_get_bufl(
553 xfs_fsblock_t fsbno, /* file system block number */ 553 xfs_fsblock_t fsbno, /* file system block number */
554 uint lock) /* lock flags for get_buf */ 554 uint lock) /* lock flags for get_buf */
555{ 555{
556 xfs_buf_t *bp; /* buffer pointer (return value) */
557 xfs_daddr_t d; /* real disk block address */ 556 xfs_daddr_t d; /* real disk block address */
558 557
559 ASSERT(fsbno != NULLFSBLOCK); 558 ASSERT(fsbno != NULLFSBLOCK);
560 d = XFS_FSB_TO_DADDR(mp, fsbno); 559 d = XFS_FSB_TO_DADDR(mp, fsbno);
561 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock); 560 return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
562 ASSERT(!xfs_buf_geterror(bp));
563 return bp;
564} 561}
565 562
566/* 563/*
@@ -575,15 +572,12 @@ xfs_btree_get_bufs(
575 xfs_agblock_t agbno, /* allocation group block number */ 572 xfs_agblock_t agbno, /* allocation group block number */
576 uint lock) /* lock flags for get_buf */ 573 uint lock) /* lock flags for get_buf */
577{ 574{
578 xfs_buf_t *bp; /* buffer pointer (return value) */
579 xfs_daddr_t d; /* real disk block address */ 575 xfs_daddr_t d; /* real disk block address */
580 576
581 ASSERT(agno != NULLAGNUMBER); 577 ASSERT(agno != NULLAGNUMBER);
582 ASSERT(agbno != NULLAGBLOCK); 578 ASSERT(agbno != NULLAGBLOCK);
583 d = XFS_AGB_TO_DADDR(mp, agno, agbno); 579 d = XFS_AGB_TO_DADDR(mp, agno, agbno);
584 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock); 580 return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
585 ASSERT(!xfs_buf_geterror(bp));
586 return bp;
587} 581}
588 582
589/* 583/*
@@ -723,7 +717,6 @@ xfs_btree_read_bufl(
723 mp->m_bsize, lock, &bp, ops); 717 mp->m_bsize, lock, &bp, ops);
724 if (error) 718 if (error)
725 return error; 719 return error;
726 ASSERT(!xfs_buf_geterror(bp));
727 if (bp) 720 if (bp)
728 xfs_buf_set_ref(bp, refval); 721 xfs_buf_set_ref(bp, refval);
729 *bpp = bp; 722 *bpp = bp;
@@ -1179,7 +1172,6 @@ xfs_btree_read_buf_block(
1179 if (error) 1172 if (error)
1180 return error; 1173 return error;
1181 1174
1182 ASSERT(!xfs_buf_geterror(*bpp));
1183 xfs_btree_set_refs(cur, *bpp); 1175 xfs_btree_set_refs(cur, *bpp);
1184 *block = XFS_BUF_TO_BLOCK(*bpp); 1176 *block = XFS_BUF_TO_BLOCK(*bpp);
1185 return 0; 1177 return 0;
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 0e47fd1fedba..3a7a5523d3dc 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -298,11 +298,6 @@ extern void xfs_buf_iomove(xfs_buf_t *, size_t, size_t, void *,
298 298
299extern int xfs_bioerror_relse(struct xfs_buf *); 299extern int xfs_bioerror_relse(struct xfs_buf *);
300 300
301static inline int xfs_buf_geterror(xfs_buf_t *bp)
302{
303 return bp ? bp->b_error : ENOMEM;
304}
305
306/* Buffer Utility Routines */ 301/* Buffer Utility Routines */
307extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t); 302extern xfs_caddr_t xfs_buf_offset(xfs_buf_t *, size_t);
308 303
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 64b17f5bed9a..4654338b03fc 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -1052,7 +1052,7 @@ xfs_buf_iodone_callbacks(
1052 static ulong lasttime; 1052 static ulong lasttime;
1053 static xfs_buftarg_t *lasttarg; 1053 static xfs_buftarg_t *lasttarg;
1054 1054
1055 if (likely(!xfs_buf_geterror(bp))) 1055 if (likely(!bp->b_error))
1056 goto do_callbacks; 1056 goto do_callbacks;
1057 1057
1058 /* 1058 /*
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index 5fec738f1f2e..3ee0cd43edc0 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -353,10 +353,10 @@ xfs_qm_dqalloc(
353 dqp->q_blkno, 353 dqp->q_blkno,
354 mp->m_quotainfo->qi_dqchunklen, 354 mp->m_quotainfo->qi_dqchunklen,
355 0); 355 0);
356 356 if (!bp) {
357 error = xfs_buf_geterror(bp); 357 error = ENOMEM;
358 if (error)
359 goto error1; 358 goto error1;
359 }
360 bp->b_ops = &xfs_dquot_buf_ops; 360 bp->b_ops = &xfs_dquot_buf_ops;
361 361
362 /* 362 /*
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c
index e8dfaf039232..5960e5593fe0 100644
--- a/fs/xfs/xfs_ialloc.c
+++ b/fs/xfs/xfs_ialloc.c
@@ -2129,7 +2129,6 @@ xfs_read_agi(
2129 if (error) 2129 if (error)
2130 return error; 2130 return error;
2131 2131
2132 ASSERT(!xfs_buf_geterror(*bpp));
2133 xfs_buf_set_ref(*bpp, XFS_AGI_REF); 2132 xfs_buf_set_ref(*bpp, XFS_AGI_REF);
2134 return 0; 2133 return 0;
2135} 2134}
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 3554098692d8..292308dede6d 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1165,7 +1165,7 @@ xlog_iodone(xfs_buf_t *bp)
1165 /* 1165 /*
1166 * Race to shutdown the filesystem if we see an error. 1166 * Race to shutdown the filesystem if we see an error.
1167 */ 1167 */
1168 if (XFS_TEST_ERROR((xfs_buf_geterror(bp)), l->l_mp, 1168 if (XFS_TEST_ERROR(bp->b_error, l->l_mp,
1169 XFS_ERRTAG_IODONE_IOERR, XFS_RANDOM_IODONE_IOERR)) { 1169 XFS_ERRTAG_IODONE_IOERR, XFS_RANDOM_IODONE_IOERR)) {
1170 xfs_buf_ioerror_alert(bp, __func__); 1170 xfs_buf_ioerror_alert(bp, __func__);
1171 xfs_buf_stale(bp); 1171 xfs_buf_stale(bp);
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 03c9d645865c..3507cd0ec400 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -323,8 +323,19 @@ reread:
323 /* 323 /*
324 * Initialize the mount structure from the superblock. 324 * Initialize the mount structure from the superblock.
325 */ 325 */
326 xfs_sb_from_disk(&mp->m_sb, XFS_BUF_TO_SBP(bp)); 326 xfs_sb_from_disk(sbp, XFS_BUF_TO_SBP(bp));
327 xfs_sb_quota_from_disk(&mp->m_sb); 327 xfs_sb_quota_from_disk(sbp);
328
329 /*
330 * If we haven't validated the superblock, do so now before we try
331 * to check the sector size and reread the superblock appropriately.
332 */
333 if (sbp->sb_magicnum != XFS_SB_MAGIC) {
334 if (loud)
335 xfs_warn(mp, "Invalid superblock magic number");
336 error = EINVAL;
337 goto release_buf;
338 }
328 339
329 /* 340 /*
330 * We must be able to do sector-sized and sector-aligned IO. 341 * We must be able to do sector-sized and sector-aligned IO.
@@ -337,11 +348,11 @@ reread:
337 goto release_buf; 348 goto release_buf;
338 } 349 }
339 350
340 /*
341 * Re-read the superblock so the buffer is correctly sized,
342 * and properly verified.
343 */
344 if (buf_ops == NULL) { 351 if (buf_ops == NULL) {
352 /*
353 * Re-read the superblock so the buffer is correctly sized,
354 * and properly verified.
355 */
345 xfs_buf_relse(bp); 356 xfs_buf_relse(bp);
346 sector_size = sbp->sb_sectsize; 357 sector_size = sbp->sb_sectsize;
347 buf_ops = loud ? &xfs_sb_buf_ops : &xfs_sb_quiet_buf_ops; 358 buf_ops = loud ? &xfs_sb_buf_ops : &xfs_sb_quiet_buf_ops;
diff --git a/fs/xfs/xfs_rtbitmap.c b/fs/xfs/xfs_rtbitmap.c
index b1f2fe8af4a8..f4dd697cac08 100644
--- a/fs/xfs/xfs_rtbitmap.c
+++ b/fs/xfs/xfs_rtbitmap.c
@@ -74,7 +74,6 @@ xfs_rtbuf_get(
74 mp->m_bsize, 0, &bp, NULL); 74 mp->m_bsize, 0, &bp, NULL);
75 if (error) 75 if (error)
76 return error; 76 return error;
77 ASSERT(!xfs_buf_geterror(bp));
78 *bpp = bp; 77 *bpp = bp;
79 return 0; 78 return 0;
80} 79}