Skip to content

Commit b34a650

Browse files
committed
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: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
1 parent ef7d475 commit b34a650

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

‎fs/nilfs2/mdt.c‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ nilfs_mdt_submit_block(struct inode *inode, unsigned long blkoff,
186186
}
187187

188188
static int nilfs_mdt_read_block(struct inode *inode, unsigned long block,
189-
struct buffer_head **out_bh)
189+
int readahead, struct buffer_head **out_bh)
190190
{
191191
struct buffer_head *first_bh, *bh;
192192
unsigned long blkoff;
@@ -200,16 +200,18 @@ static int nilfs_mdt_read_block(struct inode *inode, unsigned long block,
200200
if (unlikely(err))
201201
goto failed;
202202

203-
blkoff = block + 1;
204-
for (i = 0; i < nr_ra_blocks; i++, blkoff++) {
205-
err = nilfs_mdt_submit_block(inode, blkoff, READA, &bh);
206-
if (likely(!err || err == -EEXIST))
207-
brelse(bh);
208-
else if (err != -EBUSY)
209-
break; /* abort readahead if bmap lookup failed */
210-
211-
if (!buffer_locked(first_bh))
212-
goto out_no_wait;
203+
if (readahead) {
204+
blkoff = block + 1;
205+
for (i = 0; i < nr_ra_blocks; i++, blkoff++) {
206+
err = nilfs_mdt_submit_block(inode, blkoff, READA, &bh);
207+
if (likely(!err || err == -EEXIST))
208+
brelse(bh);
209+
else if (err != -EBUSY)
210+
break;
211+
/* abort readahead if bmap lookup failed */
212+
if (!buffer_locked(first_bh))
213+
goto out_no_wait;
214+
}
213215
}
214216

215217
wait_on_buffer(first_bh);
@@ -263,7 +265,7 @@ int nilfs_mdt_get_block(struct inode *inode, unsigned long blkoff, int create,
263265

264266
/* Should be rewritten with merging nilfs_mdt_read_block() */
265267
retry:
266-
ret = nilfs_mdt_read_block(inode, blkoff, out_bh);
268+
ret = nilfs_mdt_read_block(inode, blkoff, !create, out_bh);
267269
if (!create || ret != -ENOENT)
268270
return ret;
269271

@@ -371,7 +373,7 @@ int nilfs_mdt_mark_block_dirty(struct inode *inode, unsigned long block)
371373
struct buffer_head *bh;
372374
int err;
373375

374-
err = nilfs_mdt_read_block(inode, block, &bh);
376+
err = nilfs_mdt_read_block(inode, block, 0, &bh);
375377
if (unlikely(err))
376378
return err;
377379
nilfs_mark_buffer_dirty(bh);

0 commit comments

Comments
 (0)