Skip to content

Commit 089f4eb

Browse files
author
Andreas Gruenbacher
committed
gfs2: Don't update inode timestamps for direct writes
During direct reads and writes, the caller is holding the inode glock in deferred mode, which doesn't allow metadata updates. However, a previous change caused callers to update the inode modification time before carrying out direct writes, which caused the inode glock to be converted to exclusive mode for the timestamp update, only to be immediately converted back to deferred mode for the direct write. This locks out other direct readers and writers and wreaks havoc on performance. Fix that by reverting to not updating the inode modification time for direct writes. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 21d9067 commit 089f4eb

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

fs/gfs2/file.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,14 +1120,16 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
11201120
if (ret)
11211121
goto out_unlock;
11221122

1123-
ret = file_update_time(file);
1124-
if (ret)
1125-
goto out_unlock;
1126-
11271123
if (iocb->ki_flags & IOCB_DIRECT) {
11281124
struct address_space *mapping = file->f_mapping;
11291125
ssize_t buffered, ret2;
11301126

1127+
/*
1128+
* Note that under direct I/O, we don't allow and inode
1129+
* timestamp updates, so we're not calling file_update_time()
1130+
* here.
1131+
*/
1132+
11311133
ret = gfs2_file_direct_write(iocb, from, &gh);
11321134
if (ret < 0 || !iov_iter_count(from))
11331135
goto out_unlock;
@@ -1154,6 +1156,10 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
11541156
if (!ret || ret2 > 0)
11551157
ret += ret2;
11561158
} else {
1159+
ret = file_update_time(file);
1160+
if (ret)
1161+
goto out_unlock;
1162+
11571163
ret = gfs2_file_buffered_write(iocb, from, &gh);
11581164
if (likely(ret > 0))
11591165
ret = generic_write_sync(iocb, ret);

0 commit comments

Comments
 (0)