xfs: random fixes and code cleanup
v3 cover xfs: random fixes and code cleanup
From: Kaixu Xia <[email protected]>
Hi all,
This patchset include random fixes and code cleanups, and there are no connections among these patches. In order to make it easier to track, I bundle them up and put all the scattered patches into a single patchset.
Changes for v3:
-move the log intent/intent-done items detection helpers
to xfs_trans.h.
-fix the overly long line.
Changes for v2:
-detect intent-done items by their item ops. -update the commit messages.
-code cleanup for xfs_attr_leaf_entsize_{remote,local}.
Kaixu Xia (7):
xfs: remove the unused SYNCHRONIZE macro
xfs: use the existing type definition for di_projid
xfs: remove the unnecessary xfs_dqid_t type cast
xfs: do the assert for all the log done items in xfs_trans_cancel
xfs: remove the redundant crc feature check in xfs_attr3_rmt_verify
xfs: code cleanup in xfs_attr_leaf_entsize_{remote,local}
xfs: fix some comments
fs/xfs/libxfs/xfs_attr_remote.c | 2 -- fs/xfs/libxfs/xfs_da_format.h | 12 ++++++------ fs/xfs/libxfs/xfs_inode_buf.h | 2 +- fs/xfs/xfs_dquot.c | 4 ++-- fs/xfs/xfs_linux.h | 1 - fs/xfs/xfs_log_recover.c | 7 ------- fs/xfs/xfs_qm.c | 2 +- fs/xfs/xfs_trans.c | 2 +- fs/xfs/xfs_trans.h | 16 ++++++++++++++++ 9 files changed, 27 insertions(+), 21 deletions(-)
Signature · 1 line
2.20.0
PATCH v3 1/7 xfs: remove the unused SYNCHRONIZE macro
From: Kaixu Xia <[email protected]>
There are no callers of the SYNCHRONIZE() macro, so remove it.
--- fs/xfs/xfs_linux.h | 1 - 1 file changed, 1 deletion(-)
fs/xfs/xfs_linux.h +0 -1
@@ -123,7 +123,6 @@ typedef __u32 xfs_nlink_t;#define EFSCORRUPTED EUCLEAN/* Filesystem is corrupted */ #define EFSBADCRC EBADMSG/* Bad CRC detected */ -#define SYNCHRONIZE () barrier()#define __return_address __builtin_return_address(0)/*
Signature · 1 line
2.20.0
PATCH v3 2/7 xfs: use the existing type definition for di_projid
In reply to [email protected]From: Kaixu Xia <[email protected]>
We have already defined the project ID type prid_t, so maybe should use it here.
--- fs/xfs/libxfs/xfs_inode_buf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_inode_buf.h +1 -1
@@ -17,7 +17,7 @@ struct xfs_dinode;*/ struct xfs_icdinode {uint16_t di_flushiter;/* incremented on flush */ -uint32_t di_projid;/* owner's project id */ +prid_t di_projid;/* owner's project id */ xfs_fsize_t di_size;/* number of bytes in file */ xfs_rfsblock_t di_nblocks;/* # of direct & btree blocks used */ xfs_extlen_t di_extsize;/* basic/minimum extent size for file */
Signature · 1 line
2.20.0
PATCH v3 3/7 xfs: remove the unnecessary xfs_dqid_t type cast
In reply to [email protected]From: Kaixu Xia <[email protected]>
Since the type prid_t and xfs_dqid_t both are uint32_t, seems the type cast is unnecessary, so remove it.
--- fs/xfs/xfs_qm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_qm.c +1 -1
@@ -1715,7 +1715,7 @@ xfs_qm_vop_dqalloc(if ((flags &XFS_QMOPT_PQUOTA ) &&XFS_IS_PQUOTA_ON (mp)) {if (ip->i_d.di_projid != prid) {xfs_iunlock (ip, lockflags); - error =xfs_qm_dqget (mp, (xfs_dqid_t )prid, + error =xfs_qm_dqget (mp, prid,XFS_DQTYPE_PROJ , true, &pq);if (error) {ASSERT (error != -ENOENT );
Signature · 1 line
2.20.0
PATCH v3 4/7 xfs: do the assert for all the log done items in xfs_trans_cancel
In reply to [email protected]From: Kaixu Xia <[email protected]>
We should do the assert for all the log intent-done items if they appear here. This patch detect intent-done items by the fact that their item ops don't have iop_unpin and iop_push methods and also move the helper xlog_item_is_intent to xfs_trans.h.
--- fs/xfs/xfs_log_recover.c | 7 ------- fs/xfs/xfs_trans.c | 2 +- fs/xfs/xfs_trans.h | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 8 deletions(-)
fs/xfs/xfs_log_recover.c +0 -7
@@ -2475,13 +2475,6 @@ xlog_finish_defer_ops(return xfs_trans_commit (tp); } -/* Is this log item a deferred action intent? */ -static inline bool xlog_item_is_intent (struct xfs_log_item *lip) -{ -return lip->li_ops->iop_recover !=NULL && - lip->li_ops->iop_match !=NULL ; -} -/* * When this is called, all of the log intent items which did not have * corresponding log done items should be in the AIL. What we do now
fs/xfs/xfs_trans.c +1 -1
@@ -959,7 +959,7 @@ xfs_trans_cancel(struct xfs_log_item *lip;list_for_each_entry (lip, &tp->t_items, li_trans) - ASSERT(!(lip->li_type == XFS_LI_EFD)); + ASSERT(!xlog_item_is_intent_done(lip)); }#endif xfs_trans_unreserve_and_mod_sb (tp);
fs/xfs/xfs_trans.h +16 -0
@@ -78,6 +78,22 @@ struct xfs_item_ops {bool (*iop_match)(struct xfs_log_item *item,uint64_t id); }; +/* Is this log item a deferred action intent? */ +static inline bool +xlog_item_is_intent (struct xfs_log_item *lip) +{ +return lip->li_ops->iop_recover !=NULL && + lip->li_ops->iop_match !=NULL ; +} + +/* Is this a log intent-done item? */ +static inline bool +xlog_item_is_intent_done (struct xfs_log_item *lip) +{ +return lip->li_ops->iop_unpin ==NULL && + lip->li_ops->iop_push ==NULL ; +} +/* * Release the log item as soon as committed. This is for items just logging * intents that never need to be written back in place.
Signature · 1 line
2.20.0
PATCH v3 5/7 xfs: remove the redundant crc feature check in xfs_attr3_rmt_verify
In reply to [email protected]From: Kaixu Xia <[email protected]>
We already check whether the crc feature is enabled before calling xfs_attr3_rmt_verify(), so remove the redundant feature check in that function.
--- fs/xfs/libxfs/xfs_attr_remote.c | 2 -- 1 file changed, 2 deletions(-)
fs/xfs/libxfs/xfs_attr_remote.c +0 -2
@@ -96,8 +96,6 @@ xfs_attr3_rmt_verify( {struct xfs_attr3_rmt_hdr *rmt = ptr; -if (!xfs_sb_version_hascrc (&mp->m_sb)) -return __this_address;if (!xfs_verify_magic (bp, rmt->rm_magic))return __this_address;if (!uuid_equal (&rmt->rm_uuid, &mp->m_sb.sb_meta_uuid))
Signature · 1 line
2.20.0
PATCH v3 6/7 xfs: code cleanup in xfs_attr_leaf_entsize_{remote,local}
In reply to [email protected]From: Kaixu Xia <[email protected]>
Cleanup the typedef usage, the unnecessary parentheses, the unnecessary backslash and use the open-coded round_up call in xfs_attr_leaf_entsize_{remote,local}.
--- fs/xfs/libxfs/xfs_da_format.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/xfs/libxfs/xfs_da_format.h +4 -4
@@ -746,14 +746,14 @@ xfs_attr3_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)*/ static inline int xfs_attr_leaf_entsize_remote (int nlen) { -return ((uint )sizeof (xfs_attr_leaf_name_remote_t) -1 + (nlen) + \ -XFS_ATTR_LEAF_NAME_ALIGN -1 ) & ~(XFS_ATTR_LEAF_NAME_ALIGN -1 ); +return round_up (sizeof (struct xfs_attr_leaf_name_remote ) -1 + + nlen,XFS_ATTR_LEAF_NAME_ALIGN ); }static inline int xfs_attr_leaf_entsize_local (int nlen,int vlen) { -return ((uint )sizeof (xfs_attr_leaf_name_local_t) -1 + (nlen) + (vlen) + -XFS_ATTR_LEAF_NAME_ALIGN -1 ) & ~(XFS_ATTR_LEAF_NAME_ALIGN -1 ); +return round_up (sizeof (struct xfs_attr_leaf_name_local ) -1 + + nlen + vlen,XFS_ATTR_LEAF_NAME_ALIGN ); }static inline int xfs_attr_leaf_entsize_local_max (int bsize)
Signature · 1 line
2.20.0
Re: [PATCH v3 6/7] xfs: code cleanup in xfs_attr_leaf_entsize_{remote,local}
Quoted 8 lines · On Wed, Sep 23, 2020 at 02:59:17PM +0800, [email protected] wrote:
From: Kaixu Xia <[email protected]>
Cleanup the typedef usage, the unnecessary parentheses, the unnecessary backslash and use the open-coded
round_upcall in xfs_attr_leaf_entsize_{remote,local}.Signed-off-by Kaixu Xia <[email protected]>Reviewed-by Darrick J. Wong <[email protected]>
Looks good,
PATCH v3 7/7 xfs: fix some comments
In reply to [email protected]From: Kaixu Xia <[email protected]>
Fix the comments to help people understand the code.
--- fs/xfs/libxfs/xfs_da_format.h | 4 ++-- fs/xfs/xfs_dquot.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
fs/xfs/libxfs/xfs_da_format.h +2 -2
@@ -35,8 +35,8 @@ typedef struct xfs_da_blkinfo {*/ #define XFS_DA3_NODE_MAGIC 0x3ebe/* magic number: non-leaf blocks */ #define XFS_ATTR3_LEAF_MAGIC 0x3bee/* magic number: attribute leaf blks */ -#define XFS_DIR3_LEAF1_MAGIC 0x3df1/* magic number: v2 dirlf single blks */ -#define XFS_DIR3_LEAFN_MAGIC 0x3dff/* magic number: v2 dirlf multi blks */ +#define XFS_DIR3_LEAF1_MAGIC 0x3df1/* magic number: v3 dirlf single blks */ +#define XFS_DIR3_LEAFN_MAGIC 0x3dff/* magic number: v3 dirlf multi blks */ struct xfs_da3_blkinfo {/*
fs/xfs/xfs_dquot.c +2 -2
@@ -831,8 +831,8 @@ xfs_qm_dqget_checks( }/* -* Given the file system, id, and type (UDQUOT/GDQUOT), return a locked -* dquot, doing an allocation (if requested) as needed. +* Given the file system, id, and type (UDQUOT/GDQUOT/PDQUOT), return a +* locked dquot, doing an allocation (if requested) as needed. */ int xfs_qm_dqget(
Signature · 1 line
2.20.0
Darrick J. Wong
AppliedQuoted 4 lines · On Wed, Sep 23, 2020 at 02:59:11PM +0800, [email protected] wrote:
From: Kaixu Xia <[email protected]>
Hi all,
Quoted 9 lines
This patchset include random fixes and code cleanups, and there are no connections among these patches. In order to make it easier to track, I bundle them up and put all the scattered patches into a single patchset.
Changes for v3:
-move the log intent/intent-done items detection helpers
toxfs_trans.h.
-fix the overly long line.
Applied, thanks.
--D
Quoted 28 lines
Changes for v2:
-detect intent-done items by their item ops. -update the commit messages.
-code cleanup for xfs_attr_leaf_entsize_{remote,local}.Kaixu Xia (7):
xfs: remove the unused SYNCHRONIZE macro
xfs: use the existing type definition fordi_projid
xfs: remove the unnecessaryxfs_dqid_ttype cast
xfs: do the assert for all the log done items inxfs_trans_cancel
xfs: remove the redundant crc feature check inxfs_attr3_rmt_verify
xfs: code cleanup in xfs_attr_leaf_entsize_{remote,local}
xfs: fix some commentsfs/xfs/libxfs/xfs_attr_remote.c | 2 -- fs/xfs/libxfs/xfs_da_format.h | 12 ++++++------ fs/xfs/libxfs/xfs_inode_buf.h | 2 +- fs/xfs/xfs_dquot.c | 4 ++-- fs/xfs/xfs_linux.h | 1 - fs/xfs/xfs_log_recover.c | 7 ------- fs/xfs/xfs_qm.c | 2 +- fs/xfs/xfs_trans.c | 2 +- fs/xfs/xfs_trans.h | 16 ++++++++++++++++ 9 files changed, 27 insertions(+), 21 deletions(-)Signature · 1 line
2.20.0