Skip to content

Commit 2b0fb35

Browse files
author
Andreas Gruenbacher
committed
gfs2: Avoid access time thrashing in gfs2_inode_lookup
In gfs2_inode_lookup, we initialize inode->i_atime to the lowest possibly value after gfs2_inode_refresh may already have been called. This should be the other way around, but we didn't notice because usually the inode type is known from the directory entry and so gfs2_inode_lookup won't call gfs2_inode_refresh. In addition, only initialize ip->i_no_formal_ino from no_formal_ino when actually needed. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent e556280 commit 2b0fb35

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/gfs2/inode.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
136136

137137
if (inode->i_state & I_NEW) {
138138
struct gfs2_sbd *sdp = GFS2_SB(inode);
139-
ip->i_no_formal_ino = no_formal_ino;
140139

141140
error = gfs2_glock_get(sdp, no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl);
142141
if (unlikely(error))
@@ -175,21 +174,22 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
175174
gfs2_glock_put(io_gl);
176175
io_gl = NULL;
177176

177+
/* Lowest possible timestamp; will be overwritten in gfs2_dinode_in. */
178+
inode->i_atime.tv_sec = 1LL << (8 * sizeof(inode->i_atime.tv_sec) - 1);
179+
inode->i_atime.tv_nsec = 0;
180+
178181
if (type == DT_UNKNOWN) {
179182
/* Inode glock must be locked already */
180183
error = gfs2_inode_refresh(GFS2_I(inode));
181184
if (error)
182185
goto fail_refresh;
183186
} else {
187+
ip->i_no_formal_ino = no_formal_ino;
184188
inode->i_mode = DT2IF(type);
185189
}
186190

187191
gfs2_set_iop(inode);
188192

189-
/* Lowest possible timestamp; will be overwritten in gfs2_dinode_in. */
190-
inode->i_atime.tv_sec = 1LL << (8 * sizeof(inode->i_atime.tv_sec) - 1);
191-
inode->i_atime.tv_nsec = 0;
192-
193193
unlock_new_inode(inode);
194194
}
195195

0 commit comments

Comments
 (0)