aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2012-04-23 01:59:07 -0400
committerBen Myers <bpm@sgi.com>2012-05-14 17:21:03 -0400
commit611c99468c7aa1a5c2bb6d46e7b5d8e53eecfefd (patch)
tree809588ac3b7ec796041a435dc512a3f22594be4d /fs
parentd4f3512b0891658b6b4d5fc99567242b3fc2d6b7 (diff)
xfs: make XBF_MAPPED the default behaviour
Rather than specifying XBF_MAPPED for almost all buffers, introduce XBF_UNMAPPED for the couple of users that use unmapped buffers. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_buf.c28
-rw-r--r--fs/xfs/xfs_buf.h4
-rw-r--r--fs/xfs/xfs_fsops.c10
-rw-r--r--fs/xfs/xfs_inode.c1
-rw-r--r--fs/xfs/xfs_log_recover.c4
-rw-r--r--fs/xfs/xfs_trans_buf.c6
-rw-r--r--fs/xfs/xfs_vnodeops.c3
7 files changed, 24 insertions, 32 deletions
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index b2795bab1a01..172d3cc8f8cb 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -65,11 +65,11 @@ xfs_buf_is_vmapped(
65 /* 65 /*
66 * Return true if the buffer is vmapped. 66 * Return true if the buffer is vmapped.
67 * 67 *
68 * The XBF_MAPPED flag is set if the buffer should be mapped, but the 68 * b_addr is null if the buffer is not mapped, but the code is clever
69 * code is clever enough to know it doesn't have to map a single page, 69 * enough to know it doesn't have to map a single page, so the check has
70 * so the check has to be both for XBF_MAPPED and bp->b_page_count > 1. 70 * to be both for b_addr and bp->b_page_count > 1.
71 */ 71 */
72 return (bp->b_flags & XBF_MAPPED) && bp->b_page_count > 1; 72 return bp->b_addr && bp->b_page_count > 1;
73} 73}
74 74
75static inline int 75static inline int
@@ -181,7 +181,7 @@ xfs_buf_alloc(
181 * We don't want certain flags to appear in b_flags unless they are 181 * We don't want certain flags to appear in b_flags unless they are
182 * specifically set by later operations on the buffer. 182 * specifically set by later operations on the buffer.
183 */ 183 */
184 flags &= ~(XBF_MAPPED | XBF_TRYLOCK | XBF_ASYNC | XBF_READ_AHEAD); 184 flags &= ~(XBF_UNMAPPED | XBF_TRYLOCK | XBF_ASYNC | XBF_READ_AHEAD);
185 185
186 atomic_set(&bp->b_hold, 1); 186 atomic_set(&bp->b_hold, 1);
187 atomic_set(&bp->b_lru_ref, 1); 187 atomic_set(&bp->b_lru_ref, 1);
@@ -329,7 +329,7 @@ xfs_buf_allocate_memory(
329 bp->b_pages = bp->b_page_array; 329 bp->b_pages = bp->b_page_array;
330 bp->b_pages[0] = virt_to_page(bp->b_addr); 330 bp->b_pages[0] = virt_to_page(bp->b_addr);
331 bp->b_page_count = 1; 331 bp->b_page_count = 1;
332 bp->b_flags |= XBF_MAPPED | _XBF_KMEM; 332 bp->b_flags |= _XBF_KMEM;
333 return 0; 333 return 0;
334 } 334 }
335 335
@@ -399,8 +399,9 @@ _xfs_buf_map_pages(
399 if (bp->b_page_count == 1) { 399 if (bp->b_page_count == 1) {
400 /* A single page buffer is always mappable */ 400 /* A single page buffer is always mappable */
401 bp->b_addr = page_address(bp->b_pages[0]) + bp->b_offset; 401 bp->b_addr = page_address(bp->b_pages[0]) + bp->b_offset;
402 bp->b_flags |= XBF_MAPPED; 402 } else if (flags & XBF_UNMAPPED) {
403 } else if (flags & XBF_MAPPED) { 403 bp->b_addr = NULL;
404 } else {
404 int retried = 0; 405 int retried = 0;
405 406
406 do { 407 do {
@@ -414,7 +415,6 @@ _xfs_buf_map_pages(
414 if (!bp->b_addr) 415 if (!bp->b_addr)
415 return -ENOMEM; 416 return -ENOMEM;
416 bp->b_addr += bp->b_offset; 417 bp->b_addr += bp->b_offset;
417 bp->b_flags |= XBF_MAPPED;
418 } 418 }
419 419
420 return 0; 420 return 0;
@@ -520,7 +520,7 @@ found:
520 */ 520 */
521 if (bp->b_flags & XBF_STALE) { 521 if (bp->b_flags & XBF_STALE) {
522 ASSERT((bp->b_flags & _XBF_DELWRI_Q) == 0); 522 ASSERT((bp->b_flags & _XBF_DELWRI_Q) == 0);
523 bp->b_flags &= XBF_MAPPED | _XBF_KMEM | _XBF_PAGES; 523 bp->b_flags &= _XBF_KMEM | _XBF_PAGES;
524 } 524 }
525 525
526 trace_xfs_buf_find(bp, flags, _RET_IP_); 526 trace_xfs_buf_find(bp, flags, _RET_IP_);
@@ -575,7 +575,7 @@ xfs_buf_get(
575 bp->b_io_length = bp->b_length; 575 bp->b_io_length = bp->b_length;
576 576
577found: 577found:
578 if (!(bp->b_flags & XBF_MAPPED)) { 578 if (!bp->b_addr) {
579 error = _xfs_buf_map_pages(bp, flags); 579 error = _xfs_buf_map_pages(bp, flags);
580 if (unlikely(error)) { 580 if (unlikely(error)) {
581 xfs_warn(target->bt_mount, 581 xfs_warn(target->bt_mount,
@@ -707,7 +707,6 @@ xfs_buf_set_empty(
707 bp->b_length = numblks; 707 bp->b_length = numblks;
708 bp->b_io_length = numblks; 708 bp->b_io_length = numblks;
709 bp->b_bn = XFS_BUF_DADDR_NULL; 709 bp->b_bn = XFS_BUF_DADDR_NULL;
710 bp->b_flags &= ~XBF_MAPPED;
711} 710}
712 711
713static inline struct page * 712static inline struct page *
@@ -759,7 +758,6 @@ xfs_buf_associate_memory(
759 758
760 bp->b_io_length = BTOBB(len); 759 bp->b_io_length = BTOBB(len);
761 bp->b_length = BTOBB(buflen); 760 bp->b_length = BTOBB(buflen);
762 bp->b_flags |= XBF_MAPPED;
763 761
764 return 0; 762 return 0;
765} 763}
@@ -790,7 +788,7 @@ xfs_buf_get_uncached(
790 } 788 }
791 bp->b_flags |= _XBF_PAGES; 789 bp->b_flags |= _XBF_PAGES;
792 790
793 error = _xfs_buf_map_pages(bp, XBF_MAPPED); 791 error = _xfs_buf_map_pages(bp, 0);
794 if (unlikely(error)) { 792 if (unlikely(error)) {
795 xfs_warn(target->bt_mount, 793 xfs_warn(target->bt_mount,
796 "%s: failed to map pages\n", __func__); 794 "%s: failed to map pages\n", __func__);
@@ -1287,7 +1285,7 @@ xfs_buf_offset(
1287{ 1285{
1288 struct page *page; 1286 struct page *page;
1289 1287
1290 if (bp->b_flags & XBF_MAPPED) 1288 if (bp->b_addr)
1291 return bp->b_addr + offset; 1289 return bp->b_addr + offset;
1292 1290
1293 offset += bp->b_offset; 1291 offset += bp->b_offset;
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
index 846dee3d8dac..7f1d1392ce37 100644
--- a/fs/xfs/xfs_buf.h
+++ b/fs/xfs/xfs_buf.h
@@ -41,7 +41,6 @@ typedef enum {
41#define XBF_READ (1 << 0) /* buffer intended for reading from device */ 41#define XBF_READ (1 << 0) /* buffer intended for reading from device */
42#define XBF_WRITE (1 << 1) /* buffer intended for writing to device */ 42#define XBF_WRITE (1 << 1) /* buffer intended for writing to device */
43#define XBF_READ_AHEAD (1 << 2) /* asynchronous read-ahead */ 43#define XBF_READ_AHEAD (1 << 2) /* asynchronous read-ahead */
44#define XBF_MAPPED (1 << 3) /* buffer mapped (b_addr valid) */
45#define XBF_ASYNC (1 << 4) /* initiator will not wait for completion */ 44#define XBF_ASYNC (1 << 4) /* initiator will not wait for completion */
46#define XBF_DONE (1 << 5) /* all pages in the buffer uptodate */ 45#define XBF_DONE (1 << 5) /* all pages in the buffer uptodate */
47#define XBF_STALE (1 << 6) /* buffer has been staled, do not find it */ 46#define XBF_STALE (1 << 6) /* buffer has been staled, do not find it */
@@ -53,6 +52,7 @@ typedef enum {
53 52
54/* flags used only as arguments to access routines */ 53/* flags used only as arguments to access routines */
55#define XBF_TRYLOCK (1 << 16)/* lock requested, but do not wait */ 54#define XBF_TRYLOCK (1 << 16)/* lock requested, but do not wait */
55#define XBF_UNMAPPED (1 << 17)/* do not map the buffer */
56 56
57/* flags used only internally */ 57/* flags used only internally */
58#define _XBF_PAGES (1 << 20)/* backed by refcounted pages */ 58#define _XBF_PAGES (1 << 20)/* backed by refcounted pages */
@@ -65,7 +65,6 @@ typedef unsigned int xfs_buf_flags_t;
65 { XBF_READ, "READ" }, \ 65 { XBF_READ, "READ" }, \
66 { XBF_WRITE, "WRITE" }, \ 66 { XBF_WRITE, "WRITE" }, \
67 { XBF_READ_AHEAD, "READ_AHEAD" }, \ 67 { XBF_READ_AHEAD, "READ_AHEAD" }, \
68 { XBF_MAPPED, "MAPPED" }, \
69 { XBF_ASYNC, "ASYNC" }, \ 68 { XBF_ASYNC, "ASYNC" }, \
70 { XBF_DONE, "DONE" }, \ 69 { XBF_DONE, "DONE" }, \
71 { XBF_STALE, "STALE" }, \ 70 { XBF_STALE, "STALE" }, \
@@ -73,6 +72,7 @@ typedef unsigned int xfs_buf_flags_t;
73 { XBF_FUA, "FUA" }, \ 72 { XBF_FUA, "FUA" }, \
74 { XBF_FLUSH, "FLUSH" }, \ 73 { XBF_FLUSH, "FLUSH" }, \
75 { XBF_TRYLOCK, "TRYLOCK" }, /* should never be set */\ 74 { XBF_TRYLOCK, "TRYLOCK" }, /* should never be set */\
75 { XBF_UNMAPPED, "UNMAPPED" }, /* ditto */\
76 { _XBF_PAGES, "PAGES" }, \ 76 { _XBF_PAGES, "PAGES" }, \
77 { _XBF_KMEM, "KMEM" }, \ 77 { _XBF_KMEM, "KMEM" }, \
78 { _XBF_DELWRI_Q, "DELWRI_Q" } 78 { _XBF_DELWRI_Q, "DELWRI_Q" }
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 75593d9bd70f..c25b094efbf7 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -190,7 +190,7 @@ xfs_growfs_data_private(
190 */ 190 */
191 bp = xfs_buf_get(mp->m_ddev_targp, 191 bp = xfs_buf_get(mp->m_ddev_targp,
192 XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)), 192 XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
193 XFS_FSS_TO_BB(mp, 1), XBF_MAPPED); 193 XFS_FSS_TO_BB(mp, 1), 0);
194 if (!bp) { 194 if (!bp) {
195 error = ENOMEM; 195 error = ENOMEM;
196 goto error0; 196 goto error0;
@@ -227,7 +227,7 @@ xfs_growfs_data_private(
227 */ 227 */
228 bp = xfs_buf_get(mp->m_ddev_targp, 228 bp = xfs_buf_get(mp->m_ddev_targp,
229 XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)), 229 XFS_AG_DADDR(mp, agno, XFS_AGI_DADDR(mp)),
230 XFS_FSS_TO_BB(mp, 1), XBF_MAPPED); 230 XFS_FSS_TO_BB(mp, 1), 0);
231 if (!bp) { 231 if (!bp) {
232 error = ENOMEM; 232 error = ENOMEM;
233 goto error0; 233 goto error0;
@@ -256,7 +256,7 @@ xfs_growfs_data_private(
256 */ 256 */
257 bp = xfs_buf_get(mp->m_ddev_targp, 257 bp = xfs_buf_get(mp->m_ddev_targp,
258 XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)), 258 XFS_AGB_TO_DADDR(mp, agno, XFS_BNO_BLOCK(mp)),
259 BTOBB(mp->m_sb.sb_blocksize), XBF_MAPPED); 259 BTOBB(mp->m_sb.sb_blocksize), 0);
260 if (!bp) { 260 if (!bp) {
261 error = ENOMEM; 261 error = ENOMEM;
262 goto error0; 262 goto error0;
@@ -282,7 +282,7 @@ xfs_growfs_data_private(
282 */ 282 */
283 bp = xfs_buf_get(mp->m_ddev_targp, 283 bp = xfs_buf_get(mp->m_ddev_targp,
284 XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)), 284 XFS_AGB_TO_DADDR(mp, agno, XFS_CNT_BLOCK(mp)),
285 BTOBB(mp->m_sb.sb_blocksize), XBF_MAPPED); 285 BTOBB(mp->m_sb.sb_blocksize), 0);
286 if (!bp) { 286 if (!bp) {
287 error = ENOMEM; 287 error = ENOMEM;
288 goto error0; 288 goto error0;
@@ -309,7 +309,7 @@ xfs_growfs_data_private(
309 */ 309 */
310 bp = xfs_buf_get(mp->m_ddev_targp, 310 bp = xfs_buf_get(mp->m_ddev_targp,
311 XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)), 311 XFS_AGB_TO_DADDR(mp, agno, XFS_IBT_BLOCK(mp)),
312 BTOBB(mp->m_sb.sb_blocksize), XBF_MAPPED); 312 BTOBB(mp->m_sb.sb_blocksize), 0);
313 if (!bp) { 313 if (!bp) {
314 error = ENOMEM; 314 error = ENOMEM;
315 goto error0; 315 goto error0;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 72ec1a4cc477..a59eea09930a 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -150,6 +150,7 @@ xfs_imap_to_bp(
150 int ni; 150 int ni;
151 xfs_buf_t *bp; 151 xfs_buf_t *bp;
152 152
153 buf_flags |= XBF_UNMAPPED;
153 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno, 154 error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno,
154 (int)imap->im_len, buf_flags, &bp); 155 (int)imap->im_len, buf_flags, &bp);
155 if (error) { 156 if (error) {
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 472fa1749bee..ca386909131a 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2131,8 +2131,8 @@ xlog_recover_buffer_pass2(
2131 trace_xfs_log_recover_buf_recover(log, buf_f); 2131 trace_xfs_log_recover_buf_recover(log, buf_f);
2132 2132
2133 buf_flags = 0; 2133 buf_flags = 0;
2134 if (!(buf_f->blf_flags & XFS_BLF_INODE_BUF)) 2134 if (buf_f->blf_flags & XFS_BLF_INODE_BUF)
2135 buf_flags |= XBF_MAPPED; 2135 buf_flags |= XBF_UNMAPPED;
2136 2136
2137 bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len, 2137 bp = xfs_buf_read(mp->m_ddev_targp, buf_f->blf_blkno, buf_f->blf_len,
2138 buf_flags); 2138 buf_flags);
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c
index d250afaeb70c..21c5a5e3700d 100644
--- a/fs/xfs/xfs_trans_buf.c
+++ b/fs/xfs/xfs_trans_buf.c
@@ -138,9 +138,6 @@ xfs_trans_get_buf(xfs_trans_t *tp,
138 xfs_buf_t *bp; 138 xfs_buf_t *bp;
139 xfs_buf_log_item_t *bip; 139 xfs_buf_log_item_t *bip;
140 140
141 if (flags == 0)
142 flags = XBF_MAPPED;
143
144 /* 141 /*
145 * Default to a normal get_buf() call if the tp is NULL. 142 * Default to a normal get_buf() call if the tp is NULL.
146 */ 143 */
@@ -264,9 +261,6 @@ xfs_trans_read_buf(
264 261
265 *bpp = NULL; 262 *bpp = NULL;
266 263
267 if (flags == 0)
268 flags = XBF_MAPPED;
269
270 /* 264 /*
271 * Default to a normal get_buf() call if the tp is NULL. 265 * Default to a normal get_buf() call if the tp is NULL.
272 */ 266 */
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 5b3f5b13a008..82b000f8ad2f 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -79,8 +79,7 @@ xfs_readlink_bmap(
79 d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock); 79 d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock);
80 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount); 80 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
81 81
82 bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 82 bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 0);
83 XBF_MAPPED);
84 if (!bp) 83 if (!bp)
85 return XFS_ERROR(ENOMEM); 84 return XFS_ERROR(ENOMEM);
86 error = bp->b_error; 85 error = bp->b_error;