summaryrefslogtreecommitdiffstats
path: root/fs/ceph/file.c
diff options
context:
space:
mode:
authorYan, Zheng <zheng.z.yan@intel.com>2013-08-12 21:42:15 -0700
committerSage Weil <sage@inktank.com>2013-08-15 11:12:06 -0700
commitb0d7c2231015b331b942746610a05b6ea72977ab (patch)
treea13e3f015fc3144371550b4f5c25363bd66bdf1f /fs/ceph/file.c
parentb150f5c1c759d551da9146435d3dc9df5f7e15ef (diff)
downloadop-kernel-dev-b0d7c2231015b331b942746610a05b6ea72977ab.zip
op-kernel-dev-b0d7c2231015b331b942746610a05b6ea72977ab.tar.gz
ceph: introduce i_truncate_mutex
I encountered below deadlock when running fsstress wmtruncate work truncate MDS --------------- ------------------ -------------------------- lock i_mutex <- truncate file lock i_mutex (blocked) <- revoking Fcb (filelock to MIX) send request -> handle request (xlock filelock) At the initial time, there are some dirty pages in the page cache. When the kclient receives the truncate message, it reduces inode size and creates some 'out of i_size' dirty pages. wmtruncate work can't truncate these dirty pages because it's blocked by the i_mutex. Later when the kclient receives the cap message that revokes Fcb caps, It can't flush all dirty pages because writepages() only flushes dirty pages within the inode size. When the MDS handles the 'truncate' request from kclient, it waits for the filelock to become stable. But the filelock is stuck in unstable state because it can't finish revoking kclient's Fcb caps. The truncate pagecache locking has already caused lots of trouble for use. I think it's time simplify it by introducing a new mutex. We use the new mutex to prevent concurrent truncate_inode_pages(). There is no need to worry about race between buffered write and truncate_inode_pages(), because our "get caps" mechanism prevents them from concurrent execution. Reviewed-by: Sage Weil <sage@inktank.com> Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Diffstat (limited to 'fs/ceph/file.c')
-rw-r--r--fs/ceph/file.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index bc07354..abc0e07 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -773,6 +773,13 @@ retry_snap:
goto retry_snap;
}
} else {
+ /*
+ * No need to acquire the i_truncate_mutex. Because
+ * the MDS revokes Fwb caps before sending truncate
+ * message to us. We can't get Fwb cap while there
+ * are pending vmtruncate. So write and vmtruncate
+ * can not run at the same time
+ */
written = generic_file_buffered_write(iocb, iov, nr_segs,
pos, &iocb->ki_pos,
count, 0);
@@ -819,7 +826,6 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence)
int ret;
mutex_lock(&inode->i_mutex);
- __ceph_do_pending_vmtruncate(inode);
if (whence == SEEK_END || whence == SEEK_DATA || whence == SEEK_HOLE) {
ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE);
OpenPOWER on IntegriCloud