Skip to content

Commit

Permalink
[XFS] kill superflous buffer locking (2nd attempt)
Browse files Browse the repository at this point in the history
There is no need to lock any page in xfs_buf.c because we operate on our
own address_space and all locking is covered by the buffer semaphore. If
we ever switch back to main blockdeive address_space as suggested e.g. for
fsblock with a similar scheme the locking will have to be totally revised
anyway because the current scheme is neither correct nor coherent with
itself.

SGI-PV: 971186
SGI-Modid: xfs-linux-melb:xfs-kern:30156a

Signed-off-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
  • Loading branch information
Christoph Hellwig authored and Lachlan McIlroy committed Feb 7, 2008
1 parent 40ebd81 commit a9759f2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 51 deletions.
55 changes: 5 additions & 50 deletions fs/xfs/linux-2.6/xfs_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,6 @@ _xfs_buf_lookup_pages(
if (unlikely(page == NULL)) {
if (flags & XBF_READ_AHEAD) {
bp->b_page_count = i;
for (i = 0; i < bp->b_page_count; i++)
unlock_page(bp->b_pages[i]);
return -ENOMEM;
}

Expand Down Expand Up @@ -418,24 +416,17 @@ _xfs_buf_lookup_pages(
ASSERT(!PagePrivate(page));
if (!PageUptodate(page)) {
page_count--;
if (blocksize >= PAGE_CACHE_SIZE) {
if (flags & XBF_READ)
bp->b_locked = 1;
} else if (!PagePrivate(page)) {
if (blocksize < PAGE_CACHE_SIZE && !PagePrivate(page)) {
if (test_page_region(page, offset, nbytes))
page_count++;
}
}

unlock_page(page);
bp->b_pages[i] = page;
offset = 0;
}

if (!bp->b_locked) {
for (i = 0; i < bp->b_page_count; i++)
unlock_page(bp->b_pages[i]);
}

if (page_count == bp->b_page_count)
bp->b_flags |= XBF_DONE;

Expand Down Expand Up @@ -752,7 +743,6 @@ xfs_buf_associate_memory(
bp->b_pages[i] = mem_to_page((void *)pageaddr);
pageaddr += PAGE_CACHE_SIZE;
}
bp->b_locked = 0;

bp->b_count_desired = len;
bp->b_buffer_length = buflen;
Expand Down Expand Up @@ -1099,25 +1089,13 @@ xfs_buf_iostart(
return status;
}

STATIC_INLINE int
_xfs_buf_iolocked(
xfs_buf_t *bp)
{
ASSERT(bp->b_flags & (XBF_READ | XBF_WRITE));
if (bp->b_flags & XBF_READ)
return bp->b_locked;
return 0;
}

STATIC_INLINE void
_xfs_buf_ioend(
xfs_buf_t *bp,
int schedule)
{
if (atomic_dec_and_test(&bp->b_io_remaining) == 1) {
bp->b_locked = 0;
if (atomic_dec_and_test(&bp->b_io_remaining) == 1)
xfs_buf_ioend(bp, schedule);
}
}

STATIC void
Expand Down Expand Up @@ -1148,10 +1126,6 @@ xfs_buf_bio_end_io(

if (--bvec >= bio->bi_io_vec)
prefetchw(&bvec->bv_page->flags);

if (_xfs_buf_iolocked(bp)) {
unlock_page(page);
}
} while (bvec >= bio->bi_io_vec);

_xfs_buf_ioend(bp, 1);
Expand All @@ -1162,13 +1136,12 @@ STATIC void
_xfs_buf_ioapply(
xfs_buf_t *bp)
{
int i, rw, map_i, total_nr_pages, nr_pages;
int rw, map_i, total_nr_pages, nr_pages;
struct bio *bio;
int offset = bp->b_offset;
int size = bp->b_count_desired;
sector_t sector = bp->b_bn;
unsigned int blocksize = bp->b_target->bt_bsize;
int locking = _xfs_buf_iolocked(bp);

total_nr_pages = bp->b_page_count;
map_i = 0;
Expand All @@ -1191,7 +1164,7 @@ _xfs_buf_ioapply(
* filesystem block size is not smaller than the page size.
*/
if ((bp->b_buffer_length < PAGE_CACHE_SIZE) &&
(bp->b_flags & XBF_READ) && locking &&
(bp->b_flags & XBF_READ) &&
(blocksize >= PAGE_CACHE_SIZE)) {
bio = bio_alloc(GFP_NOIO, 1);

Expand All @@ -1208,24 +1181,6 @@ _xfs_buf_ioapply(
goto submit_io;
}

/* Lock down the pages which we need to for the request */
if (locking && (bp->b_flags & XBF_WRITE) && (bp->b_locked == 0)) {
for (i = 0; size; i++) {
int nbytes = PAGE_CACHE_SIZE - offset;
struct page *page = bp->b_pages[i];

if (nbytes > size)
nbytes = size;

lock_page(page);

size -= nbytes;
offset = 0;
}
offset = bp->b_offset;
size = bp->b_count_desired;
}

next_chunk:
atomic_inc(&bp->b_io_remaining);
nr_pages = BIO_MAX_SECTORS >> (PAGE_SHIFT - BBSHIFT);
Expand Down
1 change: 0 additions & 1 deletion fs/xfs/linux-2.6/xfs_buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ typedef struct xfs_buf {
void *b_fspriv2;
void *b_fspriv3;
unsigned short b_error; /* error code on I/O */
unsigned short b_locked; /* page array is locked */
unsigned int b_page_count; /* size of page array */
unsigned int b_offset; /* page offset in first page */
struct page **b_pages; /* array of page pointers */
Expand Down

0 comments on commit a9759f2

Please sign in to comment.