OSDN Git Service

zonefs: count pages after truncating the iterator
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Thu, 16 Jul 2020 10:37:23 +0000 (19:37 +0900)
committerDamien Le Moal <damien.lemoal@wdc.com>
Mon, 20 Jul 2020 08:59:31 +0000 (17:59 +0900)
Count pages after possibly truncating the iterator to the maximum zone
append size, not before.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
fs/zonefs/super.c

index e419833..abfb17f 100644 (file)
@@ -607,14 +607,14 @@ static ssize_t zonefs_file_dio_append(struct kiocb *iocb, struct iov_iter *from)
        int nr_pages;
        ssize_t ret;
 
-       nr_pages = iov_iter_npages(from, BIO_MAX_PAGES);
-       if (!nr_pages)
-               return 0;
-
        max = queue_max_zone_append_sectors(bdev_get_queue(bdev));
        max = ALIGN_DOWN(max << SECTOR_SHIFT, inode->i_sb->s_blocksize);
        iov_iter_truncate(from, max);
 
+       nr_pages = iov_iter_npages(from, BIO_MAX_PAGES);
+       if (!nr_pages)
+               return 0;
+
        bio = bio_alloc_bioset(GFP_NOFS, nr_pages, &fs_bio_set);
        if (!bio)
                return -ENOMEM;