diff mbox series

btrfs: support STATX_DIOALIGN for statx

Message ID 20240620132000.888494-1-lihongbo22@huawei.com (mailing list archive)
State New, archived
Headers show
Series btrfs: support STATX_DIOALIGN for statx | expand

Commit Message

Hongbo Li June 20, 2024, 1:20 p.m. UTC
Add support for STATX_DIOALIGN for btrfs, so that direct I/O alignment
restrictions are exposed to userspace in a generic way.

[Before]
```
./statx_test /mnt/btrfs/test
statx(/mnt/btrfs/test) = 0
dio mem align:0
dio offset align:0
```

[After]
```
./statx_test /mnt/btrfs/test
statx(/mnt/btrfs/test) = 0
dio mem align:4096
dio offset align:4096
```

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 fs/btrfs/inode.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

David Sterba June 24, 2024, 4:02 p.m. UTC | #1
On Thu, Jun 20, 2024 at 09:20:00PM +0800, Hongbo Li wrote:
> Add support for STATX_DIOALIGN for btrfs, so that direct I/O alignment
> restrictions are exposed to userspace in a generic way.

I looked at 8434ef1d8aafc523 that does also has some code coments, the
generic changelog does not mention DIO vs other features like verity or
inline files.

The statx manual page describes the high level meaning of the
dio_*_align values, so this is filesystem and implementation dependent.
So please mention what values can be expected for various features.

We do buffered io fallback on compressed data, on inline files too (I
think), it may be possible on verity too.
kernel test robot June 25, 2024, 9:56 p.m. UTC | #2
Hi Hongbo,

kernel test robot noticed the following build errors:

[auto build test ERROR on kdave/for-next]
[also build test ERROR on linus/master v6.10-rc5 next-20240625]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Hongbo-Li/btrfs-support-STATX_DIOALIGN-for-statx/20240625-141147
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
patch link:    https://lore.kernel.org/r/20240620132000.888494-1-lihongbo22%40huawei.com
patch subject: [PATCH] btrfs: support STATX_DIOALIGN for statx
config: i386-buildonly-randconfig-002-20240626 (https://download.01.org/0day-ci/archive/20240626/202406260548.6TWVzSdc-lkp@intel.com/config)
compiler: gcc-8 (Ubuntu 8.4.0-3ubuntu2) 8.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240626/202406260548.6TWVzSdc-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406260548.6TWVzSdc-lkp@intel.com/

All errors (new ones prefixed by >>):

   fs/btrfs/inode.c: In function 'btrfs_getattr':
>> fs/btrfs/inode.c:8561:3: error: unknown type name 'btrfs_fs_info'; use 'struct' keyword to refer to the type
      btrfs_fs_info *fs_info = inode_to_fs_info(inode);
      ^~~~~~~~~~~~~
      struct 
   In file included from fs/btrfs/ctree.h:20,
                    from fs/btrfs/inode.c:38:
>> fs/btrfs/fs.h:882:34: error: initialization of 'int *' from incompatible pointer type 'struct btrfs_fs_info *' [-Werror=incompatible-pointer-types]
    #define inode_to_fs_info(_inode) (BTRFS_I(_Generic((_inode),   \
                                     ^
   fs/btrfs/inode.c:8561:28: note: in expansion of macro 'inode_to_fs_info'
      btrfs_fs_info *fs_info = inode_to_fs_info(inode);
                               ^~~~~~~~~~~~~~~~
>> fs/btrfs/inode.c:8562:38: error: request for member 'fs_devices' in something not a structure or union
      struct block_device *bdev = fs_info->fs_devices->latest_dev->bdev;
                                         ^~
   In file included from arch/x86/include/asm/atomic.h:5,
                    from include/linux/atomic.h:7,
                    from include/crypto/hash.h:11,
                    from fs/btrfs/inode.c:6:
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/compiler.h:284:48: note: in definition of macro '__is_constexpr'
     (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
                                                   ^
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
   In file included from include/linux/kernel.h:28,
                    from include/linux/cpumask.h:11,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/spinlock.h:63,
                    from include/linux/swait.h:7,
                    from include/linux/completion.h:12,
                    from include/linux/crypto.h:15,
                    from include/crypto/hash.h:12,
                    from fs/btrfs/inode.c:6:
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/minmax.h:46:45: note: in definition of macro '__cmp'
    #define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y))
                                                ^
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/minmax.h:46:57: note: in definition of macro '__cmp'
    #define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y))
                                                            ^
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/minmax.h:50:9: note: in definition of macro '__cmp_once'
     typeof(y) unique_y = (y);   \
            ^
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/minmax.h:50:24: note: in definition of macro '__cmp_once'
     typeof(y) unique_y = (y);   \
                           ^
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
   In file included from include/linux/atomic/atomic-instrumented.h:15,
                    from include/linux/atomic.h:82,
                    from include/crypto/hash.h:11,
                    from fs/btrfs/inode.c:6:
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:31:24: note: in expansion of macro '__is_constexpr'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:31:39: note: in expansion of macro 'is_signed_type'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                                          ^~~~~~~~~~~~~~
   include/linux/minmax.h:39:21: note: in expansion of macro '__is_signed'
     (__is_signed(x) == __is_signed(y) ||   \
                        ^~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:31:24: note: in expansion of macro '__is_constexpr'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:31:39: note: in expansion of macro 'is_signed_type'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                                          ^~~~~~~~~~~~~~
   include/linux/minmax.h:39:21: note: in expansion of macro '__is_signed'
     (__is_signed(x) == __is_signed(y) ||   \
                        ^~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:32:3: note: in expansion of macro 'is_signed_type'
      is_signed_type(typeof(x)), 0)
      ^~~~~~~~~~~~~~
   include/linux/minmax.h:39:21: note: in expansion of macro '__is_signed'
     (__is_signed(x) == __is_signed(y) ||   \
                        ^~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:32:3: note: in expansion of macro 'is_signed_type'
      is_signed_type(typeof(x)), 0)
      ^~~~~~~~~~~~~~
   include/linux/minmax.h:39:21: note: in expansion of macro '__is_signed'
     (__is_signed(x) == __is_signed(y) ||   \
                        ^~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
   include/linux/minmax.h:31:2: error: first argument to '__builtin_choose_expr' not a constant
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
     ^~~~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:39:21: note: in expansion of macro '__is_signed'
     (__is_signed(x) == __is_signed(y) ||   \
                        ^~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:31:24: note: in expansion of macro '__is_constexpr'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:31:39: note: in expansion of macro 'is_signed_type'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                                          ^~~~~~~~~~~~~~
   include/linux/minmax.h:40:27: note: in expansion of macro '__is_signed'
      __is_signed((x) + 0) == __is_signed((y) + 0) || \
                              ^~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:31:24: note: in expansion of macro '__is_constexpr'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:31:39: note: in expansion of macro 'is_signed_type'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                                          ^~~~~~~~~~~~~~
   include/linux/minmax.h:40:27: note: in expansion of macro '__is_signed'
      __is_signed((x) + 0) == __is_signed((y) + 0) || \
                              ^~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:32:3: note: in expansion of macro 'is_signed_type'
      is_signed_type(typeof(x)), 0)
      ^~~~~~~~~~~~~~
   include/linux/minmax.h:40:27: note: in expansion of macro '__is_signed'
      __is_signed((x) + 0) == __is_signed((y) + 0) || \
                              ^~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:32:3: note: in expansion of macro 'is_signed_type'
      is_signed_type(typeof(x)), 0)
      ^~~~~~~~~~~~~~
   include/linux/minmax.h:40:27: note: in expansion of macro '__is_signed'
      __is_signed((x) + 0) == __is_signed((y) + 0) || \
                              ^~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
   include/linux/minmax.h:31:2: error: first argument to '__builtin_choose_expr' not a constant
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
     ^~~~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:40:27: note: in expansion of macro '__is_signed'
      __is_signed((x) + 0) == __is_signed((y) + 0) || \
                              ^~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:36:25: note: in expansion of macro '__is_constexpr'
     (__builtin_choose_expr(__is_constexpr(x) && __is_signed(x), x, -1) >= 0)
                            ^~~~~~~~~~~~~~
   include/linux/minmax.h:41:24: note: in expansion of macro '__is_noneg_int'
      __is_noneg_int(x) || __is_noneg_int(y))
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:31:24: note: in expansion of macro '__is_constexpr'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:31:39: note: in expansion of macro 'is_signed_type'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                                          ^~~~~~~~~~~~~~
   include/linux/minmax.h:36:46: note: in expansion of macro '__is_signed'
     (__builtin_choose_expr(__is_constexpr(x) && __is_signed(x), x, -1) >= 0)
                                                 ^~~~~~~~~~~
   include/linux/minmax.h:41:24: note: in expansion of macro '__is_noneg_int'
      __is_noneg_int(x) || __is_noneg_int(y))
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:31:24: note: in expansion of macro '__is_constexpr'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:31:39: note: in expansion of macro 'is_signed_type'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                                          ^~~~~~~~~~~~~~
   include/linux/minmax.h:36:46: note: in expansion of macro '__is_signed'
     (__builtin_choose_expr(__is_constexpr(x) && __is_signed(x), x, -1) >= 0)
                                                 ^~~~~~~~~~~
   include/linux/minmax.h:41:24: note: in expansion of macro '__is_noneg_int'
      __is_noneg_int(x) || __is_noneg_int(y))
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
>> fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:32:3: note: in expansion of macro 'is_signed_type'
      is_signed_type(typeof(x)), 0)
      ^~~~~~~~~~~~~~
   include/linux/minmax.h:36:46: note: in expansion of macro '__is_signed'
     (__builtin_choose_expr(__is_constexpr(x) && __is_signed(x), x, -1) >= 0)
                                                 ^~~~~~~~~~~
   include/linux/minmax.h:41:24: note: in expansion of macro '__is_noneg_int'
      __is_noneg_int(x) || __is_noneg_int(y))
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
   fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:32:3: note: in expansion of macro 'is_signed_type'
      is_signed_type(typeof(x)), 0)
      ^~~~~~~~~~~~~~
   include/linux/minmax.h:36:46: note: in expansion of macro '__is_signed'
     (__builtin_choose_expr(__is_constexpr(x) && __is_signed(x), x, -1) >= 0)
                                                 ^~~~~~~~~~~
   include/linux/minmax.h:41:24: note: in expansion of macro '__is_noneg_int'
      __is_noneg_int(x) || __is_noneg_int(y))
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
   include/linux/minmax.h:31:2: error: first argument to '__builtin_choose_expr' not a constant
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
     ^~~~~~~~~~~~~~~~~~~~~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:36:46: note: in expansion of macro '__is_signed'
     (__builtin_choose_expr(__is_constexpr(x) && __is_signed(x), x, -1) >= 0)
                                                 ^~~~~~~~~~~
   include/linux/minmax.h:41:24: note: in expansion of macro '__is_noneg_int'
      __is_noneg_int(x) || __is_noneg_int(y))
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \
                   ^~~~~~~~~~
   include/linux/minmax.h:58:3: note: in expansion of macro '__cmp_once'
      __cmp_once(op, x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y)))
      ^~~~~~~~~~
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
   fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^~
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:41:24: note: in expansion of macro '__is_noneg_int'
      __is_noneg_int(x) || __is_noneg_int(y))
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:51:16: note: in expansion of macro '__types_ok'
     static_assert(__types_ok(x, y),   \


vim +8561 fs/btrfs/inode.c

  8544	
  8545	static int btrfs_getattr(struct mnt_idmap *idmap,
  8546				 const struct path *path, struct kstat *stat,
  8547				 u32 request_mask, unsigned int flags)
  8548	{
  8549		u64 delalloc_bytes;
  8550		u64 inode_bytes;
  8551		struct inode *inode = d_inode(path->dentry);
  8552		u32 blocksize = btrfs_sb(inode->i_sb)->sectorsize;
  8553		u32 bi_flags = BTRFS_I(inode)->flags;
  8554		u32 bi_ro_flags = BTRFS_I(inode)->ro_flags;
  8555	
  8556		stat->result_mask |= STATX_BTIME;
  8557		stat->btime.tv_sec = BTRFS_I(inode)->i_otime_sec;
  8558		stat->btime.tv_nsec = BTRFS_I(inode)->i_otime_nsec;
  8559	
  8560		if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode)) {
> 8561			btrfs_fs_info *fs_info = inode_to_fs_info(inode);
> 8562			struct block_device *bdev = fs_info->fs_devices->latest_dev->bdev;
  8563	
  8564			stat->result_mask |= STATX_DIOALIGN;
  8565			stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
> 8566				fs_info->sectorsize);
  8567			stat->dio_offset_align = max_t(u32, bdev_logical_block_size(bdev),
  8568				fs_info->sectorsize);
  8569		}
  8570	
  8571		if (bi_flags & BTRFS_INODE_APPEND)
  8572			stat->attributes |= STATX_ATTR_APPEND;
  8573		if (bi_flags & BTRFS_INODE_COMPRESS)
  8574			stat->attributes |= STATX_ATTR_COMPRESSED;
  8575		if (bi_flags & BTRFS_INODE_IMMUTABLE)
  8576			stat->attributes |= STATX_ATTR_IMMUTABLE;
  8577		if (bi_flags & BTRFS_INODE_NODUMP)
  8578			stat->attributes |= STATX_ATTR_NODUMP;
  8579		if (bi_ro_flags & BTRFS_INODE_RO_VERITY)
  8580			stat->attributes |= STATX_ATTR_VERITY;
  8581	
  8582		stat->attributes_mask |= (STATX_ATTR_APPEND |
  8583					  STATX_ATTR_COMPRESSED |
  8584					  STATX_ATTR_IMMUTABLE |
  8585					  STATX_ATTR_NODUMP);
  8586	
  8587		generic_fillattr(idmap, request_mask, inode, stat);
  8588		stat->dev = BTRFS_I(inode)->root->anon_dev;
  8589	
  8590		stat->subvol = BTRFS_I(inode)->root->root_key.objectid;
  8591		stat->result_mask |= STATX_SUBVOL;
  8592	
  8593		spin_lock(&BTRFS_I(inode)->lock);
  8594		delalloc_bytes = BTRFS_I(inode)->new_delalloc_bytes;
  8595		inode_bytes = inode_get_bytes(inode);
  8596		spin_unlock(&BTRFS_I(inode)->lock);
  8597		stat->blocks = (ALIGN(inode_bytes, blocksize) +
  8598				ALIGN(delalloc_bytes, blocksize)) >> SECTOR_SHIFT;
  8599		return 0;
  8600	}
  8601
kernel test robot June 26, 2024, 12:24 a.m. UTC | #3
Hi Hongbo,

kernel test robot noticed the following build errors:

[auto build test ERROR on kdave/for-next]
[also build test ERROR on linus/master v6.10-rc5 next-20240625]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Hongbo-Li/btrfs-support-STATX_DIOALIGN-for-statx/20240625-141147
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-next
patch link:    https://lore.kernel.org/r/20240620132000.888494-1-lihongbo22%40huawei.com
patch subject: [PATCH] btrfs: support STATX_DIOALIGN for statx
config: i386-randconfig-015-20240626 (https://download.01.org/0day-ci/archive/20240626/202406260839.lNfzNan4-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240626/202406260839.lNfzNan4-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406260839.lNfzNan4-lkp@intel.com/

All errors (new ones prefixed by >>):

   fs/btrfs/inode.c: In function 'btrfs_getattr':
   fs/btrfs/inode.c:8561:3: error: unknown type name 'btrfs_fs_info'; use 'struct' keyword to refer to the type
      btrfs_fs_info *fs_info = inode_to_fs_info(inode);
      ^~~~~~~~~~~~~
      struct 
   In file included from fs/btrfs/ctree.h:20:0,
                    from fs/btrfs/inode.c:38:
>> fs/btrfs/fs.h:882:34: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
    #define inode_to_fs_info(_inode) (BTRFS_I(_Generic((_inode),   \
                                     ^
   fs/btrfs/inode.c:8561:28: note: in expansion of macro 'inode_to_fs_info'
      btrfs_fs_info *fs_info = inode_to_fs_info(inode);
                               ^~~~~~~~~~~~~~~~
   fs/btrfs/inode.c:8562:38: error: request for member 'fs_devices' in something not a structure or union
      struct block_device *bdev = fs_info->fs_devices->latest_dev->bdev;
                                         ^~
   In file included from arch/x86/include/asm/atomic.h:5:0,
                    from include/linux/atomic.h:7,
                    from include/crypto/hash.h:11,
                    from fs/btrfs/inode.c:6:
   fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^
   include/linux/compiler.h:284:48: note: in definition of macro '__is_constexpr'
     (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
                                                   ^
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
   In file included from include/linux/kernel.h:28:0,
                    from include/linux/cpumask.h:11,
                    from include/linux/smp.h:13,
                    from include/linux/lockdep.h:14,
                    from include/linux/spinlock.h:63,
                    from include/linux/swait.h:7,
                    from include/linux/completion.h:12,
                    from include/linux/crypto.h:15,
                    from include/crypto/hash.h:12,
                    from fs/btrfs/inode.c:6:
   fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^
   include/linux/minmax.h:46:45: note: in definition of macro '__cmp'
    #define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y))
                                                ^
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
   fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^
   include/linux/minmax.h:46:57: note: in definition of macro '__cmp'
    #define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y))
                                                            ^
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
   fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^
   include/linux/minmax.h:50:9: note: in definition of macro '__cmp_once'
     typeof(y) unique_y = (y);   \
            ^
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
   fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^
   include/linux/minmax.h:50:24: note: in definition of macro '__cmp_once'
     typeof(y) unique_y = (y);   \
                           ^
   include/linux/minmax.h:169:27: note: in expansion of macro '__careful_cmp'
    #define max_t(type, x, y) __careful_cmp(max, (type)(x), (type)(y))
                              ^~~~~~~~~~~~~
   fs/btrfs/inode.c:8565:25: note: in expansion of macro 'max_t'
      stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
                            ^~~~~
   In file included from include/linux/atomic/atomic-instrumented.h:15:0,
                    from include/linux/atomic.h:82,
                    from include/crypto/hash.h:11,
                    from fs/btrfs/inode.c:6:
   fs/btrfs/inode.c:8566:11: error: request for member 'sectorsize' in something not a structure or union
       fs_info->sectorsize);
              ^
   include/linux/build_bug.h:78:56: note: in definition of macro '__static_assert'
    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
                                                           ^~~~
   include/linux/minmax.h:51:2: note: in expansion of macro 'static_assert'
     static_assert(__types_ok(x, y),   \
     ^~~~~~~~~~~~~
   include/linux/minmax.h:31:24: note: in expansion of macro '__is_constexpr'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \
                           ^~~~~~~~~~~~~~
   include/linux/minmax.h:31:39: note: in expansion of macro 'is_signed_type'
     __builtin_choose_expr(__is_constexpr(is_signed_type(typeof(x))), \


vim +882 fs/btrfs/fs.h

b33d2e535f9b2a David Sterba 2023-09-14  881  
41044b41ad2c8c David Sterba 2023-09-14 @882  #define inode_to_fs_info(_inode) (BTRFS_I(_Generic((_inode),			\
41044b41ad2c8c David Sterba 2023-09-14  883  					   struct inode *: (_inode)))->root->fs_info)
41044b41ad2c8c David Sterba 2023-09-14  884
Hongbo Li July 25, 2024, 1:45 p.m. UTC | #4
On 2024/6/25 0:02, David Sterba wrote:
> On Thu, Jun 20, 2024 at 09:20:00PM +0800, Hongbo Li wrote:
>> Add support for STATX_DIOALIGN for btrfs, so that direct I/O alignment
>> restrictions are exposed to userspace in a generic way.
> 
> I looked at 8434ef1d8aafc523 that does also has some code coments, the
> generic changelog does not mention DIO vs other features like verity or
> inline files.
> 
> The statx manual page describes the high level meaning of the
> dio_*_align values, so this is filesystem and implementation dependent.
> So please mention what values can be expected for various features.
> 
> We do buffered io fallback on compressed data, on inline files too (I
> think), it may be possible on verity too.
Sorry, it was my oversight. I read the relative code, but I just find 
the fsverity and offset(size) and memory may affect the dio_*_align. I 
haven't found it related to compressed data and inline files. Does this 
miss the interception for the compressed data and inline files?

Also when `iomap_dio_rw` failed and return 0, it will fallback into 
buffered io. May be the dio_*_align values should not be affected by 
this situation.

Thanks,
Hongbo
>
diff mbox series

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 753db965f7c0..a648e81143fd 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8610,6 +8610,18 @@  static int btrfs_getattr(struct mnt_idmap *idmap,
 	stat->result_mask |= STATX_BTIME;
 	stat->btime.tv_sec = BTRFS_I(inode)->i_otime_sec;
 	stat->btime.tv_nsec = BTRFS_I(inode)->i_otime_nsec;
+
+	if ((request_mask & STATX_DIOALIGN) && S_ISREG(inode->i_mode)) {
+		btrfs_fs_info *fs_info = inode_to_fs_info(inode);
+		struct block_device *bdev = fs_info->fs_devices->latest_dev->bdev;
+
+		stat->result_mask |= STATX_DIOALIGN;
+		stat->dio_mem_align = max_t(u32, (bdev_dma_alignment(bdev) + 1),
+			fs_info->sectorsize);
+		stat->dio_offset_align = max_t(u32, bdev_logical_block_size(bdev),
+			fs_info->sectorsize);
+	}
+
 	if (bi_flags & BTRFS_INODE_APPEND)
 		stat->attributes |= STATX_ATTR_APPEND;
 	if (bi_flags & BTRFS_INODE_COMPRESS)