Skip to content
Permalink
Browse files
f2fs: fix wrong inflight page stats for directIO
Previously, we use sbi->nr_pages[] to account direct IO, the count should
be based on page granularity rather than bio granularity, fix it.

Fixes: 02b16d0 ("f2fs: add to account direct IO")
Signed-off-by: Chao Yu <chao@kernel.org>
  • Loading branch information
chaseyu authored and intel-lab-lkp committed Jul 19, 2021
1 parent fff4047 commit 5fc42a72cb1e41b799ea659d710c091804fb648a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
@@ -3494,8 +3494,9 @@ static void f2fs_dio_end_io(struct bio *bio)
{
struct f2fs_private_dio *dio = bio->bi_private;

dec_page_count(F2FS_I_SB(dio->inode),
dio->write ? F2FS_DIO_WRITE : F2FS_DIO_READ);
dec_page_counts(F2FS_I_SB(dio->inode),
dio->write ? F2FS_DIO_WRITE : F2FS_DIO_READ,
dio->blkcnt);

bio->bi_private = dio->orig_private;
bio->bi_end_io = dio->orig_end_io;
@@ -3519,13 +3520,14 @@ static void f2fs_dio_submit_bio(struct bio *bio, struct inode *inode,
dio->inode = inode;
dio->orig_end_io = bio->bi_end_io;
dio->orig_private = bio->bi_private;
dio->blkcnt = blkcnt;
dio->write = write;

bio->bi_end_io = f2fs_dio_end_io;
bio->bi_private = dio;

inc_page_count(F2FS_I_SB(inode),
write ? F2FS_DIO_WRITE : F2FS_DIO_READ);
inc_page_counts(F2FS_I_SB(inode),
write ? F2FS_DIO_WRITE : F2FS_DIO_READ, dio->blkcnt);

submit_bio(bio);
return;
@@ -1759,6 +1759,7 @@ struct f2fs_private_dio {
struct inode *inode;
void *orig_private;
bio_end_io_t *orig_end_io;
unsigned int blkcnt;
bool write;
};

@@ -2267,6 +2268,12 @@ static inline void inc_page_count(struct f2fs_sb_info *sbi, int count_type)
set_sbi_flag(sbi, SBI_IS_DIRTY);
}

static inline void inc_page_counts(struct f2fs_sb_info *sbi, int count_type,
unsigned int count)
{
atomic_add(count, &sbi->nr_pages[count_type]);
}

static inline void inode_inc_dirty_pages(struct inode *inode)
{
atomic_inc(&F2FS_I(inode)->dirty_pages);
@@ -2281,6 +2288,12 @@ static inline void dec_page_count(struct f2fs_sb_info *sbi, int count_type)
atomic_dec(&sbi->nr_pages[count_type]);
}

static inline void dec_page_counts(struct f2fs_sb_info *sbi, int count_type,
unsigned int count)
{
atomic_sub(count, &sbi->nr_pages[count_type]);
}

static inline void inode_dec_dirty_pages(struct inode *inode)
{
if (!S_ISDIR(inode->i_mode) && !S_ISREG(inode->i_mode) &&

0 comments on commit 5fc42a7

Please sign in to comment.