Skip to content

Commit

Permalink
iomap: Use bitmap ops to set uptodate bits
Browse files Browse the repository at this point in the history
Now that the bitmap is protected by a spinlock, we can use the
more efficient bitmap ops instead of individual test/set bit ops.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
  • Loading branch information
Matthew Wilcox (Oracle) authored and Darrick J. Wong committed Sep 21, 2020
1 parent a6901d4 commit b21866f
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions fs/iomap/buffered-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,11 @@ iomap_iop_set_range_uptodate(struct page *page, unsigned off, unsigned len)
struct inode *inode = page->mapping->host;
unsigned first = off >> inode->i_blkbits;
unsigned last = (off + len - 1) >> inode->i_blkbits;
bool uptodate = true;
unsigned long flags;
unsigned int i;

spin_lock_irqsave(&iop->uptodate_lock, flags);
for (i = 0; i < i_blocks_per_page(inode, page); i++) {
if (i >= first && i <= last)
set_bit(i, iop->uptodate);
else if (!test_bit(i, iop->uptodate))
uptodate = false;
}

if (uptodate)
bitmap_set(iop->uptodate, first, last - first + 1);
if (bitmap_full(iop->uptodate, i_blocks_per_page(inode, page)))
SetPageUptodate(page);
spin_unlock_irqrestore(&iop->uptodate_lock, flags);
}
Expand Down

0 comments on commit b21866f

Please sign in to comment.