Re: [f2fs-dev] [PATCH v3 1/8] statx: add direct I/O alignment information

2022-06-23 Thread Eric Biggers
On Thu, Jun 23, 2022 at 10:23:20AM -0700, Eric Biggers wrote:
> On Thu, Jun 23, 2022 at 08:58:12AM -0700, Darrick J. Wong wrote:
> > > diff --git a/include/linux/stat.h b/include/linux/stat.h
> > > index 7df06931f25d8..ff277ced50e9f 100644
> > > --- a/include/linux/stat.h
> > > +++ b/include/linux/stat.h
> > > @@ -50,6 +50,8 @@ struct kstat {
> > >   struct timespec64 btime;/* File creation time */
> > >   u64 blocks;
> > >   u64 mnt_id;
> > > + u32 dio_mem_align;
> > > + u32 dio_offset_align;
> > 
> > Hmm.  Does the XFS port of XFS_IOC_DIOINFO to STATX_DIOALIGN look like
> > this?
> > 
> > struct xfs_buftarg  *target = xfs_inode_buftarg(ip);
> > 
> > kstat.dio_mem_align = target->bt_logical_sectorsize;
> > kstat.dio_offset_align = target->bt_logical_sectorsize;
> > kstat.result_mask |= STATX_DIOALIGN;
> 
> Yes, I think so.
> 

By the way, the patchset "[PATCHv6 00/11] direct-io dma alignment"
(https://lore.kernel.org/linux-block/20220610195830.3574005-1-kbu...@fb.com/T/#u),
which is currently queued in linux-block/for-next for 5.20, will relax the user
buffer alignment requirement to the dma alignment for all filesystems using the
iomap direct I/O implementation.  If that goes in, the XFS implementation of
STATX_DIOALIGN, as well as the ext4 and f2fs ones, will need to be changed
accordingly.  Also, the existing XFS_IOC_DIOINFO will need to be changed.

- Eric


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v2 1/5] Fix the struct f2fs_dentry_block definition

2022-06-23 Thread Peter Collingbourne via Linux-f2fs-devel
On Thu, Jun 23, 2022 at 11:12 AM Bart Van Assche  wrote:
>
> Fix the struct f2fs_dentry_block definition on systems for which
> PAGE_SIZE != 4096. This patch does not change the struct f2fs_dentry_block
> definition if PAGE_SIZE == 4096.
>
> Cc: Peter Collingbourne 
> Reported-by: Peter Collingbourne 
> Signed-off-by: Bart Van Assche 

Thanks, this is what I had in mind and it fixes the build on my target
with PAGE_SIZE != 4096. I also verified that a filesystem created on
the PAGE_SIZE != 4096 target can be mounted on a machine with
PAGE_SIZE == 4096.

Reviewed-by: Peter Collingbourne 
Tested-by: Peter Collingbourne 

Peter


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2 3/5] Improve compile-time type checking for f2fs_report_zone()

2022-06-23 Thread Bart Van Assche
Change the type of the third argument of f2fs_report_zone() from void *
into struct blk_zone * to enable type checking.

Signed-off-by: Bart Van Assche 
---
 include/f2fs_fs.h   |  4 +++-
 lib/libf2fs_zoned.c | 24 +++-
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index fdbf7c7a0b35..8125e9f8d082 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1560,9 +1560,11 @@ blk_zone_cond_str(struct blk_zone *blkz)
 
 #endif
 
+struct blk_zone;
+
 extern int f2fs_get_zoned_model(int);
 extern int f2fs_get_zone_blocks(int);
-extern int f2fs_report_zone(int, uint64_t, void *);
+extern int f2fs_report_zone(int, uint64_t, struct blk_zone *);
 typedef int (report_zones_cb_t)(int i, void *, void *);
 extern int f2fs_report_zones(int, report_zones_cb_t *, void *);
 extern int f2fs_check_zones(int);
diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index d8de66b82029..a0dd8bd269ef 100644
--- a/lib/libf2fs_zoned.c
+++ b/lib/libf2fs_zoned.c
@@ -200,21 +200,26 @@ int f2fs_get_zone_blocks(int i)
return 0;
 }
 
-int f2fs_report_zone(int i, uint64_t sector, void *blkzone)
+int f2fs_report_zone(int i, uint64_t sector, struct blk_zone *blkzone)
 {
-   struct blk_zone *blkz = (struct blk_zone *)blkzone;
-   struct blk_zone_report *rep;
+   struct one_zone_report {
+   struct blk_zone_report  rep;
+   struct blk_zone zone;
+   } *rep;
int ret = -1;
 
-   rep = calloc(1, sizeof(struct blk_zone_report) +
-sizeof(struct blk_zone));
+   static_assert(sizeof(*rep) == sizeof(rep->rep) + sizeof(rep->zone), "");
+
+   rep = calloc(1, sizeof(*rep));
if (!rep) {
ERR_MSG("No memory for report zones\n");
return -ENOMEM;
}
 
-   rep->sector = sector;
-   rep->nr_zones = 1;
+   rep->rep = (struct blk_zone_report){
+   .sector = sector,
+   .nr_zones = 1,
+   };
ret = ioctl(c.devices[i].fd, BLKREPORTZONE, rep);
if (ret != 0) {
ret = -errno;
@@ -222,7 +227,7 @@ int f2fs_report_zone(int i, uint64_t sector, void *blkzone)
goto out;
}
 
-   *blkz = *(struct blk_zone *)(rep + 1);
+   *blkzone = rep->zone;
 out:
free(rep);
return ret;
@@ -531,7 +536,8 @@ uint32_t f2fs_get_usable_segments(struct f2fs_super_block 
*sb)
 
 #else
 
-int f2fs_report_zone(int i, uint64_t UNUSED(sector), void *UNUSED(blkzone))
+int f2fs_report_zone(int i, uint64_t UNUSED(sector),
+struct blk_zone *UNUSED(blkzone))
 {
ERR_MSG("%d: Unsupported zoned block device\n", i);
return -1;


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2 1/5] Fix the struct f2fs_dentry_block definition

2022-06-23 Thread Bart Van Assche
Fix the struct f2fs_dentry_block definition on systems for which
PAGE_SIZE != 4096. This patch does not change the struct f2fs_dentry_block
definition if PAGE_SIZE == 4096.

Cc: Peter Collingbourne 
Reported-by: Peter Collingbourne 
Signed-off-by: Bart Van Assche 
---
 include/f2fs_fs.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h
index 21a7e70d952d..fdbf7c7a0b35 100644
--- a/include/f2fs_fs.h
+++ b/include/f2fs_fs.h
@@ -1317,7 +1317,7 @@ typedef __le32f2fs_hash_t;
 #define SIZE_OF_DIR_ENTRY  11  /* by byte */
 #define SIZE_OF_DENTRY_BITMAP  ((NR_DENTRY_IN_BLOCK + BITS_PER_BYTE - 1) / \
BITS_PER_BYTE)
-#define SIZE_OF_RESERVED   (PAGE_SIZE - ((SIZE_OF_DIR_ENTRY + \
+#define SIZE_OF_RESERVED   (F2FS_BLKSIZE - ((SIZE_OF_DIR_ENTRY + \
F2FS_SLOT_LEN) * \
NR_DENTRY_IN_BLOCK + SIZE_OF_DENTRY_BITMAP))
 #define MIN_INLINE_DENTRY_SIZE 40  /* just include '.' and '..' 
entries */
@@ -1341,7 +1341,7 @@ struct f2fs_dentry_block {
__u8 filename[NR_DENTRY_IN_BLOCK][F2FS_SLOT_LEN];
 };
 
-static_assert(sizeof(struct f2fs_dentry_block) == 4096, "");
+static_assert(sizeof(struct f2fs_dentry_block) == F2FS_BLKSIZE, "");
 
 /* for inline stuff */
 #define DEF_INLINE_RESERVED_SIZE   1


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2 4/5] Use F2FS_BLKSIZE for dev_read_block() buffers

2022-06-23 Thread Bart Van Assche
Use F2FS_BLKSIZE instead of PAGE_SIZE for dev_read_block() buffers since
dev_read_block() reads F2FS_BLKSIZE bytes.

Signed-off-by: Bart Van Assche 
---
 fsck/mount.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index 108e1238493d..cc871fea5d10 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1115,7 +1115,7 @@ static void *get_checkpoint_version(block_t cp_addr)
 {
void *cp_page;
 
-   cp_page = malloc(PAGE_SIZE);
+   cp_page = malloc(F2FS_BLKSIZE);
ASSERT(cp_page);
 
if (dev_read_block(cp_page, cp_addr) < 0)
@@ -1821,7 +1821,7 @@ static void read_compacted_summaries(struct f2fs_sb_info 
*sbi)
 
start = start_sum_block(sbi);
 
-   kaddr = (char *)malloc(PAGE_SIZE);
+   kaddr = malloc(F2FS_BLKSIZE);
ASSERT(kaddr);
 
ret = dev_read_block(kaddr, start++);
@@ -1856,7 +1856,7 @@ static void read_compacted_summaries(struct f2fs_sb_info 
*sbi)
if (offset + SUMMARY_SIZE <=
PAGE_CACHE_SIZE - SUM_FOOTER_SIZE)
continue;
-   memset(kaddr, 0, PAGE_SIZE);
+   memset(kaddr, 0, F2FS_BLKSIZE);
ret = dev_read_block(kaddr, start++);
ASSERT(ret >= 0);
offset = 0;


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2 0/5] PAGE_SIZE and zoned storage related improvements

2022-06-23 Thread Bart Van Assche
Hi Jaegeuk,

This patch series fixes one issue reported by Peter Collingbourne and a few
issues I discovered by reading the zoned block device source code. Please
consider these patches for inclusion in the official f2fs-tools repository.

Thanks,

Bart.

Bart Van Assche (5):
  Fix the struct f2fs_dentry_block definition
  Fix f2fs_report_zone()
  Improve compile-time type checking for f2fs_report_zone()
  Use F2FS_BLKSIZE for dev_read_block() buffers
  Use F2FS_BLKSIZE as the size of struct f2fs_summary_block

 fsck/mount.c| 14 +++---
 include/f2fs_fs.h   |  8 +---
 lib/libf2fs_zoned.c | 23 +++
 3 files changed, 27 insertions(+), 18 deletions(-)



___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2 2/5] Fix f2fs_report_zone()

2022-06-23 Thread Bart Van Assche
The definition of struct blk_zone_report is as follows:

struct blk_zone_report {
__u64   sector;
__u32   nr_zones;
__u32   flags;
struct blk_zone zones[0];
};

Since f2fs_report_zone() allocates the above data structure with
malloc() and since f2fs_report_zone() only initializes the sector and
nr_zones members, the flags member is not initialized. Modify
f2fs_report_zone() such that 0 is passed as flags to the
BLKREPORTZONE ioctl instead of a random value. This has been
discovered by reading the source code.

Cc: Shin'ichiro Kawasaki 
Fixes: 6d7c7b785feb ("libf2fs_zoned: Introduce f2fs_report_zone() helper 
function")
Signed-off-by: Bart Van Assche 
---
 lib/libf2fs_zoned.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/libf2fs_zoned.c b/lib/libf2fs_zoned.c
index f383ce275342..d8de66b82029 100644
--- a/lib/libf2fs_zoned.c
+++ b/lib/libf2fs_zoned.c
@@ -206,7 +206,8 @@ int f2fs_report_zone(int i, uint64_t sector, void *blkzone)
struct blk_zone_report *rep;
int ret = -1;
 
-   rep = malloc(sizeof(struct blk_zone_report) + sizeof(struct blk_zone));
+   rep = calloc(1, sizeof(struct blk_zone_report) +
+sizeof(struct blk_zone));
if (!rep) {
ERR_MSG("No memory for report zones\n");
return -ENOMEM;


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


[f2fs-dev] [PATCH v2 5/5] Use F2FS_BLKSIZE as the size of struct f2fs_summary_block

2022-06-23 Thread Bart Van Assche
Since the size of struct f2fs_summary_block equals F2FS_BLKSIZE, use
F2FS_BLKSIZE instead of PAGE_CACHE_SIZE as the size of struct
f2fs_summary_block.

Signed-off-by: Bart Van Assche 
---
 fsck/mount.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index cc871fea5d10..584e6d1370ae 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -1854,7 +1854,7 @@ static void read_compacted_summaries(struct f2fs_sb_info 
*sbi)
curseg->sum_blk->entries[j] = *s;
offset += SUMMARY_SIZE;
if (offset + SUMMARY_SIZE <=
-   PAGE_CACHE_SIZE - SUM_FOOTER_SIZE)
+   F2FS_BLKSIZE - SUM_FOOTER_SIZE)
continue;
memset(kaddr, 0, F2FS_BLKSIZE);
ret = dev_read_block(kaddr, start++);
@@ -1914,7 +1914,7 @@ static void read_normal_summaries(struct f2fs_sb_info 
*sbi, int type)
blk_addr = GET_SUM_BLKADDR(sbi, segno);
}
 
-   sum_blk = (struct f2fs_summary_block *)malloc(PAGE_SIZE);
+   sum_blk = malloc(sizeof(*sum_blk));
ASSERT(sum_blk);
 
ret = dev_read_block(sum_blk, blk_addr);
@@ -1924,7 +1924,7 @@ static void read_normal_summaries(struct f2fs_sb_info 
*sbi, int type)
restore_node_summary(sbi, segno, sum_blk);
 
curseg = CURSEG_I(sbi, type);
-   memcpy(curseg->sum_blk, sum_blk, PAGE_CACHE_SIZE);
+   memcpy(curseg->sum_blk, sum_blk, sizeof(*sum_blk));
reset_curseg(sbi, type);
free(sum_blk);
 }
@@ -1990,7 +1990,7 @@ static int build_curseg(struct f2fs_sb_info *sbi)
SM_I(sbi)->curseg_array = array;
 
for (i = 0; i < NR_CURSEG_TYPE; i++) {
-   array[i].sum_blk = calloc(PAGE_CACHE_SIZE, 1);
+   array[i].sum_blk = calloc(sizeof(*(array[i].sum_blk)), 1);
if (!array[i].sum_blk) {
MSG(1, "\tError: Calloc failed for build_curseg!!\n");
goto seg_cleanup;


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH v3 1/8] statx: add direct I/O alignment information

2022-06-23 Thread Eric Biggers
On Thu, Jun 23, 2022 at 08:58:12AM -0700, Darrick J. Wong wrote:
> > diff --git a/include/linux/stat.h b/include/linux/stat.h
> > index 7df06931f25d8..ff277ced50e9f 100644
> > --- a/include/linux/stat.h
> > +++ b/include/linux/stat.h
> > @@ -50,6 +50,8 @@ struct kstat {
> > struct timespec64 btime;/* File creation time */
> > u64 blocks;
> > u64 mnt_id;
> > +   u32 dio_mem_align;
> > +   u32 dio_offset_align;
> 
> Hmm.  Does the XFS port of XFS_IOC_DIOINFO to STATX_DIOALIGN look like
> this?
> 
>   struct xfs_buftarg  *target = xfs_inode_buftarg(ip);
> 
>   kstat.dio_mem_align = target->bt_logical_sectorsize;
>   kstat.dio_offset_align = target->bt_logical_sectorsize;
>   kstat.result_mask |= STATX_DIOALIGN;

Yes, I think so.

However, if we need more fields as Avi Kivity requested at
https://lore.kernel.org/r/6c06b2d4-2d96-c4a6-7aca-5147a91e7...@scylladb.com
that is going to complicate things.  I haven't had a chance to look
into whether those extra fields are really needed.  Your opinion on whether XFS
(and any other filesystem) needs them would be appreciated.

> 
> And I guess you're tabling the "optimal" IO discussions for now, because
> there are too many variants of what that means?
> 

Yes, that's omitted for now due to the apparent redundancy with stx_blksize.

- Eric


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [man-pages RFC PATCH] statx.2, open.2: document STATX_DIOALIGN

2022-06-23 Thread Eric Biggers
On Thu, Jun 23, 2022 at 10:27:19AM -0600, Andreas Dilger wrote:
> On Jun 23, 2022, at 10:02 AM, Darrick J. Wong  wrote:
> > 
> > On Thu, Jun 16, 2022 at 01:21:41PM -0700, Eric Biggers wrote:
> >> From: Eric Biggers 
> >> 
> >> @@ -244,8 +249,11 @@ STATX_SIZEWant stx_size
> >> STATX_BLOCKS   Want stx_blocks
> >> STATX_BASIC_STATS  [All of the above]
> >> STATX_BTIMEWant stx_btime
> >> +STATX_ALL The same as STATX_BASIC_STATS | STATX_BTIME.
> >> +  This is deprecated and should not be used.
> > 
> > STATX_ALL is deprecated??  I was under the impression that _ALL meant
> > all the known bits for that kernel release, but...
> 
> For userspace STATX_ALL doesn't make sense, and it isn't used by the kernel.
> 
> Firstly, that would be a compile-time value for an application, so it
> may be incorrect for the kernel the code is actually run on (either too
> many or too few bits could be set).
> 
> Secondly, it isn't really useful for an app to request "all attributes"
> if it doesn't know what they all mean, as that potentially adds useless
> overhead.  Better for it to explicitly request the attributes that it
> needs.  If that is fewer than the kernel could return it is irrelevant,
> since the app would ignore them anyway.
> 
> The kernel will already ignore and mask attributes that *it* doesn't
> understand, so requesting more is fine and STATX_ALL doesn't help this.
> 

What Andreas said.  Note, this discussion really should be happening on my
standalone patch that fixes the documentation for STATX_ALL:
https://lore.kernel.org/r/20220614034459.79889-1-ebigg...@kernel.org.  I folded
it into this RFC one only so that it applies cleanly without a prerequisite.

- Eric


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 6/7] ext4: Enable negative dentries on case-insensitive lookup

2022-06-23 Thread Gabriel Krisman Bertazi
kernel test robot  writes:

> Hi Gabriel,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on tytso-ext4/dev]
> [also build test ERROR on jaegeuk-f2fs/dev-test linus/master v5.19-rc3 
> next-20220622]
> [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]
>
> url:
> https://github.com/intel-lab-lkp/linux/commits/Gabriel-Krisman-Bertazi/Support-negative-dentries-on-case-insensitive-directories/20220623-034942
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
> config: x86_64-randconfig-a006 
> (https://download.01.org/0day-ci/archive/20220623/202206231550.0jrilbjp-...@intel.com/config)
> compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
> reproduce (this is a W=1 build):
> # 
> https://github.com/intel-lab-lkp/linux/commit/69488ccc517a48af2f1cec0efb84651397edf6f6
> git remote add linux-review https://github.com/intel-lab-lkp/linux
> git fetch --no-tags linux-review 
> Gabriel-Krisman-Bertazi/Support-negative-dentries-on-case-insensitive-directories/20220623-034942
> git checkout 69488ccc517a48af2f1cec0efb84651397edf6f6
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
>
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot 
>
> All errors (new ones prefixed by >>, old ones prefixed by <<):
>
>>> ERROR: modpost: "d_set_casefold_lookup" [fs/ext4/ext4.ko] undefined!

Hm, missing the EXPORT_SYMBOL() since this is called from filesystems.
I will add it for v2.

-- 
Gabriel Krisman Bertazi


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [man-pages RFC PATCH] statx.2, open.2: document STATX_DIOALIGN

2022-06-23 Thread Darrick J. Wong
On Thu, Jun 16, 2022 at 01:21:41PM -0700, Eric Biggers wrote:
> From: Eric Biggers 
> 
> Document the proposed STATX_DIOALIGN support for statx()
> (https://lore.kernel.org/linux-fsdevel/20220616201506.124209-1-ebigg...@kernel.org).
> 
> Signed-off-by: Eric Biggers 
> ---
>  man2/open.2  | 43 ---
>  man2/statx.2 | 32 +++-
>  2 files changed, 63 insertions(+), 12 deletions(-)
> 
> diff --git a/man2/open.2 b/man2/open.2
> index d1485999f..ef29847c3 100644
> --- a/man2/open.2
> +++ b/man2/open.2
> @@ -1732,21 +1732,42 @@ of user-space buffers and the file offset of I/Os.
>  In Linux alignment
>  restrictions vary by filesystem and kernel version and might be
>  absent entirely.
> -However there is currently no filesystem\-independent
> -interface for an application to discover these restrictions for a given
> -file or filesystem.
> -Some filesystems provide their own interfaces
> -for doing so, for example the
> +The handling of misaligned
> +.B O_DIRECT
> +I/Os also varies; they can either fail with
> +.B EINVAL
> +or fall back to buffered I/O.
> +.PP
> +Since Linux 5.20,
> +.B O_DIRECT
> +support and alignment restrictions for a file can be queried using
> +.BR statx (2),
> +using the
> +.B STATX_DIOALIGN
> +flag.
> +Support for
> +.B STATX_DIOALIGN
> +varies by filesystem; see
> +.BR statx (2).
> +.PP
> +Some filesystems provide their own interfaces for querying
> +.B O_DIRECT
> +alignment restrictions, for example the
>  .B XFS_IOC_DIOINFO
>  operation in
>  .BR xfsctl (3).
> +.B STATX_DIOALIGN
> +should be used instead when it is available.
>  .PP
> -Under Linux 2.4, transfer sizes, the alignment of the user buffer,
> -and the file offset must all be multiples of the logical block size
> -of the filesystem.
> -Since Linux 2.6.0, alignment to the logical block size of the
> -underlying storage (typically 512 bytes) suffices.
> -The logical block size can be determined using the
> +If none of the above is available, then direct I/O support and alignment
> +restrictions can only be assumed from known characteristics of the 
> filesystem,
> +the individual file, the underlying storage device(s), and the kernel 
> version.
> +In Linux 2.4, most block device based filesystems require that the file 
> offset
> +and the length and memory address of all I/O segments be multiples of the
> +filesystem block size (typically 4096 bytes).
> +In Linux 2.6.0, this was relaxed to the logical block size of the block 
> device
> +(typically 512 bytes).
> +A block device's logical block size can be determined using the
>  .BR ioctl (2)
>  .B BLKSSZGET
>  operation or from the shell using the command:
> diff --git a/man2/statx.2 b/man2/statx.2
> index a8620be6f..fff0a63ec 100644
> --- a/man2/statx.2
> +++ b/man2/statx.2
> @@ -61,7 +61,12 @@ struct statx {
> containing the filesystem where the file resides */
>  __u32 stx_dev_major;   /* Major ID */
>  __u32 stx_dev_minor;   /* Minor ID */
> +
>  __u64 stx_mnt_id;  /* Mount ID */
> +
> +/* Direct I/O alignment restrictions */
> +__u32 stx_dio_mem_align;
> +__u32 stx_dio_offset_align;
>  };
>  .EE
>  .in
> @@ -244,8 +249,11 @@ STATX_SIZE   Want stx_size
>  STATX_BLOCKS Want stx_blocks
>  STATX_BASIC_STATS[All of the above]
>  STATX_BTIME  Want stx_btime
> +STATX_ALLThe same as STATX_BASIC_STATS | STATX_BTIME.
> + This is deprecated and should not be used.

STATX_ALL is deprecated??  I was under the impression that _ALL meant
all the known bits for that kernel release, but...

>  STATX_MNT_ID Want stx_mnt_id (since Linux 5.8)

...I guess that is not correct.

> -STATX_ALL[All currently available fields]
> +STATX_DIOALIGN   Want stx_dio_mem_align and stx_dio_offset_align
> + (since Linux 5.20; support varies by filesystem)
>  .TE
>  .in
>  .PP
> @@ -406,6 +414,28 @@ This is the same number reported by
>  .BR name_to_handle_at (2)
>  and corresponds to the number in the first field in one of the records in
>  .IR /proc/self/mountinfo .
> +.TP
> +.I stx_dio_mem_align
> +The alignment (in bytes) required for user memory buffers for direct I/O
> +.BR "" ( O_DIRECT )
> +on this file. or 0 if direct I/O is not supported on this file.

"...on this file, or 0 if..."

> +.IP
> +.B STATX_DIOALIGN
> +.IR "" ( stx_dio_mem_align
> +and
> +.IR stx_dio_offset_align )
> +is supported on block devices since Linux 5.20.
> +The support on regular files varies by filesystem; it is supported by ext4 
> and
> +f2fs since Linux 5.20.

If the VFS changes don't provoke further bikeshedding, I'll contribute
an XFS patch to go with your series.

--D

> +.TP
> +.I stx_dio_offset_align
> +The alignment (in bytes) required for file offsets and I/O segment lengths 
> for
> +direct I/O
> +.BR "" ( O_DIRECT )
> +on this file, or 0 if direct I/O is not supported on this file.
> +This will only be nonzero if
> +.I stx_dio_mem_align
> +is nonzero, and vice 

Re: [f2fs-dev] [PATCH v3 1/8] statx: add direct I/O alignment information

2022-06-23 Thread Darrick J. Wong
On Thu, Jun 16, 2022 at 01:14:59PM -0700, Eric Biggers wrote:
> From: Eric Biggers 
> 
> Traditionally, the conditions for when DIO (direct I/O) is supported
> were fairly simple.  For both block devices and regular files, DIO had
> to be aligned to the logical block size of the block device.
> 
> However, due to filesystem features that have been added over time (e.g.
> multi-device support, data journalling, inline data, encryption, verity,
> compression, checkpoint disabling, log-structured mode), the conditions
> for when DIO is allowed on a regular file have gotten increasingly
> complex.  Whether a particular regular file supports DIO, and with what
> alignment, can depend on various file attributes and filesystem mount
> options, as well as which block device(s) the file's data is located on.
> 
> Moreover, the general rule of DIO needing to be aligned to the block
> device's logical block size is being relaxed to allow user buffers (but
> not file offsets) aligned to the DMA alignment instead
> (https://lore.kernel.org/linux-block/20220610195830.3574005-1-kbu...@fb.com/T/#u).
> 
> XFS has an ioctl XFS_IOC_DIOINFO that exposes DIO alignment information.
> Uplifting this to the VFS is one possibility.  However, as discussed
> (https://lore.kernel.org/linux-fsdevel/20220120071215.123274-1-ebigg...@kernel.org/T/#u),
> this ioctl is rarely used and not known to be used outside of
> XFS-specific code.  It was also never intended to indicate when a file
> doesn't support DIO at all, nor was it intended for block devices.
> 
> Therefore, let's expose this information via statx().  Add the
> STATX_DIOALIGN flag and two new statx fields associated with it:
> 
> * stx_dio_mem_align: the alignment (in bytes) required for user memory
>   buffers for DIO, or 0 if DIO is not supported on the file.
> 
> * stx_dio_offset_align: the alignment (in bytes) required for file
>   offsets and I/O segment lengths for DIO, or 0 if DIO is not supported
>   on the file.  This will only be nonzero if stx_dio_mem_align is
>   nonzero, and vice versa.
> 
> Note that as with other statx() extensions, if STATX_DIOALIGN isn't set
> in the returned statx struct, then these new fields won't be filled in.
> This will happen if the file is neither a regular file nor a block
> device, or if the file is a regular file and the filesystem doesn't
> support STATX_DIOALIGN.  It might also happen if the caller didn't
> include STATX_DIOALIGN in the request mask, since statx() isn't required
> to return unrequested information.
> 
> This commit only adds the VFS-level plumbing for STATX_DIOALIGN.  For
> regular files, individual filesystems will still need to add code to
> support it.  For block devices, a separate commit will wire it up too.
> 
> Signed-off-by: Eric Biggers 
> ---
>  fs/stat.c | 2 ++
>  include/linux/stat.h  | 2 ++
>  include/uapi/linux/stat.h | 4 +++-
>  3 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/stat.c b/fs/stat.c
> index 9ced8860e0f35..a7930d7444830 100644
> --- a/fs/stat.c
> +++ b/fs/stat.c
> @@ -611,6 +611,8 @@ cp_statx(const struct kstat *stat, struct statx __user 
> *buffer)
>   tmp.stx_dev_major = MAJOR(stat->dev);
>   tmp.stx_dev_minor = MINOR(stat->dev);
>   tmp.stx_mnt_id = stat->mnt_id;
> + tmp.stx_dio_mem_align = stat->dio_mem_align;
> + tmp.stx_dio_offset_align = stat->dio_offset_align;
>  
>   return copy_to_user(buffer, , sizeof(tmp)) ? -EFAULT : 0;
>  }
> diff --git a/include/linux/stat.h b/include/linux/stat.h
> index 7df06931f25d8..ff277ced50e9f 100644
> --- a/include/linux/stat.h
> +++ b/include/linux/stat.h
> @@ -50,6 +50,8 @@ struct kstat {
>   struct timespec64 btime;/* File creation time */
>   u64 blocks;
>   u64 mnt_id;
> + u32 dio_mem_align;
> + u32 dio_offset_align;

Hmm.  Does the XFS port of XFS_IOC_DIOINFO to STATX_DIOALIGN look like
this?

struct xfs_buftarg  *target = xfs_inode_buftarg(ip);

kstat.dio_mem_align = target->bt_logical_sectorsize;
kstat.dio_offset_align = target->bt_logical_sectorsize;
kstat.result_mask |= STATX_DIOALIGN;

And I guess you're tabling the "optimal" IO discussions for now, because
there are too many variants of what that means?

--D

>  };
>  
>  #endif
> diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h
> index 1500a0f58041a..7cab2c65d3d7f 100644
> --- a/include/uapi/linux/stat.h
> +++ b/include/uapi/linux/stat.h
> @@ -124,7 +124,8 @@ struct statx {
>   __u32   stx_dev_minor;
>   /* 0x90 */
>   __u64   stx_mnt_id;
> - __u64   __spare2;
> + __u32   stx_dio_mem_align;  /* Memory buffer alignment for direct 
> I/O */
> + __u32   stx_dio_offset_align;   /* File offset alignment for direct I/O 
> */
>   /* 0xa0 */
>   __u64   __spare3[12];   /* Spare space for future expansion */
>   /* 0x100 */
> @@ -152,6 +153,7 @@ 

Re: [f2fs-dev] [PATCH 7/7] f2fs: Enable negative dentries on case-insensitive lookup

2022-06-23 Thread kernel test robot
Hi Gabriel,

I love your patch! Yet something to improve:

[auto build test ERROR on tytso-ext4/dev]
[also build test ERROR on jaegeuk-f2fs/dev-test linus/master v5.19-rc3 
next-20220623]
[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]

url:
https://github.com/intel-lab-lkp/linux/commits/Gabriel-Krisman-Bertazi/Support-negative-dentries-on-case-insensitive-directories/20220623-034942
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
config: x86_64-randconfig-a006 
(https://download.01.org/0day-ci/archive/20220623/202206231838.e75vwty3-...@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# 
https://github.com/intel-lab-lkp/linux/commit/ab740b793e65b54ce8f48c693b86761f5bcaa911
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Gabriel-Krisman-Bertazi/Support-negative-dentries-on-case-insensitive-directories/20220623-034942
git checkout ab740b793e65b54ce8f48c693b86761f5bcaa911
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot 

All errors (new ones prefixed by >>, old ones prefixed by <<):

ERROR: modpost: "d_set_casefold_lookup" [fs/ext4/ext4.ko] undefined!
>> ERROR: modpost: "d_set_casefold_lookup" [fs/f2fs/f2fs.ko] undefined!

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


Re: [f2fs-dev] [PATCH 6/7] ext4: Enable negative dentries on case-insensitive lookup

2022-06-23 Thread kernel test robot
Hi Gabriel,

I love your patch! Yet something to improve:

[auto build test ERROR on tytso-ext4/dev]
[also build test ERROR on jaegeuk-f2fs/dev-test linus/master v5.19-rc3 
next-20220622]
[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]

url:
https://github.com/intel-lab-lkp/linux/commits/Gabriel-Krisman-Bertazi/Support-negative-dentries-on-case-insensitive-directories/20220623-034942
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
config: x86_64-randconfig-a006 
(https://download.01.org/0day-ci/archive/20220623/202206231550.0jrilbjp-...@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# 
https://github.com/intel-lab-lkp/linux/commit/69488ccc517a48af2f1cec0efb84651397edf6f6
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review 
Gabriel-Krisman-Bertazi/Support-negative-dentries-on-case-insensitive-directories/20220623-034942
git checkout 69488ccc517a48af2f1cec0efb84651397edf6f6
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot 

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "d_set_casefold_lookup" [fs/ext4/ext4.ko] undefined!

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


___
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel