* [PATCH v4] ceph: defer flushing the capsnap if the Fb is used
@ 2021-02-02 6:54 xiubli
2021-02-02 15:59 ` Jeff Layton
0 siblings, 1 reply; 3+ messages in thread
From: xiubli @ 2021-02-02 6:54 UTC (permalink / raw)
To: jlayton; +Cc: idryomov, pdonnell, ceph-devel, Xiubo Li
From: Xiubo Li <xiubli@redhat.com>
If the Fb cap is used it means the current inode is flushing the
dirty data to OSD, just defer flushing the capsnap.
URL: https://tracker.ceph.com/issues/48679
URL: https://tracker.ceph.com/issues/48640
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
V4:
- Fix stuck issue when running the snaptest-git-ceph.sh pointed by Jeff.
V3:
- Add more comments about putting the inode ref
- A small change about the code style
V2:
- Fix inode reference leak bug
fs/ceph/caps.c | 33 ++++++++++++++++++++-------------
fs/ceph/snap.c | 10 ++++++++++
2 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index abbf48fc6230..570731c4d019 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -3047,6 +3047,7 @@ static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had,
{
struct inode *inode = &ci->vfs_inode;
int last = 0, put = 0, flushsnaps = 0, wake = 0;
+ bool check_flushsnaps = false;
spin_lock(&ci->i_ceph_lock);
if (had & CEPH_CAP_PIN)
@@ -3063,26 +3064,17 @@ static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had,
if (had & CEPH_CAP_FILE_BUFFER) {
if (--ci->i_wb_ref == 0) {
last++;
+ /* put the ref held by ceph_take_cap_refs() */
put++;
+ check_flushsnaps = true;
}
dout("put_cap_refs %p wb %d -> %d (?)\n",
inode, ci->i_wb_ref+1, ci->i_wb_ref);
}
- if (had & CEPH_CAP_FILE_WR)
+ if (had & CEPH_CAP_FILE_WR) {
if (--ci->i_wr_ref == 0) {
last++;
- if (__ceph_have_pending_cap_snap(ci)) {
- struct ceph_cap_snap *capsnap =
- list_last_entry(&ci->i_cap_snaps,
- struct ceph_cap_snap,
- ci_item);
- capsnap->writing = 0;
- if (ceph_try_drop_cap_snap(ci, capsnap))
- put++;
- else if (__ceph_finish_cap_snap(ci, capsnap))
- flushsnaps = 1;
- wake = 1;
- }
+ check_flushsnaps = true;
if (ci->i_wrbuffer_ref_head == 0 &&
ci->i_dirty_caps == 0 &&
ci->i_flushing_caps == 0) {
@@ -3094,6 +3086,21 @@ static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had,
if (!__ceph_is_any_real_caps(ci) && ci->i_snap_realm)
drop_inode_snap_realm(ci);
}
+ }
+ if (check_flushsnaps && __ceph_have_pending_cap_snap(ci)) {
+ struct ceph_cap_snap *capsnap =
+ list_last_entry(&ci->i_cap_snaps,
+ struct ceph_cap_snap,
+ ci_item);
+
+ capsnap->writing = 0;
+ if (ceph_try_drop_cap_snap(ci, capsnap))
+ /* put the ref held by ceph_queue_cap_snap() */
+ put++;
+ else if (__ceph_finish_cap_snap(ci, capsnap))
+ flushsnaps = 1;
+ wake = 1;
+ }
spin_unlock(&ci->i_ceph_lock);
dout("put_cap_refs %p had %s%s%s\n", inode, ceph_cap_string(had),
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index b611f829cb61..0728b01d4d43 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -623,6 +623,16 @@ int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
return 0;
}
+ /* Fb cap still in use, delay it */
+ if (ci->i_wb_ref) {
+ dout("finish_cap_snap %p cap_snap %p snapc %p %llu %s s=%llu "
+ "used WRBUFFER, delaying\n", inode, capsnap,
+ capsnap->context, capsnap->context->seq,
+ ceph_cap_string(capsnap->dirty), capsnap->size);
+ capsnap->writing = 1;
+ return 0;
+ }
+
ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS;
dout("finish_cap_snap %p cap_snap %p snapc %p %llu %s s=%llu\n",
inode, capsnap, capsnap->context,
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v4] ceph: defer flushing the capsnap if the Fb is used
2021-02-02 6:54 [PATCH v4] ceph: defer flushing the capsnap if the Fb is used xiubli
@ 2021-02-02 15:59 ` Jeff Layton
2021-02-03 1:05 ` Xiubo Li
0 siblings, 1 reply; 3+ messages in thread
From: Jeff Layton @ 2021-02-02 15:59 UTC (permalink / raw)
To: xiubli; +Cc: idryomov, pdonnell, ceph-devel
On Tue, 2021-02-02 at 14:54 +0800, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>
>
> If the Fb cap is used it means the current inode is flushing the
> dirty data to OSD, just defer flushing the capsnap.
>
> URL: https://tracker.ceph.com/issues/48679
> URL: https://tracker.ceph.com/issues/48640
> Signed-off-by: Xiubo Li <xiubli@redhat.com>
> ---
>
> V4:
> - Fix stuck issue when running the snaptest-git-ceph.sh pointed by Jeff.
>
> V3:
> - Add more comments about putting the inode ref
> - A small change about the code style
>
> V2:
> - Fix inode reference leak bug
>
>
> fs/ceph/caps.c | 33 ++++++++++++++++++++-------------
> fs/ceph/snap.c | 10 ++++++++++
> 2 files changed, 30 insertions(+), 13 deletions(-)
>
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index abbf48fc6230..570731c4d019 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -3047,6 +3047,7 @@ static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had,
> {
> struct inode *inode = &ci->vfs_inode;
> int last = 0, put = 0, flushsnaps = 0, wake = 0;
> + bool check_flushsnaps = false;
>
>
> spin_lock(&ci->i_ceph_lock);
> if (had & CEPH_CAP_PIN)
> @@ -3063,26 +3064,17 @@ static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had,
> if (had & CEPH_CAP_FILE_BUFFER) {
> if (--ci->i_wb_ref == 0) {
> last++;
> + /* put the ref held by ceph_take_cap_refs() */
> put++;
> + check_flushsnaps = true;
> }
> dout("put_cap_refs %p wb %d -> %d (?)\n",
> inode, ci->i_wb_ref+1, ci->i_wb_ref);
> }
> - if (had & CEPH_CAP_FILE_WR)
> + if (had & CEPH_CAP_FILE_WR) {
> if (--ci->i_wr_ref == 0) {
> last++;
> - if (__ceph_have_pending_cap_snap(ci)) {
> - struct ceph_cap_snap *capsnap =
> - list_last_entry(&ci->i_cap_snaps,
> - struct ceph_cap_snap,
> - ci_item);
> - capsnap->writing = 0;
> - if (ceph_try_drop_cap_snap(ci, capsnap))
> - put++;
> - else if (__ceph_finish_cap_snap(ci, capsnap))
> - flushsnaps = 1;
> - wake = 1;
> - }
> + check_flushsnaps = true;
> if (ci->i_wrbuffer_ref_head == 0 &&
> ci->i_dirty_caps == 0 &&
> ci->i_flushing_caps == 0) {
> @@ -3094,6 +3086,21 @@ static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had,
> if (!__ceph_is_any_real_caps(ci) && ci->i_snap_realm)
> drop_inode_snap_realm(ci);
> }
> + }
> + if (check_flushsnaps && __ceph_have_pending_cap_snap(ci)) {
> + struct ceph_cap_snap *capsnap =
> + list_last_entry(&ci->i_cap_snaps,
> + struct ceph_cap_snap,
> + ci_item);
> +
> + capsnap->writing = 0;
> + if (ceph_try_drop_cap_snap(ci, capsnap))
> + /* put the ref held by ceph_queue_cap_snap() */
> + put++;
> + else if (__ceph_finish_cap_snap(ci, capsnap))
> + flushsnaps = 1;
> + wake = 1;
> + }
> spin_unlock(&ci->i_ceph_lock);
>
>
> dout("put_cap_refs %p had %s%s%s\n", inode, ceph_cap_string(had),
> diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
> index b611f829cb61..0728b01d4d43 100644
> --- a/fs/ceph/snap.c
> +++ b/fs/ceph/snap.c
> @@ -623,6 +623,16 @@ int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
> return 0;
> }
>
>
> + /* Fb cap still in use, delay it */
> + if (ci->i_wb_ref) {
> + dout("finish_cap_snap %p cap_snap %p snapc %p %llu %s s=%llu "
> + "used WRBUFFER, delaying\n", inode, capsnap,
> + capsnap->context, capsnap->context->seq,
> + ceph_cap_string(capsnap->dirty), capsnap->size);
> + capsnap->writing = 1;
> + return 0;
> + }
> +
> ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS;
> dout("finish_cap_snap %p cap_snap %p snapc %p %llu %s s=%llu\n",
> inode, capsnap, capsnap->context,
Much better. This one seems to behave better. I've gone ahead and taken
this into testing branch.
Thanks!
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v4] ceph: defer flushing the capsnap if the Fb is used
2021-02-02 15:59 ` Jeff Layton
@ 2021-02-03 1:05 ` Xiubo Li
0 siblings, 0 replies; 3+ messages in thread
From: Xiubo Li @ 2021-02-03 1:05 UTC (permalink / raw)
To: Jeff Layton; +Cc: idryomov, pdonnell, ceph-devel
On 2021/2/2 23:59, Jeff Layton wrote:
> On Tue, 2021-02-02 at 14:54 +0800, xiubli@redhat.com wrote:
>> From: Xiubo Li <xiubli@redhat.com>
>>
>> If the Fb cap is used it means the current inode is flushing the
>> dirty data to OSD, just defer flushing the capsnap.
>>
>> URL: https://tracker.ceph.com/issues/48679
>> URL: https://tracker.ceph.com/issues/48640
>> Signed-off-by: Xiubo Li <xiubli@redhat.com>
>> ---
>>
>> V4:
>> - Fix stuck issue when running the snaptest-git-ceph.sh pointed by Jeff.
>>
>> V3:
>> - Add more comments about putting the inode ref
>> - A small change about the code style
>>
>> V2:
>> - Fix inode reference leak bug
>>
>>
>> fs/ceph/caps.c | 33 ++++++++++++++++++++-------------
>> fs/ceph/snap.c | 10 ++++++++++
>> 2 files changed, 30 insertions(+), 13 deletions(-)
>>
>> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
>> index abbf48fc6230..570731c4d019 100644
>> --- a/fs/ceph/caps.c
>> +++ b/fs/ceph/caps.c
>> @@ -3047,6 +3047,7 @@ static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had,
>> {
>> struct inode *inode = &ci->vfs_inode;
>> int last = 0, put = 0, flushsnaps = 0, wake = 0;
>> + bool check_flushsnaps = false;
>>
>>
>> spin_lock(&ci->i_ceph_lock);
>> if (had & CEPH_CAP_PIN)
>> @@ -3063,26 +3064,17 @@ static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had,
>> if (had & CEPH_CAP_FILE_BUFFER) {
>> if (--ci->i_wb_ref == 0) {
>> last++;
>> + /* put the ref held by ceph_take_cap_refs() */
>> put++;
>> + check_flushsnaps = true;
>> }
>> dout("put_cap_refs %p wb %d -> %d (?)\n",
>> inode, ci->i_wb_ref+1, ci->i_wb_ref);
>> }
>> - if (had & CEPH_CAP_FILE_WR)
>> + if (had & CEPH_CAP_FILE_WR) {
>> if (--ci->i_wr_ref == 0) {
>> last++;
>> - if (__ceph_have_pending_cap_snap(ci)) {
>> - struct ceph_cap_snap *capsnap =
>> - list_last_entry(&ci->i_cap_snaps,
>> - struct ceph_cap_snap,
>> - ci_item);
>> - capsnap->writing = 0;
>> - if (ceph_try_drop_cap_snap(ci, capsnap))
>> - put++;
>> - else if (__ceph_finish_cap_snap(ci, capsnap))
>> - flushsnaps = 1;
>> - wake = 1;
>> - }
>> + check_flushsnaps = true;
>> if (ci->i_wrbuffer_ref_head == 0 &&
>> ci->i_dirty_caps == 0 &&
>> ci->i_flushing_caps == 0) {
>> @@ -3094,6 +3086,21 @@ static void __ceph_put_cap_refs(struct ceph_inode_info *ci, int had,
>> if (!__ceph_is_any_real_caps(ci) && ci->i_snap_realm)
>> drop_inode_snap_realm(ci);
>> }
>> + }
>> + if (check_flushsnaps && __ceph_have_pending_cap_snap(ci)) {
>> + struct ceph_cap_snap *capsnap =
>> + list_last_entry(&ci->i_cap_snaps,
>> + struct ceph_cap_snap,
>> + ci_item);
>> +
>> + capsnap->writing = 0;
>> + if (ceph_try_drop_cap_snap(ci, capsnap))
>> + /* put the ref held by ceph_queue_cap_snap() */
>> + put++;
>> + else if (__ceph_finish_cap_snap(ci, capsnap))
>> + flushsnaps = 1;
>> + wake = 1;
>> + }
>> spin_unlock(&ci->i_ceph_lock);
>>
>>
>> dout("put_cap_refs %p had %s%s%s\n", inode, ceph_cap_string(had),
>> diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
>> index b611f829cb61..0728b01d4d43 100644
>> --- a/fs/ceph/snap.c
>> +++ b/fs/ceph/snap.c
>> @@ -623,6 +623,16 @@ int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
>> return 0;
>> }
>>
>>
>> + /* Fb cap still in use, delay it */
>> + if (ci->i_wb_ref) {
>> + dout("finish_cap_snap %p cap_snap %p snapc %p %llu %s s=%llu "
>> + "used WRBUFFER, delaying\n", inode, capsnap,
>> + capsnap->context, capsnap->context->seq,
>> + ceph_cap_string(capsnap->dirty), capsnap->size);
>> + capsnap->writing = 1;
>> + return 0;
>> + }
>> +
>> ci->i_ceph_flags |= CEPH_I_FLUSH_SNAPS;
>> dout("finish_cap_snap %p cap_snap %p snapc %p %llu %s s=%llu\n",
>> inode, capsnap, capsnap->context,
> Much better. This one seems to behave better. I've gone ahead and taken
> this into testing branch.
Sure, thanks.
BRs
> Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-03 1:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 6:54 [PATCH v4] ceph: defer flushing the capsnap if the Fb is used xiubli
2021-02-02 15:59 ` Jeff Layton
2021-02-03 1:05 ` Xiubo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).