* [Cluster-devel] [PATCH 0/3] gfs2_(un)link cleanups
@ 2023-03-14 13:18 Andrew Price
2023-03-14 13:18 ` [Cluster-devel] [PATCH 1/3] gfs2: Remove duplicate i_nlink check from gfs2_link() Andrew Price
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Andrew Price @ 2023-03-14 13:18 UTC (permalink / raw)
To: cluster-devel.redhat.com
Some trivial cleanups from my O_TMPFILE branch. That work isn't ready
yet but there was no reason not to send these patches.
Andy
Andrew Price (3):
gfs2: Remove duplicate i_nlink check from gfs2_link()
gfs2: Remove ghs[] from gfs2_link
gfs2: Remove ghs[] from gfs2_unlink
fs/gfs2/inode.c | 47 ++++++++++++++++++++++-------------------------
1 file changed, 22 insertions(+), 25 deletions(-)
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Cluster-devel] [PATCH 1/3] gfs2: Remove duplicate i_nlink check from gfs2_link()
2023-03-14 13:18 [Cluster-devel] [PATCH 0/3] gfs2_(un)link cleanups Andrew Price
@ 2023-03-14 13:18 ` Andrew Price
2023-03-14 13:18 ` [Cluster-devel] [PATCH 2/3] gfs2: Remove ghs[] from gfs2_link Andrew Price
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andrew Price @ 2023-03-14 13:18 UTC (permalink / raw)
To: cluster-devel.redhat.com
The duplication is:
struct gfs2_inode *ip = GFS2_I(inode);
[...]
error = -ENOENT;
if (inode->i_nlink == 0)
goto out_gunlock;
[...]
error = -EINVAL;
if (!ip->i_inode.i_nlink)
goto out_gunlock;
The second check is removed. ENOENT is the correct error code for
attempts to link a deleted inode (ref: link(2)).
If we support O_TMPFILE in future the check will need to be updated with
an exception for inodes flagged I_LINKABLE so sorting out this
duplication now will make it a slightly cleaner change.
Signed-off-by: Andrew Price <anprice@redhat.com>
---
fs/gfs2/inode.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 1291b5ee3584..79eef9a0ebfc 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -992,9 +992,6 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
error = -EPERM;
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
goto out_gunlock;
- error = -EINVAL;
- if (!ip->i_inode.i_nlink)
- goto out_gunlock;
error = -EMLINK;
if (ip->i_inode.i_nlink == (u32)-1)
goto out_gunlock;
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Cluster-devel] [PATCH 2/3] gfs2: Remove ghs[] from gfs2_link
2023-03-14 13:18 [Cluster-devel] [PATCH 0/3] gfs2_(un)link cleanups Andrew Price
2023-03-14 13:18 ` [Cluster-devel] [PATCH 1/3] gfs2: Remove duplicate i_nlink check from gfs2_link() Andrew Price
@ 2023-03-14 13:18 ` Andrew Price
2023-03-14 13:18 ` [Cluster-devel] [PATCH 3/3] gfs2: Remove ghs[] from gfs2_unlink Andrew Price
2023-03-27 12:43 ` [Cluster-devel] [PATCH 0/3] gfs2_(un)link cleanups Andreas Gruenbacher
3 siblings, 0 replies; 5+ messages in thread
From: Andrew Price @ 2023-03-14 13:18 UTC (permalink / raw)
To: cluster-devel.redhat.com
Replace the 2-item array with two variables for readability.
Signed-off-by: Andrew Price <anprice@redhat.com>
---
fs/gfs2/inode.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 79eef9a0ebfc..9850267b9951 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -941,7 +941,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
struct gfs2_sbd *sdp = GFS2_SB(dir);
struct inode *inode = d_inode(old_dentry);
struct gfs2_inode *ip = GFS2_I(inode);
- struct gfs2_holder ghs[2];
+ struct gfs2_holder d_gh, gh;
struct buffer_head *dibh;
struct gfs2_diradd da = { .bh = NULL, .save_loc = 1, };
int error;
@@ -953,14 +953,14 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
if (error)
return error;
- gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
- gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
+ gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, &d_gh);
+ gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
- error = gfs2_glock_nq(ghs); /* parent */
+ error = gfs2_glock_nq(&d_gh);
if (error)
goto out_parent;
- error = gfs2_glock_nq(ghs + 1); /* child */
+ error = gfs2_glock_nq(&gh);
if (error)
goto out_child;
@@ -1046,13 +1046,13 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
gfs2_quota_unlock(dip);
out_gunlock:
gfs2_dir_no_add(&da);
- gfs2_glock_dq(ghs + 1);
+ gfs2_glock_dq(&gh);
out_child:
- gfs2_glock_dq(ghs);
+ gfs2_glock_dq(&d_gh);
out_parent:
gfs2_qa_put(dip);
- gfs2_holder_uninit(ghs);
- gfs2_holder_uninit(ghs + 1);
+ gfs2_holder_uninit(&d_gh);
+ gfs2_holder_uninit(&gh);
return error;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Cluster-devel] [PATCH 3/3] gfs2: Remove ghs[] from gfs2_unlink
2023-03-14 13:18 [Cluster-devel] [PATCH 0/3] gfs2_(un)link cleanups Andrew Price
2023-03-14 13:18 ` [Cluster-devel] [PATCH 1/3] gfs2: Remove duplicate i_nlink check from gfs2_link() Andrew Price
2023-03-14 13:18 ` [Cluster-devel] [PATCH 2/3] gfs2: Remove ghs[] from gfs2_link Andrew Price
@ 2023-03-14 13:18 ` Andrew Price
2023-03-27 12:43 ` [Cluster-devel] [PATCH 0/3] gfs2_(un)link cleanups Andreas Gruenbacher
3 siblings, 0 replies; 5+ messages in thread
From: Andrew Price @ 2023-03-14 13:18 UTC (permalink / raw)
To: cluster-devel.redhat.com
Replace the 3-item array with three variables for readability.
Signed-off-by: Andrew Price <anprice@redhat.com>
---
fs/gfs2/inode.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 9850267b9951..17c994a0c0d0 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1143,7 +1143,7 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
struct gfs2_sbd *sdp = GFS2_SB(dir);
struct inode *inode = d_inode(dentry);
struct gfs2_inode *ip = GFS2_I(inode);
- struct gfs2_holder ghs[3];
+ struct gfs2_holder d_gh, r_gh, gh;
struct gfs2_rgrpd *rgd;
int error;
@@ -1153,21 +1153,21 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
error = -EROFS;
- gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
- gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
+ gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, &d_gh);
+ gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1);
if (!rgd)
goto out_inodes;
- gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, LM_FLAG_NODE_SCOPE, ghs + 2);
+ gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, LM_FLAG_NODE_SCOPE, &r_gh);
- error = gfs2_glock_nq(ghs); /* parent */
+ error = gfs2_glock_nq(&d_gh);
if (error)
goto out_parent;
- error = gfs2_glock_nq(ghs + 1); /* child */
+ error = gfs2_glock_nq(&gh);
if (error)
goto out_child;
@@ -1181,7 +1181,7 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
goto out_rgrp;
}
- error = gfs2_glock_nq(ghs + 2); /* rgrp */
+ error = gfs2_glock_nq(&r_gh); /* rgrp */
if (error)
goto out_rgrp;
@@ -1197,16 +1197,16 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
gfs2_trans_end(sdp);
out_gunlock:
- gfs2_glock_dq(ghs + 2);
+ gfs2_glock_dq(&r_gh);
out_rgrp:
- gfs2_glock_dq(ghs + 1);
+ gfs2_glock_dq(&gh);
out_child:
- gfs2_glock_dq(ghs);
+ gfs2_glock_dq(&d_gh);
out_parent:
- gfs2_holder_uninit(ghs + 2);
+ gfs2_holder_uninit(&r_gh);
out_inodes:
- gfs2_holder_uninit(ghs + 1);
- gfs2_holder_uninit(ghs);
+ gfs2_holder_uninit(&gh);
+ gfs2_holder_uninit(&d_gh);
return error;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Cluster-devel] [PATCH 0/3] gfs2_(un)link cleanups
2023-03-14 13:18 [Cluster-devel] [PATCH 0/3] gfs2_(un)link cleanups Andrew Price
` (2 preceding siblings ...)
2023-03-14 13:18 ` [Cluster-devel] [PATCH 3/3] gfs2: Remove ghs[] from gfs2_unlink Andrew Price
@ 2023-03-27 12:43 ` Andreas Gruenbacher
3 siblings, 0 replies; 5+ messages in thread
From: Andreas Gruenbacher @ 2023-03-27 12:43 UTC (permalink / raw)
To: cluster-devel.redhat.com
On Tue, Mar 14, 2023 at 2:18?PM Andrew Price <anprice@redhat.com> wrote:
> Some trivial cleanups from my O_TMPFILE branch. That work isn't ready
> yet but there was no reason not to send these patches.
Applied, thanks.
Andreas
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-27 12:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-14 13:18 [Cluster-devel] [PATCH 0/3] gfs2_(un)link cleanups Andrew Price
2023-03-14 13:18 ` [Cluster-devel] [PATCH 1/3] gfs2: Remove duplicate i_nlink check from gfs2_link() Andrew Price
2023-03-14 13:18 ` [Cluster-devel] [PATCH 2/3] gfs2: Remove ghs[] from gfs2_link Andrew Price
2023-03-14 13:18 ` [Cluster-devel] [PATCH 3/3] gfs2: Remove ghs[] from gfs2_unlink Andrew Price
2023-03-27 12:43 ` [Cluster-devel] [PATCH 0/3] gfs2_(un)link cleanups Andreas Gruenbacher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).