Skip to content

Commit 248c4ff

Browse files
committed
btrfs: split waiting from read_extent_buffer_pages(), drop parameter wait
There are only 2 WAIT_* values left for wait parameter, we can encode this to the function name if the waiting functionality is split. Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Anand Jain <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent db9eef2 commit 248c4ff

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

fs/btrfs/disk-io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ int btrfs_read_extent_buffer(struct extent_buffer *eb,
226226

227227
while (1) {
228228
clear_bit(EXTENT_BUFFER_CORRUPT, &eb->bflags);
229-
ret = read_extent_buffer_pages(eb, WAIT_COMPLETE, mirror_num, check);
229+
ret = read_extent_buffer_pages(eb, mirror_num, check);
230230
if (!ret)
231231
break;
232232

fs/btrfs/extent_io.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3479,8 +3479,8 @@ static void end_bbio_meta_read(struct btrfs_bio *bbio)
34793479
bio_put(&bbio->bio);
34803480
}
34813481

3482-
int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
3483-
const struct btrfs_tree_parent_check *check)
3482+
int read_extent_buffer_pages_nowait(struct extent_buffer *eb, int mirror_num,
3483+
const struct btrfs_tree_parent_check *check)
34843484
{
34853485
struct btrfs_bio *bbio;
34863486
bool ret;
@@ -3498,7 +3498,7 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
34983498

34993499
/* Someone else is already reading the buffer, just wait for it. */
35003500
if (test_and_set_bit(EXTENT_BUFFER_READING, &eb->bflags))
3501-
goto done;
3501+
return 0;
35023502

35033503
/*
35043504
* Between the initial test_bit(EXTENT_BUFFER_UPTODATE) and the above
@@ -3538,14 +3538,21 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
35383538
}
35393539
}
35403540
btrfs_submit_bbio(bbio, mirror_num);
3541+
return 0;
3542+
}
35413543

3542-
done:
3543-
if (wait == WAIT_COMPLETE) {
3544-
wait_on_bit_io(&eb->bflags, EXTENT_BUFFER_READING, TASK_UNINTERRUPTIBLE);
3545-
if (!test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags))
3546-
return -EIO;
3547-
}
3544+
int read_extent_buffer_pages(struct extent_buffer *eb, int mirror_num,
3545+
const struct btrfs_tree_parent_check *check)
3546+
{
3547+
int ret;
35483548

3549+
ret = read_extent_buffer_pages_nowait(eb, mirror_num, check);
3550+
if (ret < 0)
3551+
return ret;
3552+
3553+
wait_on_bit_io(&eb->bflags, EXTENT_BUFFER_READING, TASK_UNINTERRUPTIBLE);
3554+
if (!test_bit(EXTENT_BUFFER_UPTODATE, &eb->bflags))
3555+
return -EIO;
35493556
return 0;
35503557
}
35513558

@@ -4276,7 +4283,7 @@ void btrfs_readahead_tree_block(struct btrfs_fs_info *fs_info,
42764283
return;
42774284
}
42784285

4279-
ret = read_extent_buffer_pages(eb, WAIT_NONE, 0, &check);
4286+
ret = read_extent_buffer_pages_nowait(eb, 0, &check);
42804287
if (ret < 0)
42814288
free_extent_buffer_stale(eb);
42824289
else

fs/btrfs/extent_io.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,11 @@ struct extent_buffer *find_extent_buffer(struct btrfs_fs_info *fs_info,
261261
u64 start);
262262
void free_extent_buffer(struct extent_buffer *eb);
263263
void free_extent_buffer_stale(struct extent_buffer *eb);
264-
#define WAIT_NONE 0
265-
#define WAIT_COMPLETE 1
266-
int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num,
264+
int read_extent_buffer_pages(struct extent_buffer *eb, int mirror_num,
267265
const struct btrfs_tree_parent_check *parent_check);
266+
int read_extent_buffer_pages_nowait(struct extent_buffer *eb, int mirror_num,
267+
const struct btrfs_tree_parent_check *parent_check);
268+
268269
static inline void wait_on_extent_buffer_writeback(struct extent_buffer *eb)
269270
{
270271
wait_on_bit_io(&eb->bflags, EXTENT_BUFFER_WRITEBACK,

0 commit comments

Comments
 (0)