Merge tag 'zonefs-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal...
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 22 Feb 2021 21:13:51 +0000 (13:13 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 22 Feb 2021 21:13:51 +0000 (13:13 -0800)
Pull zonefs updates from Damien Le Moal:
 "Two changes:

   - A fix that did not make it in time for 5.11, to correct the file
     size initialization of full sequential zone, from Shin'ichiro

   - Add file operation tracepoints to help with debugging, from
     Johannes"

* tag 'zonefs-5.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/zonefs:
  zonefs: Fix file size of zones in full condition
  zonefs: add tracepoints for file operations

1  2 
fs/zonefs/super.c

diff --combined fs/zonefs/super.c
@@@ -24,6 -24,9 +24,9 @@@
  
  #include "zonefs.h"
  
+ #define CREATE_TRACE_POINTS
+ #include "trace.h"
  static inline int zonefs_zone_mgmt(struct inode *inode,
                                   enum req_opf op)
  {
@@@ -32,6 -35,7 +35,7 @@@
  
        lockdep_assert_held(&zi->i_truncate_mutex);
  
+       trace_zonefs_zone_mgmt(inode, op);
        ret = blkdev_zone_mgmt(inode->i_sb->s_bdev, op, zi->i_zsector,
                               zi->i_zone_size >> SECTOR_SHIFT, GFP_NOFS);
        if (ret) {
@@@ -100,6 -104,8 +104,8 @@@ static int zonefs_iomap_begin(struct in
        iomap->bdev = inode->i_sb->s_bdev;
        iomap->addr = (zi->i_zsector << SECTOR_SHIFT) + iomap->offset;
  
+       trace_zonefs_iomap_begin(inode, iomap);
        return 0;
  }
  
@@@ -250,6 -256,9 +256,9 @@@ static loff_t zonefs_check_zone_conditi
                }
                inode->i_mode &= ~0222;
                return i_size_read(inode);
+       case BLK_ZONE_COND_FULL:
+               /* The write pointer of full zones is invalid. */
+               return zi->i_max_size;
        default:
                if (zi->i_ztype == ZONEFS_ZTYPE_CNV)
                        return zi->i_max_size;
@@@ -541,7 -550,7 +550,7 @@@ static int zonefs_file_fsync(struct fil
        if (ZONEFS_I(inode)->i_ztype == ZONEFS_ZTYPE_CNV)
                ret = file_write_and_wait_range(file, start, end);
        if (!ret)
 -              ret = blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL);
 +              ret = blkdev_issue_flush(inode->i_sb->s_bdev);
  
        if (ret)
                zonefs_io_error(inode, true);
@@@ -678,7 -687,7 +687,7 @@@ static ssize_t zonefs_file_dio_append(s
        if (!nr_pages)
                return 0;
  
 -      bio = bio_alloc_bioset(GFP_NOFS, nr_pages, &fs_bio_set);
 +      bio = bio_alloc(GFP_NOFS, nr_pages);
        if (!bio)
                return -ENOMEM;
  
        ret = submit_bio_wait(bio);
  
        zonefs_file_write_dio_end_io(iocb, size, ret, 0);
+       trace_zonefs_file_dio_append(inode, size, ret);
  
  out_release:
        bio_release_pages(bio, false);
@@@ -780,7 -790,7 +790,7 @@@ static ssize_t zonefs_file_dio_write(st
                ret = zonefs_file_dio_append(iocb, from);
        else
                ret = iomap_dio_rw(iocb, from, &zonefs_iomap_ops,
 -                                 &zonefs_write_dio_ops, sync);
 +                                 &zonefs_write_dio_ops, 0);
        if (zi->i_ztype == ZONEFS_ZTYPE_SEQ &&
            (ret > 0 || ret == -EIOCBQUEUED)) {
                if (ret > 0)
@@@ -917,7 -927,7 +927,7 @@@ static ssize_t zonefs_file_read_iter(st
                }
                file_accessed(iocb->ki_filp);
                ret = iomap_dio_rw(iocb, to, &zonefs_iomap_ops,
 -                                 &zonefs_read_dio_ops, is_sync_kiocb(iocb));
 +                                 &zonefs_read_dio_ops, 0);
        } else {
                ret = generic_file_read_iter(iocb, to);
                if (ret == -EIO)
@@@ -1581,11 -1591,12 +1591,11 @@@ static int zonefs_fill_super(struct sup
        sb->s_time_gran = 1;
  
        /*
 -       * The block size is set to the device physical sector size to ensure
 -       * that write operations on 512e devices (512B logical block and 4KB
 -       * physical block) are always aligned to the device physical blocks,
 -       * as mandated by the ZBC/ZAC specifications.
 +       * The block size is set to the device zone write granularity to ensure
 +       * that write operations are always aligned according to the device
 +       * interface constraints.
         */
 -      sb_set_blocksize(sb, bdev_physical_block_size(sb->s_bdev));
 +      sb_set_blocksize(sb, bdev_zone_write_granularity(sb->s_bdev));
        sbi->s_zone_sectors_shift = ilog2(bdev_zone_sectors(sb->s_bdev));
        sbi->s_uid = GLOBAL_ROOT_UID;
        sbi->s_gid = GLOBAL_ROOT_GID;