Skip to contentSkip to conversation

ext4: set awu_max_opt to awu_max

PATCH Applied Pankaj Raghav 7 participants 7 messages Sep 10 – Nov 19 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: set awu_max_opt to awu_max

commit 5d894321c49e ("fs: add atomic write unit max opt to statx") added atomic write max optimal to statx. As XFS can support large atomic writes through SW, max_opt exposes the value that will be HW accelerated atomics.

As ext4 does not support SW atomics, set awu_max_opt to awu_max.

---
 fs/ext4/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/inode.c +2 -1
index 26f0f9714f03..93056c971e74 100644
@@ -6304,7 +6304,8 @@ int ext4_getattr(struct mnt_idmap *idmap, const struct path *path,
 			awu_max = sbi->s_awu_max;
 		}
 
-		generic_fill_statx_atomic_writes(stat, awu_min, awu_max, 0);
+		generic_fill_statx_atomic_writes(stat, awu_min, awu_max,
+						 awu_max);
 	}
 
 	flags = ei->i_flags & EXT4_FL_USER_VISIBLE;

base-commit: d5ba62a0b130441bcabca59c2fd2d59e65360234

Signature · 1 line
2.51.2
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 8 lines

commit 5d894321c49e ("fs: add atomic write unit max opt to statx") added atomic write max optimal to statx. As XFS can support large atomic writes through SW, max_opt exposes the value that will be HW accelerated atomics.

As ext4 does not support SW atomics, set awu_max_opt to awu_max.

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to Pankaj Raghav
Quoted 8 lines · Pankaj Raghav

commit 5d894321c49e ("fs: add atomic write unit max opt to statx") added atomic write max optimal to statx. As XFS can support large atomic writes through SW, max_opt exposes the value that will be HW accelerated atomics.

As ext4 does not support SW atomics, set awu_max_opt to awu_max.

Yes, I guess it's better to report it than not and let userspace guess. Feel free to add:

Honza

Quoted 23 lines
---
 fs/ext4/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/inode.c +2 -1
index 26f0f9714f03..93056c971e74 100644
@@ -6304,7 +6304,8 @@ int ext4_getattr(struct mnt_idmap *idmap, const struct path *path,
 			awu_max = sbi->s_awu_max;
 		}
 
-		generic_fill_statx_atomic_writes(stat, awu_min, awu_max, 0);
+		generic_fill_statx_atomic_writes(stat, awu_min, awu_max,
+						 awu_max);
 	}
 
 	flags = ei->i_flags & EXT4_FL_USER_VISIBLE;

base-commit: d5ba62a0b130441bcabca59c2fd2d59e65360234

Signature · 1 line
2.51.2
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
reviewer Reviewed-by on v1 1/1
#3 lore raw
In reply to Pankaj Raghav
Quoted 7 lines · Pankaj Raghav

commit 5d894321c49e ("fs: add atomic write unit max opt to statx") added atomic write max optimal to statx. As XFS can support large atomic writes through SW, max_opt exposes the value that will be HW accelerated atomics.

As ext4 does not support SW atomics, set awu_max_opt to awu_max.

As per the man page the awu_max_opt=0 means:

A value of zero indicates that stx_atomic_write_unit_max is the optimised limit.

[1]: https://man7.org/linux/man-pages/man2/statx.2.html

But the value of 0 isn't wrong either. Jan, added that it might be more clear to report awu_max there instead of 0. So, if are going to do it - let's add this info to the commit msg. So it doesn't look like we were trying to fix anything here ;)

btw note that bdev_statx() still reports 0 for awu_max_opt.

With that please feel free to add:

Quoted 23 lines
---
 fs/ext4/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/inode.c +2 -1
index 26f0f9714f03..93056c971e74 100644
@@ -6304,7 +6304,8 @@ int ext4_getattr(struct mnt_idmap *idmap, const struct path *path,
 			awu_max = sbi->s_awu_max;
 		}
 
-		generic_fill_statx_atomic_writes(stat, awu_min, awu_max, 0);
+		generic_fill_statx_atomic_writes(stat, awu_min, awu_max,
+						 awu_max);
 	}
 
 	flags = ei->i_flags & EXT4_FL_USER_VISIBLE;

base-commit: d5ba62a0b130441bcabca59c2fd2d59e65360234

Signature · 1 line
2.51.2
#4 lore raw

Sorry for the late reply.

Quoted 10 lines · Ritesh Harjani (IBM)
Quoted 7 lines · Pankaj Raghav

commit 5d894321c49e ("fs: add atomic write unit max opt to statx") added atomic write max optimal to statx. As XFS can support large atomic writes through SW, max_opt exposes the value that will be HW accelerated atomics.

As ext4 does not support SW atomics, set awu_max_opt to awu_max.

Quoted 8 lines

As per the man page the awu_max_opt=0 means:

A value of zero indicates that stx_atomic_write_unit_max is the optimised limit.

[1]: https://man7.org/linux/man-pages/man2/statx.2.html

But the value of 0 isn't wrong either. Jan, added that it might be more

Yes.

Quoted 4 lines

clear to report awu_max there instead of 0. So, if are going to do it - let's add this info to the commit msg. So it doesn't look like we were trying to fix anything here ;)

That is why I did not put any fixes tag, as 0 just indicates awu_max is the supported value.

I can update the commit message to make this more explicit.

I guess this is not a problem for ext4, but for XFS, is there a way for the applications to reliably know whether the atomic command will be HW accelerated or not?

For normal SSDs:
ext4: awu_min and awu_max = 0, awu_max_opt = 0
XFS: awu_min = fs block size, awu_max = SW atomic max, awu_max_opt = 0

For Atomic SSDs:
ext4 with bigalloc (without these patches): awu_min = fs block size, awu_max= HW atomic limit awu_max_opt = 0
XFS: awu_min = fs block size, awu_max = SW atomic max, awu_max_opt = HW atomic limit

As a user who would only like HW atomic path, it is very hard to know which value to use unless they know what each filesystem does.

Even though statx says zero to indicate stx_atomic_write_unit_max is the optimized limit, I think it is better for all the filesystems who support HW atomics to set the max_opt to the HW optimized limit to make life easier for the users.

Quoted 2 lines

btw note that bdev_statx() still reports 0 for awu_max_opt.

I will send a separate patch for this as well. Thanks.

--
Pankaj

reviewer Reviewed-by on v1 1/1
#5 lore raw
In reply to Pankaj Raghav
Quoted 8 lines · Pankaj Raghav

commit 5d894321c49e ("fs: add atomic write unit max opt to statx") added atomic write max optimal to statx. As XFS can support large atomic writes through SW, max_opt exposes the value that will be HW accelerated atomics.

As ext4 does not support SW atomics, set awu_max_opt to awu_max.

Hey Pankaj, I think 0 is allowed for backward compatibility as highlighted in the commit you mentioned:

	...
	Masks STATX{_ATTR}_WRITE_ATOMIC can be used to get this new field. This is
  ok for older kernels which don't support this new field, as they would
  report 0 in this field (from zeroing in cp_statx()) already.
	...

But yeah sure, advertising it as awu_max is more clearer.

Regards,
ojaswin

Quoted 23 lines
---
 fs/ext4/inode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/inode.c +2 -1
index 26f0f9714f03..93056c971e74 100644
@@ -6304,7 +6304,8 @@ int ext4_getattr(struct mnt_idmap *idmap, const struct path *path,
 			awu_max = sbi->s_awu_max;
 		}
 
-		generic_fill_statx_atomic_writes(stat, awu_min, awu_max, 0);
+		generic_fill_statx_atomic_writes(stat, awu_min, awu_max,
+						 awu_max);
 	}
 
 	flags = ei->i_flags & EXT4_FL_USER_VISIBLE;

base-commit: d5ba62a0b130441bcabca59c2fd2d59e65360234

Signature · 1 line
2.51.2
maintainer Applied
#6 lore raw
In reply to Pankaj Raghav
Quoted 8 lines · Pankaj Raghav

commit 5d894321c49e ("fs: add atomic write unit max opt to statx") added atomic write max optimal to statx. As XFS can support large atomic writes through SW, max_opt exposes the value that will be HW accelerated atomics.

As ext4 does not support SW atomics, set awu_max_opt to awu_max.

[...]

Applied, thanks!

[1/1] ext4: set awu_max_opt to awu_max

      commit: 291cccad437eafafab0357c5a3a990f995c96e67

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>