Skip to contentSkip to conversation

xfs: Fix 'set but not used' warning in xfs_bmap_compute_alignments()

PATCH In review Chandan Babu R 3 participants 5 messages Jan 27, 2021 – Jan 29, 2021 1 message not in the archive XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: Fix 'set but not used' warning in xfs_bmap_compute_alignments()

With both CONFIG_XFS_DEBUG and CONFIG_XFS_WARN disabled, the only reference to local variable "error" in xfs_bmap_compute_alignments() gets eliminated during pre-processing stage of the compilation process. This causes the compiler to generate a "set but not used" warning.

---
This patch is applicable on top of current xfs-linux/for-next branch.

 fs/xfs/libxfs/xfs_bmap.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +4 -5
index 2cd24bb06040..ba56554e8c05 100644
@@ -3471,7 +3471,6 @@ xfs_bmap_compute_alignments(
 	struct xfs_mount	*mp = args->mp;
 	xfs_extlen_t		align = 0; /* minimum allocation alignment */
 	int			stripe_align = 0;
-	int			error;
 
 	/* stripe alignment for allocation is determined by mount parameters */
 	if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC))
@@ -3484,10 +3483,10 @@ xfs_bmap_compute_alignments(
 	else if (ap->datatype & XFS_ALLOC_USERDATA)
 		align = xfs_get_extsz_hint(ap->ip);
 	if (align) {
-		error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
-						align, 0, ap->eof, 0, ap->conv,
-						&ap->offset, &ap->length);
-		ASSERT(!error);
+		if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
+			align, 0, ap->eof, 0, ap->conv, &ap->offset,
+			&ap->length))
+			ASSERT(0);
 		ASSERT(ap->length);
 	}
 
Signature · 1 line
2.29.2
#1 lore raw
Quoted 27 lines · Chandan Babu R

With both CONFIG_XFS_DEBUG and CONFIG_XFS_WARN disabled, the only reference to local variable "error" in xfs_bmap_compute_alignments() gets eliminated during pre-processing stage of the compilation process. This causes the compiler to generate a "set but not used" warning.

---
This patch is applicable on top of current xfs-linux/for-next branch.

 fs/xfs/libxfs/xfs_bmap.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +0 -1
index 2cd24bb06040..ba56554e8c05 100644
@@ -3471,7 +3471,6 @@ xfs_bmap_compute_alignments(
 	struct xfs_mount	*mp = args->mp;
 	xfs_extlen_t		align = 0; /* minimum allocation alignment */
 	int			stripe_align = 0;
-	int			error;
 
 	/* stripe alignment for allocation is determined by mount parameters */
 	if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC))
@@ -3484,10 +3483,10 @@ xfs_bmap_compute_alignments(
 	else if (ap->datatype & XFS_ALLOC_USERDATA)

fs/xfs/libxfs/xfs_bmap.c xfs_bmap_compute_alignments( · line 3489

Quoted 10 lines
fs/xfs/libxfs/xfs_bmap.c +4 -4
 		align = xfs_get_extsz_hint(ap->ip);
 	if (align) {
-		error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
-						align, 0, ap->eof, 0, ap->conv,
-						&ap->offset, &ap->length);
-		ASSERT(!error);
+		if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
+			align, 0, ap->eof, 0, ap->conv, &ap->offset,
+			&ap->length))
+			ASSERT(0);

I was wondering if we should just make xfs_bmap_extsize_align() return void and push the asserts down into the function itself, but it looks like xfs_bmap_rtalloc() actually handles the error. Any idea on why we might have that inconsistency?

Brian

Quoted 6 lines
fs/xfs/libxfs/xfs_bmap.c +0 -0
 		ASSERT(ap->length);
 	}
 
Signature · 1 line
2.29.2
#2 lore raw
Quoted 35 lines · Brian Foster
Quoted 34 lines · Chandan Babu R

With both CONFIG_XFS_DEBUG and CONFIG_XFS_WARN disabled, the only reference to local variable "error" in xfs_bmap_compute_alignments() gets eliminated during pre-processing stage of the compilation process. This causes the compiler to generate a "set but not used" warning.

---
This patch is applicable on top of current xfs-linux/for-next branch.

 fs/xfs/libxfs/xfs_bmap.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +1 -5
index 2cd24bb06040..ba56554e8c05 100644
@@ -3471,7 +3471,6 @@ xfs_bmap_compute_alignments(
 	struct xfs_mount	*mp = args->mp;
 	xfs_extlen_t		align = 0; /* minimum allocation alignment */
 	int			stripe_align = 0;
-	int			error;
 
 	/* stripe alignment for allocation is determined by mount parameters */
 	if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC))
@@ -3484,10 +3483,10 @@ xfs_bmap_compute_alignments(
 	else if (ap->datatype & XFS_ALLOC_USERDATA)
 		align = xfs_get_extsz_hint(ap->ip);
 	if (align) {
-		error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
-						align, 0, ap->eof, 0, ap->conv,
-						&ap->offset, &ap->length);
-		ASSERT(!error);
+		if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
Quoted 8 lines

fs/xfs/libxfs/xfs_bmap.c xfs_bmap_compute_alignments( · line 3489

Quoted 3 lines
fs/xfs/libxfs/xfs_bmap.c +3 -0
+			align, 0, ap->eof, 0, ap->conv, &ap->offset,
+			&ap->length))
+			ASSERT(0);

I was wondering if we should just make xfs_bmap_extsize_align() return void and push the asserts down into the function itself, but it looks like xfs_bmap_rtalloc() actually handles the error. Any idea on why we might have that inconsistency?

It only returns nonzero if isrt (the fifth parameter) is nonzero, and only if the requested range is still not aligned to the rt extent size after aligning it and eliminating any overlaps with existing extents.

--D

Quoted 9 lines

Brian

Quoted 6 lines
fs/xfs/libxfs/xfs_bmap.c +0 -0
 		ASSERT(ap->length);
 	}
 
Signature · 1 line
2.29.2
#3 lore raw
Quoted 45 lines · Darrick J. Wong
Quoted 35 lines · Brian Foster
Quoted 34 lines · Chandan Babu R

With both CONFIG_XFS_DEBUG and CONFIG_XFS_WARN disabled, the only reference to local variable "error" in xfs_bmap_compute_alignments() gets eliminated during pre-processing stage of the compilation process. This causes the compiler to generate a "set but not used" warning.

---
This patch is applicable on top of current xfs-linux/for-next branch.

 fs/xfs/libxfs/xfs_bmap.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +1 -5
index 2cd24bb06040..ba56554e8c05 100644
@@ -3471,7 +3471,6 @@ xfs_bmap_compute_alignments(
 	struct xfs_mount	*mp = args->mp;
 	xfs_extlen_t		align = 0; /* minimum allocation alignment */
 	int			stripe_align = 0;
-	int			error;
 
 	/* stripe alignment for allocation is determined by mount parameters */
 	if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC))
@@ -3484,10 +3483,10 @@ xfs_bmap_compute_alignments(
 	else if (ap->datatype & XFS_ALLOC_USERDATA)
 		align = xfs_get_extsz_hint(ap->ip);
 	if (align) {
-		error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
-						align, 0, ap->eof, 0, ap->conv,
-						&ap->offset, &ap->length);
-		ASSERT(!error);
+		if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
Quoted 8 lines

fs/xfs/libxfs/xfs_bmap.c xfs_bmap_compute_alignments( · line 3489

Quoted 3 lines
fs/xfs/libxfs/xfs_bmap.c +3 -0
+			align, 0, ap->eof, 0, ap->conv, &ap->offset,
+			&ap->length))
+			ASSERT(0);

I was wondering if we should just make xfs_bmap_extsize_align() return void and push the asserts down into the function itself, but it looks like xfs_bmap_rtalloc() actually handles the error. Any idea on why we might have that inconsistency?

Quoted 4 lines

It only returns nonzero if isrt (the fifth parameter) is nonzero, and only if the requested range is still not aligned to the rt extent size after aligning it and eliminating any overlaps with existing extents.

Adding to what Darrick has mentioned above ...

Space on realtime devices are tracked at a granularity of "rextsize" bytes. Each bit held in the data blocks of xfs_mount->m_rbmip represents usage status of a single rextsized block. Most likely this seems to be underlying reason for strict allocation alignment requirements for realtime files.

--
chandan

#5 lore raw
In reply to a message not in the archive
Quoted 63 lines · Brian Foster
Quoted 51 lines · Chandan Babu R
Quoted 45 lines · Darrick J. Wong
Quoted 35 lines · Brian Foster
Quoted 34 lines · Chandan Babu R

With both CONFIG_XFS_DEBUG and CONFIG_XFS_WARN disabled, the only reference to local variable "error" in xfs_bmap_compute_alignments() gets eliminated during pre-processing stage of the compilation process. This causes the compiler to generate a "set but not used" warning.

---
This patch is applicable on top of current xfs-linux/for-next branch.

 fs/xfs/libxfs/xfs_bmap.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_bmap.c +1 -5
index 2cd24bb06040..ba56554e8c05 100644
@@ -3471,7 +3471,6 @@ xfs_bmap_compute_alignments(
 	struct xfs_mount	*mp = args->mp;
 	xfs_extlen_t		align = 0; /* minimum allocation alignment */
 	int			stripe_align = 0;
-	int			error;
 
 	/* stripe alignment for allocation is determined by mount parameters */
 	if (mp->m_swidth && (mp->m_flags & XFS_MOUNT_SWALLOC))
@@ -3484,10 +3483,10 @@ xfs_bmap_compute_alignments(
 	else if (ap->datatype & XFS_ALLOC_USERDATA)
 		align = xfs_get_extsz_hint(ap->ip);
 	if (align) {
-		error = xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
-						align, 0, ap->eof, 0, ap->conv,
-						&ap->offset, &ap->length);
-		ASSERT(!error);
+		if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev,
Quoted 8 lines

fs/xfs/libxfs/xfs_bmap.c xfs_bmap_compute_alignments( · line 3489

Quoted 3 lines
fs/xfs/libxfs/xfs_bmap.c +3 -0
+			align, 0, ap->eof, 0, ap->conv, &ap->offset,
+			&ap->length))
+			ASSERT(0);

I was wondering if we should just make xfs_bmap_extsize_align() return void and push the asserts down into the function itself, but it looks like xfs_bmap_rtalloc() actually handles the error. Any idea on why we might have that inconsistency?

Quoted 4 lines

It only returns nonzero if isrt (the fifth parameter) is nonzero, and only if the requested range is still not aligned to the rt extent size after aligning it and eliminating any overlaps with existing extents.

Quoted 7 lines

Adding to what Darrick has mentioned above ...

Space on realtime devices are tracked at a granularity of "rextsize" bytes. Each bit held in the data blocks of xfs_mount->m_rbmip represents usage status of a single rextsized block. Most likely this seems to be underlying reason for strict allocation alignment requirements for realtime files.

Ah, I see. Could you fix the indentation/alignment of the call so it looks something like the following?

Quoted 6 lines
		if (xfs_bmap_extsize_align(mp, &ap->got, &ap->prev, align, 0,
					   ap->eof, 0, ap->conv, &ap->offset,
					   &ap->length))
			ASSERT(0);

Otherwise the patch seems fine to me.

Yeah, I'll fix it in my tree before I push out for-next again.

--D

Quoted 6 lines

Brian

Quoted 3 lines

--
chandan