Commit b34a6506 authored by Ryusuke Konishi's avatar Ryusuke Konishi

nilfs2: avoid readahead on metadata file for create mode

This turns off readhead action of metadata file if nilfs_mdt_get_block
function was called with a create flag.
Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
parent ef7d4757
...@@ -186,7 +186,7 @@ nilfs_mdt_submit_block(struct inode *inode, unsigned long blkoff, ...@@ -186,7 +186,7 @@ nilfs_mdt_submit_block(struct inode *inode, unsigned long blkoff,
} }
static int nilfs_mdt_read_block(struct inode *inode, unsigned long block, static int nilfs_mdt_read_block(struct inode *inode, unsigned long block,
struct buffer_head **out_bh) int readahead, struct buffer_head **out_bh)
{ {
struct buffer_head *first_bh, *bh; struct buffer_head *first_bh, *bh;
unsigned long blkoff; unsigned long blkoff;
...@@ -200,16 +200,18 @@ static int nilfs_mdt_read_block(struct inode *inode, unsigned long block, ...@@ -200,16 +200,18 @@ static int nilfs_mdt_read_block(struct inode *inode, unsigned long block,
if (unlikely(err)) if (unlikely(err))
goto failed; goto failed;
blkoff = block + 1; if (readahead) {
for (i = 0; i < nr_ra_blocks; i++, blkoff++) { blkoff = block + 1;
err = nilfs_mdt_submit_block(inode, blkoff, READA, &bh); for (i = 0; i < nr_ra_blocks; i++, blkoff++) {
if (likely(!err || err == -EEXIST)) err = nilfs_mdt_submit_block(inode, blkoff, READA, &bh);
brelse(bh); if (likely(!err || err == -EEXIST))
else if (err != -EBUSY) brelse(bh);
break; /* abort readahead if bmap lookup failed */ else if (err != -EBUSY)
break;
if (!buffer_locked(first_bh)) /* abort readahead if bmap lookup failed */
goto out_no_wait; if (!buffer_locked(first_bh))
goto out_no_wait;
}
} }
wait_on_buffer(first_bh); wait_on_buffer(first_bh);
...@@ -263,7 +265,7 @@ int nilfs_mdt_get_block(struct inode *inode, unsigned long blkoff, int create, ...@@ -263,7 +265,7 @@ int nilfs_mdt_get_block(struct inode *inode, unsigned long blkoff, int create,
/* Should be rewritten with merging nilfs_mdt_read_block() */ /* Should be rewritten with merging nilfs_mdt_read_block() */
retry: retry:
ret = nilfs_mdt_read_block(inode, blkoff, out_bh); ret = nilfs_mdt_read_block(inode, blkoff, !create, out_bh);
if (!create || ret != -ENOENT) if (!create || ret != -ENOENT)
return ret; return ret;
...@@ -371,7 +373,7 @@ int nilfs_mdt_mark_block_dirty(struct inode *inode, unsigned long block) ...@@ -371,7 +373,7 @@ int nilfs_mdt_mark_block_dirty(struct inode *inode, unsigned long block)
struct buffer_head *bh; struct buffer_head *bh;
int err; int err;
err = nilfs_mdt_read_block(inode, block, &bh); err = nilfs_mdt_read_block(inode, block, 0, &bh);
if (unlikely(err)) if (unlikely(err))
return err; return err;
nilfs_mark_buffer_dirty(bh); nilfs_mark_buffer_dirty(bh);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment