From: "Darrick J. Wong" <djwong@kernel.org>
To: cem@kernel.org, djwong@kernel.org
Cc: Shida Zhang <zhangshida@kylinos.cn>,
Dave Chinner <david@fromorbit.com>,
linux-xfs@vger.kernel.org
Subject: [PATCH 04/24] xfs: rearrange the logic and remove the broken comment for xfs_dir2_isxx
Date: Tue, 08 Nov 2022 18:06:05 -0800 [thread overview]
Message-ID: <166795956500.3761583.4853170066354811352.stgit@magnolia> (raw)
In-Reply-To: <166795954256.3761583.3551179546135782562.stgit@magnolia>
From: Shida Zhang <zhangshida@kylinos.cn>
Source kernel commit: c098576f5f63bc0ee2424bba50892514a71d54e8
xfs_dir2_isleaf is used to see if the directory is a single-leaf
form directory instead, as commented right above the function.
Besides getting rid of the broken comment, we rearrange the logic by
converting everything over to standard formatting and conventions,
at the same time, to make it easier to understand and self documenting.
Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Dave Chinner <david@fromorbit.com>
---
db/namei.c | 2 +-
libxfs/xfs_dir2.c | 50 ++++++++++++++++++++++++++++++--------------------
libxfs/xfs_dir2.h | 4 ++--
repair/phase6.c | 4 ++--
4 files changed, 35 insertions(+), 25 deletions(-)
diff --git a/db/namei.c b/db/namei.c
index 6c57cc624e..7a5d749a77 100644
--- a/db/namei.c
+++ b/db/namei.c
@@ -449,8 +449,8 @@ listdir(
.dp = dp,
.geo = dp->i_mount->m_dir_geo,
};
+ bool isblock;
int error;
- int isblock;
if (dp->i_df.if_format == XFS_DINODE_FMT_LOCAL)
return list_sfdir(&args);
diff --git a/libxfs/xfs_dir2.c b/libxfs/xfs_dir2.c
index fac072fcb1..d6a192963f 100644
--- a/libxfs/xfs_dir2.c
+++ b/libxfs/xfs_dir2.c
@@ -260,7 +260,7 @@ xfs_dir_createname(
{
struct xfs_da_args *args;
int rval;
- int v; /* type-checking value */
+ bool v;
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
@@ -356,7 +356,7 @@ xfs_dir_lookup(
{
struct xfs_da_args *args;
int rval;
- int v; /* type-checking value */
+ bool v;
int lock_mode;
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
@@ -434,7 +434,7 @@ xfs_dir_removename(
{
struct xfs_da_args *args;
int rval;
- int v; /* type-checking value */
+ bool v;
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
XFS_STATS_INC(dp->i_mount, xs_dir_remove);
@@ -492,7 +492,7 @@ xfs_dir_replace(
{
struct xfs_da_args *args;
int rval;
- int v; /* type-checking value */
+ bool v;
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
@@ -609,19 +609,23 @@ xfs_dir2_grow_inode(
int
xfs_dir2_isblock(
struct xfs_da_args *args,
- int *vp) /* out: 1 is block, 0 is not block */
+ bool *isblock)
{
- xfs_fileoff_t last; /* last file offset */
- int rval;
+ struct xfs_mount *mp = args->dp->i_mount;
+ xfs_fileoff_t eof;
+ int error;
- if ((rval = xfs_bmap_last_offset(args->dp, &last, XFS_DATA_FORK)))
- return rval;
- rval = XFS_FSB_TO_B(args->dp->i_mount, last) == args->geo->blksize;
- if (XFS_IS_CORRUPT(args->dp->i_mount,
- rval != 0 &&
- args->dp->i_disk_size != args->geo->blksize))
+ error = xfs_bmap_last_offset(args->dp, &eof, XFS_DATA_FORK);
+ if (error)
+ return error;
+
+ *isblock = false;
+ if (XFS_FSB_TO_B(mp, eof) != args->geo->blksize)
+ return 0;
+
+ *isblock = true;
+ if (XFS_IS_CORRUPT(mp, args->dp->i_disk_size != args->geo->blksize))
return -EFSCORRUPTED;
- *vp = rval;
return 0;
}
@@ -631,14 +635,20 @@ xfs_dir2_isblock(
int
xfs_dir2_isleaf(
struct xfs_da_args *args,
- int *vp) /* out: 1 is block, 0 is not block */
+ bool *isleaf)
{
- xfs_fileoff_t last; /* last file offset */
- int rval;
+ xfs_fileoff_t eof;
+ int error;
- if ((rval = xfs_bmap_last_offset(args->dp, &last, XFS_DATA_FORK)))
- return rval;
- *vp = last == args->geo->leafblk + args->geo->fsbcount;
+ error = xfs_bmap_last_offset(args->dp, &eof, XFS_DATA_FORK);
+ if (error)
+ return error;
+
+ *isleaf = false;
+ if (eof != args->geo->leafblk + args->geo->fsbcount)
+ return 0;
+
+ *isleaf = true;
return 0;
}
diff --git a/libxfs/xfs_dir2.h b/libxfs/xfs_dir2.h
index b6df3c34b2..dd39f17dd9 100644
--- a/libxfs/xfs_dir2.h
+++ b/libxfs/xfs_dir2.h
@@ -61,8 +61,8 @@ extern int xfs_dir2_sf_to_block(struct xfs_da_args *args);
/*
* Interface routines used by userspace utilities
*/
-extern int xfs_dir2_isblock(struct xfs_da_args *args, int *r);
-extern int xfs_dir2_isleaf(struct xfs_da_args *args, int *r);
+extern int xfs_dir2_isblock(struct xfs_da_args *args, bool *isblock);
+extern int xfs_dir2_isleaf(struct xfs_da_args *args, bool *isleaf);
extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
struct xfs_buf *bp);
diff --git a/repair/phase6.c b/repair/phase6.c
index fefb9755f5..81fccff9d4 100644
--- a/repair/phase6.c
+++ b/repair/phase6.c
@@ -2250,8 +2250,8 @@ longform_dir2_entry_check(
xfs_dablk_t da_bno;
freetab_t *freetab;
int i;
- int isblock;
- int isleaf;
+ bool isblock;
+ bool isleaf;
xfs_fileoff_t next_da_bno;
int seeval;
int fixit = 0;
next prev parent reply other threads:[~2022-11-09 2:06 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-09 2:05 [PATCHSET 00/24] xfsprogs: sync with 6.1 Darrick J. Wong
2022-11-09 2:05 ` [PATCH 01/24] xfs: clean up "%Ld/%Lu" which doesn't meet C standard Darrick J. Wong
2022-11-09 2:05 ` [PATCH 02/24] xfs: Remove the unneeded result variable Darrick J. Wong
2022-11-09 2:05 ` [PATCH 03/24] xfs: trim the mapp array accordingly in xfs_da_grow_inode_int Darrick J. Wong
2022-11-09 2:06 ` Darrick J. Wong [this message]
2022-11-09 2:06 ` [PATCH 05/24] treewide: use prandom_u32_max() when possible, part 1 Darrick J. Wong
2022-11-09 2:06 ` [PATCH 06/24] treewide: use get_random_u32() when possible Darrick J. Wong
2022-11-09 2:06 ` [PATCH 07/24] xfs: fix exception caused by unexpected illegal bestcount in leaf dir Darrick J. Wong
2022-11-09 2:06 ` [PATCH 08/24] xfs: increase rename inode reservation Darrick J. Wong
2022-11-09 2:06 ` [PATCH 09/24] xfs: fix memcpy fortify errors in EFI log format copying Darrick J. Wong
2022-11-09 2:06 ` [PATCH 10/24] xfs: refactor all the EFI/EFD log format sizeof logic Darrick J. Wong
2022-11-09 2:06 ` [PATCH 11/24] xfs: make sure aglen never goes negative in xfs_refcount_adjust_extents Darrick J. Wong
2022-11-09 2:06 ` [PATCH 12/24] xfs: create a predicate to verify per-AG extents Darrick J. Wong
2022-11-09 2:06 ` [PATCH 13/24] xfs: check deferred refcount op continuation parameters Darrick J. Wong
2022-11-09 2:07 ` [PATCH 14/24] xfs: move _irec structs to xfs_types.h Darrick J. Wong
2022-11-09 2:07 ` [PATCH 15/24] xfs: track cow/shared record domains explicitly in xfs_refcount_irec Darrick J. Wong
2022-11-18 10:17 ` Carlos Maiolino
2022-11-21 17:05 ` Darrick J. Wong
2022-11-22 9:55 ` Carlos Maiolino
2022-11-09 2:07 ` [PATCH 16/24] xfs: report refcount domain in tracepoints Darrick J. Wong
2022-11-09 2:07 ` [PATCH 17/24] xfs: refactor domain and refcount checking Darrick J. Wong
2022-11-09 2:07 ` [PATCH 18/24] xfs: remove XFS_FIND_RCEXT_SHARED and _COW Darrick J. Wong
2022-11-09 2:07 ` [PATCH 19/24] xfs: check record domain when accessing refcount records Darrick J. Wong
2022-11-09 2:07 ` [PATCH 20/24] xfs: fix agblocks check in the cow leftover recovery function Darrick J. Wong
2022-11-09 2:07 ` [PATCH 21/24] xfs: fix uninitialized list head in struct xfs_refcount_recovery Darrick J. Wong
2022-11-09 2:07 ` [PATCH 22/24] xfs: rename XFS_REFC_COW_START to _COWFLAG Darrick J. Wong
2022-11-09 2:07 ` [PATCH 23/24] xfs_{db,repair}: fix XFS_REFC_COW_START usage Darrick J. Wong
2022-11-09 2:07 ` [PATCH 24/24] mkfs.xfs: add mkfs config file for the 6.1 LTS kernel Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=166795956500.3761583.4853170066354811352.stgit@magnolia \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=david@fromorbit.com \
--cc=linux-xfs@vger.kernel.org \
--cc=zhangshida@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.