Skip to content

Commit 82e938b

Browse files
committed
gfs2: Upgrade shared glocks for atime updates
Commit 20f8299 ("gfs2: Rework read and page fault locking") lifted the glock lock taking from the low-level ->readpage and ->readahead address space operations to the higher-level ->read_iter file and ->fault vm operations. The glocks are still taken in LM_ST_SHARED mode only. On filesystems mounted without the noatime option, ->read_iter sometimes needs to update the atime as well, though. Right now, this leads to a failed locking mode assertion in gfs2_dirty_inode. Fix that by introducing a new update_time inode operation. There, if the glock is held non-exclusively, upgrade it to an exclusive lock. Reported-by: Alexander Aring <aahringo@redhat.com> Fixes: 20f8299 ("gfs2: Rework read and page fault locking") Cc: stable@vger.kernel.org # v5.8+ Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent f39e7d3 commit 82e938b

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

‎fs/gfs2/inode.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,6 +2116,25 @@ loff_t gfs2_seek_hole(struct file *file, loff_t offset)
21162116
return vfs_setpos(file, ret, inode->i_sb->s_maxbytes);
21172117
}
21182118

2119+
static int gfs2_update_time(struct inode *inode, struct timespec64 *time,
2120+
int flags)
2121+
{
2122+
struct gfs2_inode *ip = GFS2_I(inode);
2123+
struct gfs2_glock *gl = ip->i_gl;
2124+
struct gfs2_holder *gh;
2125+
int error;
2126+
2127+
gh = gfs2_glock_is_locked_by_me(gl);
2128+
if (gh && !gfs2_glock_is_held_excl(gl)) {
2129+
gfs2_glock_dq(gh);
2130+
gfs2_holder_reinit(LM_ST_EXCLUSIVE, 0, gh);
2131+
error = gfs2_glock_nq(gh);
2132+
if (error)
2133+
return error;
2134+
}
2135+
return generic_update_time(inode, time, flags);
2136+
}
2137+
21192138
const struct inode_operations gfs2_file_iops = {
21202139
.permission = gfs2_permission,
21212140
.setattr = gfs2_setattr,
@@ -2124,6 +2143,7 @@ const struct inode_operations gfs2_file_iops = {
21242143
.fiemap = gfs2_fiemap,
21252144
.get_acl = gfs2_get_acl,
21262145
.set_acl = gfs2_set_acl,
2146+
.update_time = gfs2_update_time,
21272147
};
21282148

21292149
const struct inode_operations gfs2_dir_iops = {
@@ -2143,6 +2163,7 @@ const struct inode_operations gfs2_dir_iops = {
21432163
.fiemap = gfs2_fiemap,
21442164
.get_acl = gfs2_get_acl,
21452165
.set_acl = gfs2_set_acl,
2166+
.update_time = gfs2_update_time,
21462167
.atomic_open = gfs2_atomic_open,
21472168
};
21482169

0 commit comments

Comments
 (0)