Skip to content

Commit 6bdcade

Browse files
committed
gfs2: Minor gfs2_lookup_by_inum cleanup
Use a zero no_formal_ino instead of a NULL pointer to indicate that any inode generation number will qualify: a valid inode never has a zero no_formal_ino. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 9e73330 commit 6bdcade

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎fs/gfs2/export.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ static struct dentry *gfs2_get_dentry(struct super_block *sb,
134134
struct gfs2_sbd *sdp = sb->s_fs_info;
135135
struct inode *inode;
136136

137-
inode = gfs2_lookup_by_inum(sdp, inum->no_addr, &inum->no_formal_ino,
137+
if (!inum->no_formal_ino)
138+
return ERR_PTR(-ESTALE);
139+
inode = gfs2_lookup_by_inum(sdp, inum->no_addr, inum->no_formal_ino,
138140
GFS2_BLKST_DINODE);
139141
if (IS_ERR(inode))
140142
return ERR_CAST(inode);

‎fs/gfs2/glock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ static void delete_work_func(struct work_struct *work)
843843
}
844844
}
845845

846-
inode = gfs2_lookup_by_inum(sdp, no_addr, NULL, GFS2_BLKST_UNLINKED);
846+
inode = gfs2_lookup_by_inum(sdp, no_addr, 0, GFS2_BLKST_UNLINKED);
847847
if (!IS_ERR_OR_NULL(inode)) {
848848
d_prune_aliases(inode);
849849
iput(inode);

‎fs/gfs2/inode.c‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,15 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
207207
return ERR_PTR(error);
208208
}
209209

210+
/**
211+
* gfs2_lookup_by_inum - look up an inode by inode number
212+
* @sdp: The super block
213+
* @no_addr: The inode number
214+
* @no_formal_ino: The inode generation number (0 for any)
215+
* @blktype: Requested block type (see gfs2_inode_lookup)
216+
*/
210217
struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr,
211-
u64 *no_formal_ino, unsigned int blktype)
218+
u64 no_formal_ino, unsigned int blktype)
212219
{
213220
struct super_block *sb = sdp->sd_vfs;
214221
struct inode *inode;
@@ -221,7 +228,7 @@ struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr,
221228
/* Two extra checks for NFS only */
222229
if (no_formal_ino) {
223230
error = -ESTALE;
224-
if (GFS2_I(inode)->i_no_formal_ino != *no_formal_ino)
231+
if (GFS2_I(inode)->i_no_formal_ino != no_formal_ino)
225232
goto fail_iput;
226233

227234
error = -EIO;

‎fs/gfs2/inode.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ extern struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned type,
9292
u64 no_addr, u64 no_formal_ino,
9393
unsigned int blktype);
9494
extern struct inode *gfs2_lookup_by_inum(struct gfs2_sbd *sdp, u64 no_addr,
95-
u64 *no_formal_ino,
95+
u64 no_formal_ino,
9696
unsigned int blktype);
9797

9898
extern int gfs2_inode_refresh(struct gfs2_inode *ip);

0 commit comments

Comments
 (0)