Skip to content

Commit c098576

Browse files
Shida Zhangdchinner
authored andcommitted
xfs: rearrange the logic and remove the broken comment for xfs_dir2_isxx
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>
1 parent 4415965 commit c098576

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed

fs/xfs/libxfs/xfs_dir2.c

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ xfs_dir_createname(
261261
{
262262
struct xfs_da_args *args;
263263
int rval;
264-
int v; /* type-checking value */
264+
bool v;
265265

266266
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
267267

@@ -357,7 +357,7 @@ xfs_dir_lookup(
357357
{
358358
struct xfs_da_args *args;
359359
int rval;
360-
int v; /* type-checking value */
360+
bool v;
361361
int lock_mode;
362362

363363
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
@@ -435,7 +435,7 @@ xfs_dir_removename(
435435
{
436436
struct xfs_da_args *args;
437437
int rval;
438-
int v; /* type-checking value */
438+
bool v;
439439

440440
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
441441
XFS_STATS_INC(dp->i_mount, xs_dir_remove);
@@ -493,7 +493,7 @@ xfs_dir_replace(
493493
{
494494
struct xfs_da_args *args;
495495
int rval;
496-
int v; /* type-checking value */
496+
bool v;
497497

498498
ASSERT(S_ISDIR(VFS_I(dp)->i_mode));
499499

@@ -610,19 +610,23 @@ xfs_dir2_grow_inode(
610610
int
611611
xfs_dir2_isblock(
612612
struct xfs_da_args *args,
613-
int *vp) /* out: 1 is block, 0 is not block */
613+
bool *isblock)
614614
{
615-
xfs_fileoff_t last; /* last file offset */
616-
int rval;
615+
struct xfs_mount *mp = args->dp->i_mount;
616+
xfs_fileoff_t eof;
617+
int error;
617618

618-
if ((rval = xfs_bmap_last_offset(args->dp, &last, XFS_DATA_FORK)))
619-
return rval;
620-
rval = XFS_FSB_TO_B(args->dp->i_mount, last) == args->geo->blksize;
621-
if (XFS_IS_CORRUPT(args->dp->i_mount,
622-
rval != 0 &&
623-
args->dp->i_disk_size != args->geo->blksize))
619+
error = xfs_bmap_last_offset(args->dp, &eof, XFS_DATA_FORK);
620+
if (error)
621+
return error;
622+
623+
*isblock = false;
624+
if (XFS_FSB_TO_B(mp, eof) != args->geo->blksize)
625+
return 0;
626+
627+
*isblock = true;
628+
if (XFS_IS_CORRUPT(mp, args->dp->i_disk_size != args->geo->blksize))
624629
return -EFSCORRUPTED;
625-
*vp = rval;
626630
return 0;
627631
}
628632

@@ -632,14 +636,20 @@ xfs_dir2_isblock(
632636
int
633637
xfs_dir2_isleaf(
634638
struct xfs_da_args *args,
635-
int *vp) /* out: 1 is block, 0 is not block */
639+
bool *isleaf)
636640
{
637-
xfs_fileoff_t last; /* last file offset */
638-
int rval;
641+
xfs_fileoff_t eof;
642+
int error;
639643

640-
if ((rval = xfs_bmap_last_offset(args->dp, &last, XFS_DATA_FORK)))
641-
return rval;
642-
*vp = last == args->geo->leafblk + args->geo->fsbcount;
644+
error = xfs_bmap_last_offset(args->dp, &eof, XFS_DATA_FORK);
645+
if (error)
646+
return error;
647+
648+
*isleaf = false;
649+
if (eof != args->geo->leafblk + args->geo->fsbcount)
650+
return 0;
651+
652+
*isleaf = true;
643653
return 0;
644654
}
645655

fs/xfs/libxfs/xfs_dir2.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ extern int xfs_dir2_sf_to_block(struct xfs_da_args *args);
6161
/*
6262
* Interface routines used by userspace utilities
6363
*/
64-
extern int xfs_dir2_isblock(struct xfs_da_args *args, int *r);
65-
extern int xfs_dir2_isleaf(struct xfs_da_args *args, int *r);
64+
extern int xfs_dir2_isblock(struct xfs_da_args *args, bool *isblock);
65+
extern int xfs_dir2_isleaf(struct xfs_da_args *args, bool *isleaf);
6666
extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
6767
struct xfs_buf *bp);
6868

fs/xfs/scrub/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ xchk_directory_blocks(
676676
xfs_dablk_t dabno;
677677
xfs_dir2_db_t last_data_db = 0;
678678
bool found;
679-
int is_block = 0;
679+
bool is_block = false;
680680
int error;
681681

682682
/* Ignore local format directories. */

fs/xfs/xfs_dir2_readdir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ xfs_readdir(
512512
{
513513
struct xfs_da_args args = { NULL };
514514
unsigned int lock_mode;
515-
int isblock;
515+
bool isblock;
516516
int error;
517517

518518
trace_xfs_readdir(dp);

0 commit comments

Comments
 (0)