On write code paths, the VFS usually takes care of updating the mtime and ctime
of the inode.  We need to grab the inode's glock in EX mode before the write
can happen.  When acquiring the glock in EX mode, the DLM may decide that the
lock needs to be unlocked before being re-acquired in EX mode, which will cause
the on-disk inode to be reread from disk.  When that happens, the VFS's mtime
and ctime update are lost.  To fix that, make sure to update the mtime and
ctime again once we hold the glock in EX mode.

Signed-off-by: Andreas Gruenbacher <agrue...@redhat.com>
 fs/gfs2/ops_address.c | 3 +++
 fs/gfs2/ops_file.c    | 1 +
 2 files changed, 4 insertions(+)

diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index f22ee46..7bb54ff 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -700,6 +700,8 @@ int gfs2_write_begin(struct file *file, struct 
address_space *mapping,
        error = gfs2_glock_nq(&ip->i_gh);
        if (unlikely(error))
                goto out_uninit;
+       file_update_time(file);
        if (&ip->i_inode == sdp->sd_rindex) {
                error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE,
                                           GL_NOCACHE, &m_ip->i_gh);
@@ -1005,6 +1007,7 @@ static int gfs2_prepare_write(struct file *file, struct 
page *page,
        error = gfs2_write_lock_start(ip, page, pos, write_len, 
        if (error)
                return error;
+       file_update_time(file);
        if (gfs2_is_stuffed(ip)) {
                if (end > sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)) {
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c
index 3994484..2adefe6 100644
--- a/fs/gfs2/ops_file.c
+++ b/fs/gfs2/ops_file.c
@@ -413,6 +413,7 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, 
struct page *page)
        ret = gfs2_glock_nq(&gh);
        if (ret)
                goto out;
+       file_update_time(vma->vm_file);
        set_bit(GIF_SW_PAGED, &ip->i_flags);
        ret = gfs2_write_alloc_required(ip, pos, PAGE_CACHE_SIZE, 

Reply via email to