diff options
author | Yan, Zheng <zyan@redhat.com> | 2016-05-18 08:58:26 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2016-05-25 19:15:42 -0400 |
commit | 9abd4db713704aac146395e079224ddd716e9b95 (patch) | |
tree | bf7ddd4b76b0b20b45e905c6854d1b74551c06f6 /fs | |
parent | b109eec6f4332bd517e2f41e207037c4b9065094 (diff) |
ceph: don't use truncate_pagecache() to invalidate read cache
truncate_pagecache() drops dirty pages, it's dangerous to use it
to invalidate read cache. Besides, we shouldn't start invalidating
read cache while there are buffer writers. Because buffer writers
may add dirty pages later.
Signed-off-by: Yan, Zheng <zyan@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ceph/caps.c | 8 | ||||
-rw-r--r-- | fs/ceph/inode.c | 4 |
2 files changed, 7 insertions, 5 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index fab93c66d879..c17b5d76d75e 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c | |||
@@ -1656,7 +1656,7 @@ retry_locked: | |||
1656 | */ | 1656 | */ |
1657 | if ((!is_delayed || mdsc->stopping) && | 1657 | if ((!is_delayed || mdsc->stopping) && |
1658 | !S_ISDIR(inode->i_mode) && /* ignore readdir cache */ | 1658 | !S_ISDIR(inode->i_mode) && /* ignore readdir cache */ |
1659 | ci->i_wrbuffer_ref == 0 && /* no dirty pages... */ | 1659 | !(ci->i_wb_ref || ci->i_wrbuffer_ref) && /* no dirty pages... */ |
1660 | inode->i_data.nrpages && /* have cached pages */ | 1660 | inode->i_data.nrpages && /* have cached pages */ |
1661 | (revoking & (CEPH_CAP_FILE_CACHE| | 1661 | (revoking & (CEPH_CAP_FILE_CACHE| |
1662 | CEPH_CAP_FILE_LAZYIO)) && /* or revoking cache */ | 1662 | CEPH_CAP_FILE_LAZYIO)) && /* or revoking cache */ |
@@ -1698,8 +1698,8 @@ retry_locked: | |||
1698 | 1698 | ||
1699 | revoking = cap->implemented & ~cap->issued; | 1699 | revoking = cap->implemented & ~cap->issued; |
1700 | dout(" mds%d cap %p used %s issued %s implemented %s revoking %s\n", | 1700 | dout(" mds%d cap %p used %s issued %s implemented %s revoking %s\n", |
1701 | cap->mds, cap, ceph_cap_string(cap->issued), | 1701 | cap->mds, cap, ceph_cap_string(cap_used), |
1702 | ceph_cap_string(cap_used), | 1702 | ceph_cap_string(cap->issued), |
1703 | ceph_cap_string(cap->implemented), | 1703 | ceph_cap_string(cap->implemented), |
1704 | ceph_cap_string(revoking)); | 1704 | ceph_cap_string(revoking)); |
1705 | 1705 | ||
@@ -2828,7 +2828,7 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc, | |||
2828 | if (!S_ISDIR(inode->i_mode) && /* don't invalidate readdir cache */ | 2828 | if (!S_ISDIR(inode->i_mode) && /* don't invalidate readdir cache */ |
2829 | ((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) && | 2829 | ((cap->issued & ~newcaps) & CEPH_CAP_FILE_CACHE) && |
2830 | (newcaps & CEPH_CAP_FILE_LAZYIO) == 0 && | 2830 | (newcaps & CEPH_CAP_FILE_LAZYIO) == 0 && |
2831 | !ci->i_wrbuffer_ref) { | 2831 | !(ci->i_wrbuffer_ref || ci->i_wb_ref)) { |
2832 | if (try_nonblocking_invalidate(inode)) { | 2832 | if (try_nonblocking_invalidate(inode)) { |
2833 | /* there were locked pages.. invalidate later | 2833 | /* there were locked pages.. invalidate later |
2834 | in a separate thread. */ | 2834 | in a separate thread. */ |
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 89d08155986d..07495ba61fe3 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c | |||
@@ -1728,7 +1728,9 @@ static void ceph_invalidate_work(struct work_struct *work) | |||
1728 | orig_gen = ci->i_rdcache_gen; | 1728 | orig_gen = ci->i_rdcache_gen; |
1729 | spin_unlock(&ci->i_ceph_lock); | 1729 | spin_unlock(&ci->i_ceph_lock); |
1730 | 1730 | ||
1731 | truncate_pagecache(inode, 0); | 1731 | if (invalidate_inode_pages2(inode->i_mapping) < 0) { |
1732 | pr_err("invalidate_pages %p fails\n", inode); | ||
1733 | } | ||
1732 | 1734 | ||
1733 | spin_lock(&ci->i_ceph_lock); | 1735 | spin_lock(&ci->i_ceph_lock); |
1734 | if (orig_gen == ci->i_rdcache_gen && | 1736 | if (orig_gen == ci->i_rdcache_gen && |