* [PATCH v2] xfs: Fix overallocation in xfs_buf_allocate_memory()
@ 2012-06-05 22:32 Jan Kara
2012-06-20 6:39 ` Christoph Hellwig
2012-06-20 6:41 ` Dave Chinner
0 siblings, 2 replies; 3+ messages in thread
From: Jan Kara @ 2012-06-05 22:32 UTC (permalink / raw)
To: xfs; +Cc: Ben Myers, Alex Elder, Jan Kara, David Chinner
Commit de1cbee which removed b_file_offset in favor of b_bn introduced a bug
causing xfs_buf_allocate_memory() to overestimate the number of necessary
pages. The problem is that xfs_buf_alloc() sets b_bn to -1 and thus effectively
every buffer is straddling a page boundary which causes
xfs_buf_allocate_memory() to allocate two pages and use vmalloc() for access
which is unnecessary.
Dave says xfs_buf_alloc() doesn't need to set b_bn to -1 anymore since the
buffer is inserted into the cache only after being fully initialized now.
So just make xfs_buf_alloc() fill in proper block number from the beginning.
CC: David Chinner <dchinner@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/xfs/xfs_buf.c | 16 ++--------------
1 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 172d3cc..a4beb42 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -201,14 +201,7 @@ xfs_buf_alloc(
bp->b_length = numblks;
bp->b_io_length = numblks;
bp->b_flags = flags;
-
- /*
- * We do not set the block number here in the buffer because we have not
- * finished initialising the buffer. We insert the buffer into the cache
- * in this state, so this ensures that we are unable to do IO on a
- * buffer that hasn't been fully initialised.
- */
- bp->b_bn = XFS_BUF_DADDR_NULL;
+ bp->b_bn = blkno;
atomic_set(&bp->b_pin_count, 0);
init_waitqueue_head(&bp->b_waiters);
@@ -567,11 +560,6 @@ xfs_buf_get(
if (bp != new_bp)
xfs_buf_free(new_bp);
- /*
- * Now we have a workable buffer, fill in the block number so
- * that we can do IO on it.
- */
- bp->b_bn = blkno;
bp->b_io_length = bp->b_length;
found:
@@ -772,7 +760,7 @@ xfs_buf_get_uncached(
int error, i;
xfs_buf_t *bp;
- bp = xfs_buf_alloc(target, 0, numblks, 0);
+ bp = xfs_buf_alloc(target, XFS_BUF_DADDR_NULL, numblks, 0);
if (unlikely(bp == NULL))
goto fail;
--
1.7.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] xfs: Fix overallocation in xfs_buf_allocate_memory()
2012-06-05 22:32 [PATCH v2] xfs: Fix overallocation in xfs_buf_allocate_memory() Jan Kara
@ 2012-06-20 6:39 ` Christoph Hellwig
2012-06-20 6:41 ` Dave Chinner
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2012-06-20 6:39 UTC (permalink / raw)
To: Jan Kara; +Cc: Ben Myers, Alex Elder, David Chinner, xfs
On Wed, Jun 06, 2012 at 12:32:26AM +0200, Jan Kara wrote:
> Commit de1cbee which removed b_file_offset in favor of b_bn introduced a bug
> causing xfs_buf_allocate_memory() to overestimate the number of necessary
> pages. The problem is that xfs_buf_alloc() sets b_bn to -1 and thus effectively
> every buffer is straddling a page boundary which causes
> xfs_buf_allocate_memory() to allocate two pages and use vmalloc() for access
> which is unnecessary.
>
> Dave says xfs_buf_alloc() doesn't need to set b_bn to -1 anymore since the
> buffer is inserted into the cache only after being fully initialized now.
> So just make xfs_buf_alloc() fill in proper block number from the beginning.
Looks good. The b_io_length initialization in xfs_buf_get can also be
removed, but as that's a cosmetic change it can way for 3.6.
Reviewed-by: Christoph Hellwig <hch@lst.de>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] xfs: Fix overallocation in xfs_buf_allocate_memory()
2012-06-05 22:32 [PATCH v2] xfs: Fix overallocation in xfs_buf_allocate_memory() Jan Kara
2012-06-20 6:39 ` Christoph Hellwig
@ 2012-06-20 6:41 ` Dave Chinner
1 sibling, 0 replies; 3+ messages in thread
From: Dave Chinner @ 2012-06-20 6:41 UTC (permalink / raw)
To: Jan Kara; +Cc: Ben Myers, Alex Elder, David Chinner, xfs
On Wed, Jun 06, 2012 at 12:32:26AM +0200, Jan Kara wrote:
> Commit de1cbee which removed b_file_offset in favor of b_bn introduced a bug
> causing xfs_buf_allocate_memory() to overestimate the number of necessary
> pages. The problem is that xfs_buf_alloc() sets b_bn to -1 and thus effectively
> every buffer is straddling a page boundary which causes
> xfs_buf_allocate_memory() to allocate two pages and use vmalloc() for access
> which is unnecessary.
>
> Dave says xfs_buf_alloc() doesn't need to set b_bn to -1 anymore since the
> buffer is inserted into the cache only after being fully initialized now.
> So just make xfs_buf_alloc() fill in proper block number from the beginning.
>
> CC: David Chinner <dchinner@redhat.com>
> Signed-off-by: Jan Kara <jack@suse.cz>
Hmmm, the
Reviewed-by: Dave Chinner <dchinner@redhat.com>
I sent yesterday doesn't appear to have made it to the list. Oh
well, try again...
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-06-20 6:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-05 22:32 [PATCH v2] xfs: Fix overallocation in xfs_buf_allocate_memory() Jan Kara
2012-06-20 6:39 ` Christoph Hellwig
2012-06-20 6:41 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox