diff mbox series

[v3,2/3] generic/436: round up bufsz to nearest filesystem blksz

Message ID 20240527114834.167521-3-kernel@pankajraghav.com (mailing list archive)
State New
Headers show
Series more lbs test fixes | expand

Commit Message

Pankaj Raghav (Samsung) May 27, 2024, 11:48 a.m. UTC
From: Pankaj Raghav <p.raghav@samsung.com>

SEEK_HOLE and SEEK_DATA work in filesystem block size granularity. So
while filling up the buffer for test 13 - 16, round up the bufsz to the
closest filesystem blksz.

As we only allowed blocksizes lower than the pagesize, this was never an
issue and it always aligned. Once we have blocksize > pagesize, this
assumption will break.

Fixes the test for LBS configuration.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
---
 src/seek_sanity_test.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Pankaj Raghav (Samsung) May 27, 2024, 1:01 p.m. UTC | #1
On Mon, May 27, 2024 at 01:48:33PM +0200, Pankaj Raghav (Samsung) wrote:
> From: Pankaj Raghav <p.raghav@samsung.com>
> 
> SEEK_HOLE and SEEK_DATA work in filesystem block size granularity. So
> while filling up the buffer for test 13 - 16, round up the bufsz to the
> closest filesystem blksz.
> 
> As we only allowed blocksizes lower than the pagesize, this was never an
> issue and it always aligned. Once we have blocksize > pagesize, this
> assumption will break.
> 
> Fixes the test for LBS configuration.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Looks like I missed the RVB from Darrick [1].

@Zorro could you fix it up before you commit?

[1] https://lore.kernel.org/fstests/20240517155437.GK360908@frogsfrogsfrogs/
> ---
>  src/seek_sanity_test.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
> index 48b3ccc0..a61ed3da 100644
> --- a/src/seek_sanity_test.c
> +++ b/src/seek_sanity_test.c
> @@ -541,7 +541,7 @@ static int test16(int fd, int testnum)
>  {
>  	int ret = 0;
>  	char *buf = NULL;
> -	int bufsz = sysconf(_SC_PAGE_SIZE);
> +	int bufsz = roundup(sysconf(_SC_PAGE_SIZE), alloc_size);
>  	int filsz = 4 << 20;
>  
>  	if (!unwritten_extents) {
> @@ -591,7 +591,7 @@ static int test15(int fd, int testnum)
>  {
>  	int ret = 0;
>  	char *buf = NULL;
> -	int bufsz = sysconf(_SC_PAGE_SIZE);
> +	int bufsz = roundup(sysconf(_SC_PAGE_SIZE), alloc_size);
>  	int filsz = 4 << 20;
>  
>  	if (!unwritten_extents) {
> @@ -643,7 +643,7 @@ static int test14(int fd, int testnum)
>  {
>  	int ret = 0;
>  	char *buf = NULL;
> -	int bufsz = sysconf(_SC_PAGE_SIZE) * 14;
> +	int bufsz = roundup(sysconf(_SC_PAGE_SIZE) * 14, alloc_size);
>  	int filsz = 4 << 20;
>  
>  	if (!unwritten_extents) {
> @@ -692,7 +692,7 @@ static int test13(int fd, int testnum)
>  {
>  	int ret = 0;
>  	char *buf = NULL;
> -	int bufsz = sysconf(_SC_PAGE_SIZE) * 14;
> +	int bufsz = roundup(sysconf(_SC_PAGE_SIZE) * 14, alloc_size);
>  	int filsz = 4 << 20;
>  
>  	if (!unwritten_extents) {
> -- 
> 2.34.1
>
Zorro Lang May 27, 2024, 1:26 p.m. UTC | #2
On Mon, May 27, 2024 at 01:01:11PM +0000, Pankaj Raghav (Samsung) wrote:
> On Mon, May 27, 2024 at 01:48:33PM +0200, Pankaj Raghav (Samsung) wrote:
> > From: Pankaj Raghav <p.raghav@samsung.com>
> > 
> > SEEK_HOLE and SEEK_DATA work in filesystem block size granularity. So
> > while filling up the buffer for test 13 - 16, round up the bufsz to the
> > closest filesystem blksz.
> > 
> > As we only allowed blocksizes lower than the pagesize, this was never an
> > issue and it always aligned. Once we have blocksize > pagesize, this
> > assumption will break.
> > 
> > Fixes the test for LBS configuration.
> > 
> > Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> > Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> Looks like I missed the RVB from Darrick [1].
> 
> @Zorro could you fix it up before you commit?

Sure, if there's not more review points, I'll merge it with this change.

Thanks,
Zorro

> 
> [1] https://lore.kernel.org/fstests/20240517155437.GK360908@frogsfrogsfrogs/
> > ---
> >  src/seek_sanity_test.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
> > index 48b3ccc0..a61ed3da 100644
> > --- a/src/seek_sanity_test.c
> > +++ b/src/seek_sanity_test.c
> > @@ -541,7 +541,7 @@ static int test16(int fd, int testnum)
> >  {
> >  	int ret = 0;
> >  	char *buf = NULL;
> > -	int bufsz = sysconf(_SC_PAGE_SIZE);
> > +	int bufsz = roundup(sysconf(_SC_PAGE_SIZE), alloc_size);
> >  	int filsz = 4 << 20;
> >  
> >  	if (!unwritten_extents) {
> > @@ -591,7 +591,7 @@ static int test15(int fd, int testnum)
> >  {
> >  	int ret = 0;
> >  	char *buf = NULL;
> > -	int bufsz = sysconf(_SC_PAGE_SIZE);
> > +	int bufsz = roundup(sysconf(_SC_PAGE_SIZE), alloc_size);
> >  	int filsz = 4 << 20;
> >  
> >  	if (!unwritten_extents) {
> > @@ -643,7 +643,7 @@ static int test14(int fd, int testnum)
> >  {
> >  	int ret = 0;
> >  	char *buf = NULL;
> > -	int bufsz = sysconf(_SC_PAGE_SIZE) * 14;
> > +	int bufsz = roundup(sysconf(_SC_PAGE_SIZE) * 14, alloc_size);
> >  	int filsz = 4 << 20;
> >  
> >  	if (!unwritten_extents) {
> > @@ -692,7 +692,7 @@ static int test13(int fd, int testnum)
> >  {
> >  	int ret = 0;
> >  	char *buf = NULL;
> > -	int bufsz = sysconf(_SC_PAGE_SIZE) * 14;
> > +	int bufsz = roundup(sysconf(_SC_PAGE_SIZE) * 14, alloc_size);
> >  	int filsz = 4 << 20;
> >  
> >  	if (!unwritten_extents) {
> > -- 
> > 2.34.1
> > 
> 
> -- 
> Pankaj Raghav
>
Pankaj Raghav (Samsung) May 28, 2024, 9:12 a.m. UTC | #3
On Mon, May 27, 2024 at 09:26:37PM +0800, Zorro Lang wrote:
> On Mon, May 27, 2024 at 01:01:11PM +0000, Pankaj Raghav (Samsung) wrote:
> > On Mon, May 27, 2024 at 01:48:33PM +0200, Pankaj Raghav (Samsung) wrote:
> > > From: Pankaj Raghav <p.raghav@samsung.com>
> > > 
> > > SEEK_HOLE and SEEK_DATA work in filesystem block size granularity. So
> > > while filling up the buffer for test 13 - 16, round up the bufsz to the
> > > closest filesystem blksz.
> > > 
> > > As we only allowed blocksizes lower than the pagesize, this was never an
> > > issue and it always aligned. Once we have blocksize > pagesize, this
> > > assumption will break.
> > > 
> > > Fixes the test for LBS configuration.
> > > 
> > > Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
> > > Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> > Looks like I missed the RVB from Darrick [1].
> > 
> > @Zorro could you fix it up before you commit?
> 
> Sure, if there's not more review points, I'll merge it with this change.

Sounds good. Thanks!
diff mbox series

Patch

diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
index 48b3ccc0..a61ed3da 100644
--- a/src/seek_sanity_test.c
+++ b/src/seek_sanity_test.c
@@ -541,7 +541,7 @@  static int test16(int fd, int testnum)
 {
 	int ret = 0;
 	char *buf = NULL;
-	int bufsz = sysconf(_SC_PAGE_SIZE);
+	int bufsz = roundup(sysconf(_SC_PAGE_SIZE), alloc_size);
 	int filsz = 4 << 20;
 
 	if (!unwritten_extents) {
@@ -591,7 +591,7 @@  static int test15(int fd, int testnum)
 {
 	int ret = 0;
 	char *buf = NULL;
-	int bufsz = sysconf(_SC_PAGE_SIZE);
+	int bufsz = roundup(sysconf(_SC_PAGE_SIZE), alloc_size);
 	int filsz = 4 << 20;
 
 	if (!unwritten_extents) {
@@ -643,7 +643,7 @@  static int test14(int fd, int testnum)
 {
 	int ret = 0;
 	char *buf = NULL;
-	int bufsz = sysconf(_SC_PAGE_SIZE) * 14;
+	int bufsz = roundup(sysconf(_SC_PAGE_SIZE) * 14, alloc_size);
 	int filsz = 4 << 20;
 
 	if (!unwritten_extents) {
@@ -692,7 +692,7 @@  static int test13(int fd, int testnum)
 {
 	int ret = 0;
 	char *buf = NULL;
-	int bufsz = sysconf(_SC_PAGE_SIZE) * 14;
+	int bufsz = roundup(sysconf(_SC_PAGE_SIZE) * 14, alloc_size);
 	int filsz = 4 << 20;
 
 	if (!unwritten_extents) {