Ling, Xiaofeng
2004-Jul-06 21:54 UTC
[Ocfs2-devel] [PATCH] add notify trunctpage to close file
It is reasonable to notify other node when closing file. It is reasonable to notify other node when closing file. It ensures other node can get the newest data after the write finish, ------------------------------------------- Index: dlm.c ==================================================================--- dlm.c (revision 1242) +++ dlm.c (working copy) @@ -732,7 +732,7 @@ * ocfs_notify_truncate_on_wopen() * inode is definitely non NULL */ -int ocfs_notify_truncate_on_wopen (ocfs_super * osb, struct inode *inode) +int ocfs_notify_truncate_on_write (ocfs_super * osb, struct inode *inode) { int status = -EAGAIN; int disk_vote = 0; @@ -774,7 +774,7 @@ bail: LOG_EXIT_STATUS (status); return status; -} /* ocfs_notify_truncate_on_wopen */ +} /* ocfs_notify_truncate_on_write */ enum { invalid_path = 0, Index: file.c ==================================================================--- file.c (revision 1242) +++ file.c (working copy) @@ -341,6 +341,7 @@ struct dentry *dentry; int last_close = 0; int dec = 0; + int status; LOG_SET_CONTEXT(RELEASE); @@ -394,6 +395,13 @@ spin_unlock(&oin_num_ext_lock); up(&recovery_list_sem); } + if (file->f_flags & (O_WRONLY|O_RDWR) && !(file->f_flags & O_DIRECT)) { + status = ocfs_notify_truncate_on_write(osb, inode); + if (status < 0) { + LOG_ERROR_STATUS(status); + } + } + up (&(OCFS_I(inode)->ip_sem)); ocfs_sync_inode(inode);