diff mbox series

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

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

Commit Message

Pankaj Raghav (Samsung) May 6, 2024, 3:01 p.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>
---
 src/seek_sanity_test.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Zorro Lang May 7, 2024, 6:10 p.m. UTC | #1
On Mon, May 06, 2024 at 05:01:18PM +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>
> ---

Makes sense to me,

Reviewed-by: Zorro Lang <zlang@redhat.com>

>  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..bc30f77c 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) * 14, 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) * 14, 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
>
Darrick J. Wong May 7, 2024, 10:24 p.m. UTC | #2
On Mon, May 06, 2024 at 05:01:18PM +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>
> ---
>  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..bc30f77c 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) * 14, alloc_size);

Why is the page size multiplied by 14?

--D

>  	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) * 14, 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 (Samsung) May 8, 2024, 10:05 a.m. UTC | #3
On Tue, May 07, 2024 at 03:24:07PM -0700, Darrick J. Wong wrote:
> On Mon, May 06, 2024 at 05:01:18PM +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>
> > ---
> >  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..bc30f77c 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) * 14, alloc_size);
> 
> Why is the page size multiplied by 14?

Ah, that is a copy pasta error from test 14 and test 15. I will change
it in the next version. Thanks.

> 
> --D
> 
> >  	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) * 14, 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
> >
diff mbox series

Patch

diff --git a/src/seek_sanity_test.c b/src/seek_sanity_test.c
index 48b3ccc0..bc30f77c 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) * 14, 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) * 14, 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) {