misc xfsprogs cleanups after the 5.7 merge
Hi Eric,
this series contains the differences to my port that seem useful to keep.
PATCH 1/8 libxfs: use tabs instead of spaces in div_u64
--- libxfs/libxfs_priv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
libxfs/libxfs_priv.h +2 -2
@@ -263,8 +263,8 @@ div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)*/ static inline uint64_t div_u64 (uint64_t dividend,uint32_t divisor) { -uint32_t remainder; -return div_u64_rem (dividend, divisor, &remainder); +uint32_t remainder; +return div_u64_rem (dividend, divisor, &remainder); }/**
Signature · 1 line
2.26.2
Re: [PATCH 1/8] libxfs: use tabs instead of spaces in div_u64
Quoted 1 line · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
--D
Quoted 22 lines
--- libxfs/libxfs_priv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)libxfs/libxfs_priv.h +2
-2@@ -263,8 +263,8 @@ div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)*/ static inline uint64_t div_u64 (uint64_t dividend,uint32_t divisor) { -uint32_t remainder; -return div_u64_rem (dividend, divisor, &remainder); +uint32_t remainder; +return div_u64_rem (dividend, divisor, &remainder); }/** Signature · 1 line
2.26.2
Re: [PATCH 1/8] libxfs: use tabs instead of spaces in div_u64
In reply to Christoph HellwigQuoted 2 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>---
oh that's embarrassing.... Thanks for this and the other fixes, I had meant to go through the differences but tough to keep up with you. ;)
-Eric
Quoted 19 lines
libxfs/libxfs_priv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)libxfs/libxfs_priv.h +2
-2@@ -263,8 +263,8 @@ div_u64_rem(uint64_t dividend, uint32_t divisor, uint32_t *remainder)*/ static inline uint64_t div_u64 (uint64_t dividend,uint32_t divisor) { -uint32_t remainder; -return div_u64_rem (dividend, divisor, &remainder); +uint32_t remainder; +return div_u64_rem (dividend, divisor, &remainder); }/**
PATCH 2/8 db: fix a comment in scan_freelist
In reply to Christoph HellwigXFS_BUF_TO_AGFL_BNO has been renamed to open coded xfs_buf_to_agfl_bno.
--- db/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
db/check.c +1 -1
@@ -4075,7 +4075,7 @@ scan_freelist(return ; } -/* open coded XFS_BUF_TO_AGFL_BNO */ +/* open coded xfs_buf_to_agfl_bno */ state.count =0 ; state.agno = seqno;libxfs_agfl_walk (mp, agf, iocur_top->bp, scan_agfl, &state);
Signature · 1 line
2.26.2
Re: [PATCH 2/8] db: fix a comment in scan_freelist
Quoted 3 lines · Christoph Hellwig
XFS_BUF_TO_AGFL_BNOhas been renamed to open codedxfs_buf_to_agfl_bno.Signed-off-by Christoph Hellwig <[email protected]>
LGTM
--D
Quoted 20 lines
--- db/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)db/check.c +1
-1@@ -4075,7 +4075,7 @@ scan_freelist(return ; } -/* open coded XFS_BUF_TO_AGFL_BNO */ +/* open coded xfs_buf_to_agfl_bno */ state.count =0 ; state.agno = seqno;libxfs_agfl_walk (mp, agf, iocur_top->bp, scan_agfl, &state);Signature · 1 line
2.26.2
PATCH 3/8 db: add a comment to agfl_crc_flds
In reply to Christoph HellwigExplain the bno field that is not actually part of the structure anymore.
--- db/agfl.c | 1 + 1 file changed, 1 insertion(+)
db/agfl.c +1 -0
@@ -47,6 +47,7 @@ const field_t agfl_crc_flds[] = { { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE }, { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE }, { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE }, +/* the bno array really is behind the actual structure */ { "bno", FLDT_AGBLOCKNZ, OI(bitize(sizeof(struct xfs_agfl))), agfl_bno_size, FLD_ARRAY|FLD_COUNT, TYP_DATA }, { NULL }
Signature · 1 line
2.26.2
Re: [PATCH 3/8] db: add a comment to agfl_crc_flds
Quoted 13 lines · Christoph Hellwig
Explain the bno field that is not actually part of the structure anymore.
Signed-off-by Christoph Hellwig <[email protected]>--- db/agfl.c | 1 + 1 file changed, 1 insertion(+)db/agfl.c +0
-0
db/agfl.c const field_t agfl_crc_flds[] = { · line 50
Quoted 4 lines
db/agfl.c +1
-0@@ -47,6 +47,7 @@ const field_t agfl_crc_flds[] = { { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE }, { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE }, { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE }, + /* the bno array really is behind the actual structure */
Er... the bno array comes /after/ the actual structure, right?
--D
Quoted 6 lines
db/agfl.c +0
-0{"bno" ,FLDT_AGBLOCKNZ ,OI (bitize (sizeof (struct xfs_agfl ))), agfl_bno_size, FLD_ARRAY|FLD_COUNT, TYP_DATA }, { NULL }Signature · 1 line
2.26.2
Re: [PATCH 3/8] db: add a comment to agfl_crc_flds
Quoted 9 lines · Darrick J. Wong
Quoted 8 lines · Christoph Hellwig
Explain the bno field that is not actually part of the structure anymore.
Signed-off-by Christoph Hellwig <[email protected]>--- db/agfl.c | 1 + 1 file changed, 1 insertion(+)
Quoted 11 lines
db/agfl.c const field_t agfl_crc_flds[] = { · line 50
Quoted 9 lines
db/agfl.c +1
-0@@ -47,6 +47,7 @@ const field_t agfl_crc_flds[] = { { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE }, { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE }, { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE }, + /* the bno array really is behind the actual structure */Er... the bno array comes /after/ the actual structure, right?
Yes. That's what I mean, but after seems to be less confusing.
Re: [PATCH 3/8] db: add a comment to agfl_crc_flds
Quoted 22 lines · Christoph Hellwig
Quoted 9 lines · Darrick J. Wong
Quoted 8 lines · Christoph Hellwig
Explain the bno field that is not actually part of the structure anymore.
Signed-off-by Christoph Hellwig <[email protected]>--- db/agfl.c | 1 + 1 file changed, 1 insertion(+)Quoted 11 lines
db/agfl.c const field_t agfl_crc_flds[] = { · line 50
Quoted 9 lines
db/agfl.c +1
-0@@ -47,6 +47,7 @@ const field_t agfl_crc_flds[] = { { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE }, { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE }, { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE }, + /* the bno array really is behind the actual structure */Er... the bno array comes /after/ the actual structure, right?
Quoted 1 line
Yes. That's what I mean, but after seems to be less confusing.
so:
/* the bno array is after the actual structure */
right? I can just do that on merge.
Darrick J. Wong
Reviewed-byRe: [PATCH 3/8] db: add a comment to agfl_crc_flds
Quoted 23 lines · Eric Sandeen
Quoted 22 lines · Christoph Hellwig
Quoted 20 lines · Darrick J. Wong
Quoted 13 lines · Christoph Hellwig
Explain the bno field that is not actually part of the structure anymore.
Signed-off-by Christoph Hellwig <[email protected]>--- db/agfl.c | 1 + 1 file changed, 1 insertion(+)db/agfl.c +0
-0db/agfl.c const field_t agfl_crc_flds[] = { · line 50
Quoted 4 lines
db/agfl.c +1
-0@@ -47,6 +47,7 @@ const field_t agfl_crc_flds[] = { { "uuid", FLDT_UUID, OI(OFF(uuid)), C1, 0, TYP_NONE }, { "lsn", FLDT_UINT64X, OI(OFF(lsn)), C1, 0, TYP_NONE }, { "crc", FLDT_CRC, OI(OFF(crc)), C1, 0, TYP_NONE }, + /* the bno array really is behind the actual structure */Er... the bno array comes /after/ the actual structure, right?
Quoted 7 lines
Quoted 1 line
Yes. That's what I mean, but after seems to be less confusing.
so:
/* the bno array is after the actual structure */
right? I can just do that on merge.
With that changed,
--D
Re: [PATCH 3/8] db: add a comment to agfl_crc_flds
In reply to Eric SandeenQuoted 6 lines · Eric Sandeen
Quoted 1 line
Yes. That's what I mean, but after seems to be less confusing.
so:
/* the bno array is after the actual structure */
right? I can just do that on merge.
Looks ok.
PATCH 4/8 db: cleanup attr_set_f and attr_remove_f
In reply to Christoph HellwigDon't use local variables for information that is set in the da_args structure.
--- db/attrset.c | 67 ++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 39 deletions(-)
db/attrset.c +28 -39
@@ -67,10 +67,9 @@ attr_set_f(int argc, char **argv) { - struct xfs_inode *ip = NULL; -struct xfs_da_args args = {NULL }; -char *name, *value, *sp; -int c, valuelen =0 ; + struct xfs_da_args args = { }; +char *sp; +int c;if (cur_typ ==NULL ) {dbprintf (_ ("no current type\n" ));
@@ -111,8 +110,9 @@ attr_set_f(/* value length */ case 'v' : - valuelen = (int )strtol (optarg, &sp,0 ); -if (*sp !='\0' || valuelen <0 || valuelen >64 *1024 ) { + args.valuelen =strtol (optarg, &sp,0 ); +if (*sp !='\0' || + args.valuelen <0 || args.valuelen >64 *1024 ) {dbprintf (_ ("bad attr_set valuelen %s\n" ), optarg);return 0 ; }
@@ -129,35 +129,29 @@ attr_set_f(return 0 ; } - name = argv[optind]; + args.name = (const unsigned char *)argv[optind]; + args.namelen =strlen (argv[optind]); -if (valuelen) { - value = (char *)memalign (getpagesize (), valuelen); -if (!value) { -dbprintf (_ ("cannot allocate buffer (%d)\n" ), valuelen); +if (args.valuelen) { + args.value =memalign (getpagesize (), args.valuelen); +if (!args.value) { +dbprintf (_ ("cannot allocate buffer (%d)\n" ), + args.valuelen); goto out; } -memset (value,'v' , valuelen); - }else { - value =NULL ; +memset (args.value,'v' , args.valuelen); } -if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &ip, +if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &args.dp, &xfs_default_ifork_ops)) {dbprintf (_ ("failed to iget inode %llu\n" ), (unsigned long long )iocur_top->ino); goto out; } - args.dp = ip; - args.name = (unsigned char *)name; - args.namelen =strlen (name); - args.value = value; - args.valuelen = valuelen; -if (libxfs_attr_set (&args)) {dbprintf (_ ("failed to set attr %s on inode %llu\n" ), - name, (unsigned long long )iocur_top->ino); + args.name, (unsigned long long )iocur_top->ino); goto out; }
@@ -166,10 +160,10 @@ attr_set_f( out: mp->m_flags &= ~LIBXFS_MOUNT_COMPAT_ATTR ; -if (ip) -libxfs_irele (ip); -if (value) -free (value); +if (args.dp) +libxfs_irele (args.dp); +if (args.value) +free (args.value);return 0 ; }
@@ -178,9 +172,7 @@ attr_remove_f(int argc, char **argv) { - struct xfs_inode *ip = NULL; -struct xfs_da_args args = {NULL }; -char *name; + struct xfs_da_args args = { };int c;if (cur_typ ==NULL ) {
@@ -223,23 +215,20 @@ attr_remove_f(return 0 ; } - name = argv[optind]; + args.name = (const unsigned char *)argv[optind]; + args.namelen =strlen (argv[optind]); -if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &ip, +if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &args.dp, &xfs_default_ifork_ops)) {dbprintf (_ ("failed to iget inode %llu\n" ), (unsigned long long )iocur_top->ino); goto out; } - args.dp = ip; - args.name = (unsigned char *)name; - args.namelen =strlen (name); - args.value =NULL ; -if (libxfs_attr_set (&args)) {dbprintf (_ ("failed to remove attr %s from inode %llu\n" ), - name, (unsigned long long )iocur_top->ino); + (unsigned char *)args.name, + (unsigned long long )iocur_top->ino); goto out; }
@@ -248,7 +237,7 @@ attr_remove_f( out: mp->m_flags &= ~LIBXFS_MOUNT_COMPAT_ATTR ; -if (ip) -libxfs_irele (ip); +if (args.dp) +libxfs_irele (args.dp);return 0 ; }
Signature · 1 line
2.26.2
Re: [PATCH 4/8] db: cleanup attr_set_f and attr_remove_f
Quoted 4 lines · Christoph Hellwig
Don't use local variables for information that is set in the
da_argsstructure.Signed-off-by Christoph Hellwig <[email protected]>
Seems like a good cleanup,
--D
Quoted 148 lines
--- db/attrset.c | 67 ++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 39 deletions(-)db/attrset.c +28
-39@@ -67,10 +67,9 @@ attr_set_f(int argc, char **argv) { - struct xfs_inode *ip = NULL; -struct xfs_da_args args = {NULL }; -char *name, *value, *sp; -int c, valuelen =0 ; + struct xfs_da_args args = { }; +char *sp; +int c;if (cur_typ ==NULL ) {dbprintf (_ ("no current type\n" ));@@ -111,8 +110,9 @@ attr_set_f(/* value length */ case 'v' : - valuelen = (int )strtol (optarg, &sp,0 ); -if (*sp !='\0' || valuelen <0 || valuelen >64 *1024 ) { + args.valuelen =strtol (optarg, &sp,0 ); +if (*sp !='\0' || + args.valuelen <0 || args.valuelen >64 *1024 ) {dbprintf (_ ("bad attr_set valuelen %s\n" ), optarg);return 0 ; }@@ -129,35 +129,29 @@ attr_set_f(return 0 ; } - name = argv[optind]; + args.name = (const unsigned char *)argv[optind]; + args.namelen =strlen (argv[optind]); -if (valuelen) { - value = (char *)memalign (getpagesize (), valuelen); -if (!value) { -dbprintf (_ ("cannot allocate buffer (%d)\n" ), valuelen); +if (args.valuelen) { + args.value =memalign (getpagesize (), args.valuelen); +if (!args.value) { +dbprintf (_ ("cannot allocate buffer (%d)\n" ), + args.valuelen); goto out; } -memset (value,'v' , valuelen); - }else { - value =NULL ; +memset (args.value,'v' , args.valuelen); } -if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &ip, +if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &args.dp, &xfs_default_ifork_ops)) {dbprintf (_ ("failed to iget inode %llu\n" ), (unsigned long long )iocur_top->ino); goto out; } - args.dp = ip; - args.name = (unsigned char *)name; - args.namelen =strlen (name); - args.value = value; - args.valuelen = valuelen; -if (libxfs_attr_set (&args)) {dbprintf (_ ("failed to set attr %s on inode %llu\n" ), - name, (unsigned long long )iocur_top->ino); + args.name, (unsigned long long )iocur_top->ino); goto out; }@@ -166,10 +160,10 @@ attr_set_f( out: mp->m_flags &= ~LIBXFS_MOUNT_COMPAT_ATTR ; -if (ip) -libxfs_irele (ip); -if (value) -free (value); +if (args.dp) +libxfs_irele (args.dp); +if (args.value) +free (args.value);return 0 ; }@@ -178,9 +172,7 @@ attr_remove_f(int argc, char **argv) { - struct xfs_inode *ip = NULL; -struct xfs_da_args args = {NULL }; -char *name; + struct xfs_da_args args = { };int c;if (cur_typ ==NULL ) {@@ -223,23 +215,20 @@ attr_remove_f(return 0 ; } - name = argv[optind]; + args.name = (const unsigned char *)argv[optind]; + args.namelen =strlen (argv[optind]); -if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &ip, +if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &args.dp, &xfs_default_ifork_ops)) {dbprintf (_ ("failed to iget inode %llu\n" ), (unsigned long long )iocur_top->ino); goto out; } - args.dp = ip; - args.name = (unsigned char *)name; - args.namelen =strlen (name); - args.value =NULL ; -if (libxfs_attr_set (&args)) {dbprintf (_ ("failed to remove attr %s from inode %llu\n" ), - name, (unsigned long long )iocur_top->ino); + (unsigned char *)args.name, + (unsigned long long )iocur_top->ino); goto out; }@@ -248,7 +237,7 @@ attr_remove_f( out: mp->m_flags &= ~LIBXFS_MOUNT_COMPAT_ATTR ; -if (ip) -libxfs_irele (ip); +if (args.dp) +libxfs_irele (args.dp);return 0 ; }Signature · 1 line
2.26.2
Re: [PATCH 4/8] db: cleanup attr_set_f and attr_remove_f
In reply to Christoph HellwigQuoted 2 lines · Christoph Hellwig
Don't use local variables for information that is set in the
da_argsstructure.
I'm on the fence about this one; Darrick had missed setting a couple of necessary structure members, so I actually see some value in assigning them all right before we call into libxfs_attr_set .... it makes it very clear what's being sent in to libxfs_attr_set.
-Eric
Quoted 147 lines
Signed-off-by Christoph Hellwig <[email protected]>--- db/attrset.c | 67 ++++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 39 deletions(-)db/attrset.c +28
-39@@ -67,10 +67,9 @@ attr_set_f(int argc, char **argv) { - struct xfs_inode *ip = NULL; -struct xfs_da_args args = {NULL }; -char *name, *value, *sp; -int c, valuelen =0 ; + struct xfs_da_args args = { }; +char *sp; +int c;if (cur_typ ==NULL ) {dbprintf (_ ("no current type\n" ));@@ -111,8 +110,9 @@ attr_set_f(/* value length */ case 'v' : - valuelen = (int )strtol (optarg, &sp,0 ); -if (*sp !='\0' || valuelen <0 || valuelen >64 *1024 ) { + args.valuelen =strtol (optarg, &sp,0 ); +if (*sp !='\0' || + args.valuelen <0 || args.valuelen >64 *1024 ) {dbprintf (_ ("bad attr_set valuelen %s\n" ), optarg);return 0 ; }@@ -129,35 +129,29 @@ attr_set_f(return 0 ; } - name = argv[optind]; + args.name = (const unsigned char *)argv[optind]; + args.namelen =strlen (argv[optind]); -if (valuelen) { - value = (char *)memalign (getpagesize (), valuelen); -if (!value) { -dbprintf (_ ("cannot allocate buffer (%d)\n" ), valuelen); +if (args.valuelen) { + args.value =memalign (getpagesize (), args.valuelen); +if (!args.value) { +dbprintf (_ ("cannot allocate buffer (%d)\n" ), + args.valuelen); goto out; } -memset (value,'v' , valuelen); - }else { - value =NULL ; +memset (args.value,'v' , args.valuelen); } -if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &ip, +if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &args.dp, &xfs_default_ifork_ops)) {dbprintf (_ ("failed to iget inode %llu\n" ), (unsigned long long )iocur_top->ino); goto out; } - args.dp = ip; - args.name = (unsigned char *)name; - args.namelen =strlen (name); - args.value = value; - args.valuelen = valuelen; -if (libxfs_attr_set (&args)) {dbprintf (_ ("failed to set attr %s on inode %llu\n" ), - name, (unsigned long long )iocur_top->ino); + args.name, (unsigned long long )iocur_top->ino); goto out; }@@ -166,10 +160,10 @@ attr_set_f( out: mp->m_flags &= ~LIBXFS_MOUNT_COMPAT_ATTR ; -if (ip) -libxfs_irele (ip); -if (value) -free (value); +if (args.dp) +libxfs_irele (args.dp); +if (args.value) +free (args.value);return 0 ; }@@ -178,9 +172,7 @@ attr_remove_f(int argc, char **argv) { - struct xfs_inode *ip = NULL; -struct xfs_da_args args = {NULL }; -char *name; + struct xfs_da_args args = { };int c;if (cur_typ ==NULL ) {@@ -223,23 +215,20 @@ attr_remove_f(return 0 ; } - name = argv[optind]; + args.name = (const unsigned char *)argv[optind]; + args.namelen =strlen (argv[optind]); -if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &ip, +if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &args.dp, &xfs_default_ifork_ops)) {dbprintf (_ ("failed to iget inode %llu\n" ), (unsigned long long )iocur_top->ino); goto out; } - args.dp = ip; - args.name = (unsigned char *)name; - args.namelen =strlen (name); - args.value =NULL ; -if (libxfs_attr_set (&args)) {dbprintf (_ ("failed to remove attr %s from inode %llu\n" ), - name, (unsigned long long )iocur_top->ino); + (unsigned char *)args.name, + (unsigned long long )iocur_top->ino); goto out; }@@ -248,7 +237,7 @@ attr_remove_f( out: mp->m_flags &= ~LIBXFS_MOUNT_COMPAT_ATTR ; -if (ip) -libxfs_irele (ip); +if (args.dp) +libxfs_irele (args.dp);return 0 ; }
Re: [PATCH 4/8] db: cleanup attr_set_f and attr_remove_f
Quoted 8 lines · Eric Sandeen
Quoted 2 lines · Christoph Hellwig
Don't use local variables for information that is set in the
da_argsstructure.I'm on the fence about this one; Darrick had missed setting a couple of necessary structure members, so I actually see some value in assigning them all right before we call into
libxfs_attr_set.... it makes it very clear what's being sent in tolibxfs_attr_set.
But using additional local variables doesn't help with initialing the fields, it actually makes it easier to miss, which I guess is what happened. I find the code much easier to verify without the extra variables.
Re: [PATCH 4/8] db: cleanup attr_set_f and attr_remove_f
Quoted 10 lines · Christoph Hellwig
Quoted 8 lines · Eric Sandeen
Quoted 2 lines · Christoph Hellwig
Don't use local variables for information that is set in the
da_argsstructure.I'm on the fence about this one; Darrick had missed setting a couple of necessary structure members, so I actually see some value in assigning them all right before we call into
libxfs_attr_set.... it makes it very clear what's being sent in tolibxfs_attr_set.
Quoted 4 lines
But using additional local variables doesn't help with initialing the fields, it actually makes it easier to miss, which I guess is what happened. I find the code much easier to verify without the extra variables.
They seem a bit extraneous, but my problem is I can't keep track of how much of the args structure is actually filled out when it's spread out over dozens of lines ....
*shrug* I dunno. Maybe darrick can cast the tie-breaking vote. ;)
Re: [PATCH 4/8] db: cleanup attr_set_f and attr_remove_f
Quoted 16 lines · Eric Sandeen
Quoted 10 lines · Christoph Hellwig
Quoted 8 lines · Eric Sandeen
Quoted 2 lines · Christoph Hellwig
Don't use local variables for information that is set in the
da_argsstructure.I'm on the fence about this one; Darrick had missed setting a couple of necessary structure members, so I actually see some value in assigning them all right before we call into
libxfs_attr_set.... it makes it very clear what's being sent in tolibxfs_attr_set.Quoted 4 lines
But using additional local variables doesn't help with initialing the fields, it actually makes it easier to miss, which I guess is what happened. I find the code much easier to verify without the extra variables.
Quoted 5 lines
They seem a bit extraneous, but my problem is I can't keep track of how much of the args structure is actually filled out when it's spread out over dozens of lines ....
*shrug* I dunno. Maybe darrick can cast the tie-breaking vote. ;)
I mean... I /did/ already RVB this one... :)
--D
Re: [PATCH 4/8] db: cleanup attr_set_f and attr_remove_f
Quoted 17 lines · Darrick J. Wong
Quoted 16 lines · Eric Sandeen
Quoted 14 lines · Christoph Hellwig
Quoted 8 lines · Eric Sandeen
Quoted 2 lines · Christoph Hellwig
Don't use local variables for information that is set in the
da_argsstructure.I'm on the fence about this one; Darrick had missed setting a couple of necessary structure members, so I actually see some value in assigning them all right before we call into
libxfs_attr_set.... it makes it very clear what's being sent in tolibxfs_attr_set.But using additional local variables doesn't help with initialing the fields, it actually makes it easier to miss, which I guess is what happened. I find the code much easier to verify without the extra variables.
Quoted 7 lines
Quoted 5 lines
They seem a bit extraneous, but my problem is I can't keep track of how much of the args structure is actually filled out when it's spread out over dozens of lines ....
*shrug* I dunno. Maybe darrick can cast the tie-breaking vote. ;)
I mean... I /did/ already RVB this one... :)
Before I raised the question, but *shrug* ok, I guess nobody else sees it my way so I'll merge it as is, not worth haggling over any further.
thanks for all the cleanups, Christoph.
-Eric
PATCH 5/8 db: validate name and namelen in attr_set_f and attr_remove_f
In reply to Christoph Hellwiglibxfs has stopped validating these parameters internally, so do it in the xfs_db commands.
--- db/attrset.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
db/attrset.c +18 -0
@@ -130,7 +130,16 @@ attr_set_f( } args.name = (const unsigned char *)argv[optind]; +if (!args.name) { +dbprintf (_ ("invalid name\n" )); +return 0 ; + } + args.namelen =strlen (argv[optind]); +if (args.namelen >=MAXNAMELEN ) { +dbprintf (_ ("name too long\n" )); +return 0 ; + }if (args.valuelen) { args.value =memalign (getpagesize (), args.valuelen);
@@ -216,7 +225,16 @@ attr_remove_f( } args.name = (const unsigned char *)argv[optind]; +if (!args.name) { +dbprintf (_ ("invalid name\n" )); +return 0 ; + } + args.namelen =strlen (argv[optind]); +if (args.namelen >=MAXNAMELEN ) { +dbprintf (_ ("name too long\n" )); +return 0 ; + }if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &args.dp, &xfs_default_ifork_ops)) {
Signature · 1 line
2.26.2
Re: [PATCH 5/8] db: validate name and namelen in attr_set_f and attr_remove_f
Quoted 4 lines · Christoph Hellwig
libxfs has stopped validating these parameters internally, so do it in the
xfs_dbcommands.Signed-off-by Christoph Hellwig <[email protected]>
IIRC the VFS checks these parameters so that libxfs doesn't have to, right?
If so,
--D
Quoted 45 lines
--- db/attrset.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)db/attrset.c +18
-0@@ -130,7 +130,16 @@ attr_set_f( } args.name = (const unsigned char *)argv[optind]; +if (!args.name) { +dbprintf (_ ("invalid name\n" )); +return 0 ; + } + args.namelen =strlen (argv[optind]); +if (args.namelen >=MAXNAMELEN ) { +dbprintf (_ ("name too long\n" )); +return 0 ; + }if (args.valuelen) { args.value =memalign (getpagesize (), args.valuelen);@@ -216,7 +225,16 @@ attr_remove_f( } args.name = (const unsigned char *)argv[optind]; +if (!args.name) { +dbprintf (_ ("invalid name\n" )); +return 0 ; + } + args.namelen =strlen (argv[optind]); +if (args.namelen >=MAXNAMELEN ) { +dbprintf (_ ("name too long\n" )); +return 0 ; + }if (libxfs_iget (mp,NULL , iocur_top->ino,0 , &args.dp, &xfs_default_ifork_ops)) {Signature · 1 line
2.26.2
Re: [PATCH 5/8] db: validate name and namelen in attr_set_f and attr_remove_f
Quoted 8 lines · Darrick J. Wong
Quoted 4 lines · Christoph Hellwig
libxfs has stopped validating these parameters internally, so do it in the
xfs_dbcommands.Signed-off-by Christoph Hellwig <[email protected]>IIRC the VFS checks these parameters so that libxfs doesn't have to, right?
Yes. But we don't have the VFS in xfsprogs :)
PATCH 6/8 db: ensure that create and replace are exclusive in attr_set_f
In reply to Christoph HellwigClear the other flag when applying the create or replace option, as the low-level libxfs can't handle both at the same time.
--- db/attrset.c | 2 ++ 1 file changed, 2 insertions(+)
db/attrset.c +2 -0
@@ -99,9 +99,11 @@ attr_set_f(/* modifiers */ case 'C' : args.attr_flags |=XATTR_CREATE ; + args.attr_flags &= ~XATTR_REPLACE ;break ;case 'R' : args.attr_flags |=XATTR_REPLACE ; + args.attr_flags &= ~XATTR_CREATE ;break ;case 'n' :
Signature · 1 line
2.26.2
Re: [PATCH 6/8] db: ensure that create and replace are exclusive in attr_set_f
Quoted 4 lines · Christoph Hellwig
Clear the other flag when applying the create or replace option, as the low-level libxfs can't handle both at the same time.
Signed-off-by Christoph Hellwig <[email protected]>
--D
Quoted 23 lines
--- db/attrset.c | 2 ++ 1 file changed, 2 insertions(+)db/attrset.c +2
-0@@ -99,9 +99,11 @@ attr_set_f(/* modifiers */ case 'C' : args.attr_flags |=XATTR_CREATE ; + args.attr_flags &= ~XATTR_REPLACE ;break ;case 'R' : args.attr_flags |=XATTR_REPLACE ; + args.attr_flags &= ~XATTR_CREATE ;break ;case 'n' :Signature · 1 line
2.26.2
PATCH 7/8 repair: cleanup build_agf_agfl
In reply to Christoph HellwigNo need to have two variables for the AGFL block number array.
--- repair/phase5.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
repair/phase5.c +2 -5
@@ -2149,18 +2149,15 @@ build_agf_agfl(/* setting to 0xff results in initialisation to NULLAGBLOCK */ memset (agfl,0xff , mp->m_sb.sb_sectsize); + freelist =xfs_buf_to_agfl_bno (agfl_buf);if (xfs_sb_version_hascrc (&mp->m_sb)) { -__be32 *agfl_bno =xfs_buf_to_agfl_bno (agfl_buf); - agfl->agfl_magicnum =cpu_to_be32 (XFS_AGFL_MAGIC ); agfl->agfl_seqno =cpu_to_be32 (agno);platform_uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid);for (i =0 ; i <libxfs_agfl_size (mp); i++) - agfl_bno[i] =cpu_to_be32 (NULLAGBLOCK ); + freelist[i] =cpu_to_be32 (NULLAGBLOCK ); } - freelist =xfs_buf_to_agfl_bno (agfl_buf); -/* * do we have left-over blocks in the btree cursors that should * be used to fill the AGFL?
Signature · 1 line
2.26.2
Re: [PATCH 7/8] repair: cleanup build_agf_agfl
Quoted 12 lines · Christoph Hellwig
No need to have two variables for the AGFL block number array.
Signed-off-by Christoph Hellwig <[email protected]>--- repair/phase5.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)repair/phase5.c +0
-0
repair/phase5.c build_agf_agfl( · line 2151
Quoted 3 lines
repair/phase5.c +0
-0@@ -2149,18 +2149,15 @@ build_agf_agfl(/* setting to 0xff results in initialisation to NULLAGBLOCK */ memset (agfl,0xff , mp->m_sb.sb_sectsize);
/me wonders why this memset isn't sufficient to null out the freelist, but a better cleanup would be to rip all this out in favor of adapting the nearly identical functions in xfs_ag.c.
In the meantime we don't need duplicate variables, and:
--D
Quoted 20 lines
repair/phase5.c +2
-5+ freelist =xfs_buf_to_agfl_bno (agfl_buf);if (xfs_sb_version_hascrc (&mp->m_sb)) { -__be32 *agfl_bno =xfs_buf_to_agfl_bno (agfl_buf); - agfl->agfl_magicnum =cpu_to_be32 (XFS_AGFL_MAGIC ); agfl->agfl_seqno =cpu_to_be32 (agno);platform_uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid);for (i =0 ; i <libxfs_agfl_size (mp); i++) - agfl_bno[i] =cpu_to_be32 (NULLAGBLOCK ); + freelist[i] =cpu_to_be32 (NULLAGBLOCK ); } - freelist =xfs_buf_to_agfl_bno (agfl_buf); -/* * do we have left-over blocks in the btree cursors that should * be used to fill the AGFL? Signature · 1 line
2.26.2
Re: [PATCH 7/8] repair: cleanup build_agf_agfl
Quoted 14 lines · Darrick J. Wong
Quoted 13 lines · Christoph Hellwig
No need to have two variables for the AGFL block number array.
Signed-off-by Christoph Hellwig <[email protected]>--- repair/phase5.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)repair/phase5.c +0
-0@@ -2149,18 +2149,15 @@ build_agf_agfl(
Quoted 6 lines
repair/phase5.c build_agf_agfl( · line 2151
Quoted 2 lines
repair/phase5.c +0
-0/* setting to 0xff results in initialisation to NULLAGBLOCK */ memset (agfl,0xff , mp->m_sb.sb_sectsize);/me wonders why this memset isn't sufficient to null out the freelist, but a better cleanup would be to rip all this out in favor of adapting the nearly identical functions in
xfs_ag.c.
probably because xfs_agflblock_init is
a) static and
b) expects a aghdr_init_data *id arg which isn't too convenient here I guess
Might be nice to factor xfs_agflblock_init to call a helper that this and build_agf_agfl can both use though, I'll give that a whirl.
-Eric
Quoted 27 lines
In the meantime we don't need duplicate variables, and:
Reviewed-by Darrick J. Wong <[email protected]>--D
Quoted 20 lines
repair/phase5.c +2
-5+ freelist =xfs_buf_to_agfl_bno (agfl_buf);if (xfs_sb_version_hascrc (&mp->m_sb)) { -__be32 *agfl_bno =xfs_buf_to_agfl_bno (agfl_buf); - agfl->agfl_magicnum =cpu_to_be32 (XFS_AGFL_MAGIC ); agfl->agfl_seqno =cpu_to_be32 (agno);platform_uuid_copy (&agfl->agfl_uuid, &mp->m_sb.sb_meta_uuid);for (i =0 ; i <libxfs_agfl_size (mp); i++) - agfl_bno[i] =cpu_to_be32 (NULLAGBLOCK ); + freelist[i] =cpu_to_be32 (NULLAGBLOCK ); } - freelist =xfs_buf_to_agfl_bno (agfl_buf); -/* * do we have left-over blocks in the btree cursors that should * be used to fill the AGFL? Signature · 1 line
2.26.2
PATCH 8/8 metadump: small cleanup for process_inode
In reply to Christoph HellwigShorten a conditional to a single line.
--- db/metadump.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
db/metadump.c +1 -2
@@ -2415,8 +2415,7 @@ process_inode(nametable_clear ();/* copy extended attributes if they exist and forkoff is valid */ -if (success && -XFS_DFORK_DSIZE (dip, mp) <XFS_LITINO (mp)) { +if (success &&XFS_DFORK_DSIZE (dip, mp) <XFS_LITINO (mp)) { attr_data.remote_val_count =0 ;switch (dip->di_aformat) {case XFS_DINODE_FMT_LOCAL :
Signature · 1 line
2.26.2
Re: [PATCH 8/8] metadump: small cleanup for process_inode
Quoted 3 lines · Christoph Hellwig
Shorten a conditional to a single line.
Signed-off-by Christoph Hellwig <[email protected]>
Looks good,
--D
Quoted 21 lines
--- db/metadump.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)db/metadump.c +1
-2@@ -2415,8 +2415,7 @@ process_inode(nametable_clear ();/* copy extended attributes if they exist and forkoff is valid */ -if (success && -XFS_DFORK_DSIZE (dip, mp) <XFS_LITINO (mp)) { +if (success &&XFS_DFORK_DSIZE (dip, mp) <XFS_LITINO (mp)) { attr_data.remote_val_count =0 ;switch (dip->di_aformat) {case XFS_DINODE_FMT_LOCAL :Signature · 1 line
2.26.2
Quoted 4 lines · Christoph Hellwig
Hi Eric,
this series contains the differences to my port that seem useful to keep.
I staged all of these except:
11538453 New [4/8] db: cleanup attr_set_f and attr_remove_f 11538455 New [5/8] db: validate name and namelen in attr_set_f and attr_remove_f 11538457 New [6/8] db: ensure that create and replace are exclusive in attr_set_f
because i'm not sure about patch 4/8; because the structure bits that need initialization differ a bit between set and remove, and because the initial backport missed a couple initializations, I feel like initializing the structure just before the libxfs call might be more obvious in terms of what's getting passed in.
(however, if we keep that I should make the attr_filter variable work the same way)
patches 5 and 6 just depend on the decision re: patch 4.
thanks,
-Eric