ceph: init the i_list/g_list for cap flush
Subsystems (2)
PATCH 1/1 ceph: init the i_list/g_list for cap flush
From: Xiubo Li <[email protected]>
Always init the i_list/g_list in the begining to make sure it won't crash the kernel if someone want to delete the cap_flush from the lists.
Cc: [email protected]
URL: https://tracker.ceph.com/issues/52401
--- fs/ceph/caps.c | 2 +- fs/ceph/snap.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)
fs/ceph/caps.c +1 -1
@@ -3666,7 +3666,7 @@ static void handle_cap_flush_ack(struct inode *inode, u64 flush_tid,while (!list_empty (&to_remove)) { cf =list_first_entry (&to_remove, struct ceph_cap_flush, i_list); -list_del (&cf->i_list); +list_del_init (&cf->i_list);if (!cf->is_capsnap)ceph_free_cap_flush (cf); }
fs/ceph/snap.c +2 -0
@@ -488,6 +488,8 @@ static void ceph_queue_cap_snap(struct ceph_inode_info *ci)return ; } capsnap->cap_flush.is_capsnap = true; +INIT_LIST_HEAD (&capsnap->cap_flush.i_list); +INIT_LIST_HEAD (&capsnap->cap_flush.g_list);spin_lock (&ci->i_ceph_lock); used =__ceph_caps_used (ci);
Signature · 1 line
2.27.0
Quoted 32 lines · On Wed, 2021-08-25 at 13:22 +0800, [email protected] wrote:
From: Xiubo Li <[email protected]>
Always init the i_list/g_list in the begining to make sure it won't crash the kernel if someone want to delete the
cap_flushfrom the lists.Cc: [email protected]
URL: https://tracker.ceph.com/issues/52401Signed-off-by Xiubo Li <[email protected]>--- fs/ceph/caps.c | 2 +- fs/ceph/snap.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)fs/ceph/caps.c +1
-1@@ -3666,7 +3666,7 @@ static void handle_cap_flush_ack(struct inode *inode, u64 flush_tid,while (!list_empty (&to_remove)) { cf =list_first_entry (&to_remove, struct ceph_cap_flush, i_list); -list_del (&cf->i_list); +list_del_init (&cf->i_list);if (!cf->is_capsnap)ceph_free_cap_flush (cf); }fs/ceph/snap.c +0
-0
fs/ceph/snap.c static void ceph_queue_cap_snap(struct ceph_inode_info *ci) · line 495
Quoted 8 lines
fs/ceph/snap.c +2
-0@@ -488,6 +488,8 @@ static void ceph_queue_cap_snap(struct ceph_inode_info *ci)return ; } capsnap->cap_flush.is_capsnap = true; +INIT_LIST_HEAD (&capsnap->cap_flush.i_list); +INIT_LIST_HEAD (&capsnap->cap_flush.g_list);spin_lock (&ci->i_ceph_lock); used =__ceph_caps_used (ci);
I'm not certain the second hunk is strictly needed. These either end up on the list or they just get freed. That said, they shouldn't hurt anything and it is more consistent. Merged into testing.
Ilya, since this is marked for stable, this probably ought to go to Linus in the last v5.14 pile.
Thanks,
Signature · 1 line
Jeff Layton <[email protected]>
Ilya Dryomov
maintainerQuoted 47 lines · Jeff Layton
Quoted 32 lines · On Wed, 2021-08-25 at 13:22 +0800, [email protected] wrote:
From: Xiubo Li <[email protected]>
Always init the i_list/g_list in the begining to make sure it won't crash the kernel if someone want to delete the
cap_flushfrom the lists.Cc: [email protected]
URL: https://tracker.ceph.com/issues/52401Signed-off-by Xiubo Li <[email protected]>--- fs/ceph/caps.c | 2 +- fs/ceph/snap.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)fs/ceph/caps.c +1
-1@@ -3666,7 +3666,7 @@ static void handle_cap_flush_ack(struct inode *inode, u64 flush_tid,while (!list_empty (&to_remove)) { cf =list_first_entry (&to_remove, struct ceph_cap_flush, i_list); -list_del (&cf->i_list); +list_del_init (&cf->i_list);if (!cf->is_capsnap)ceph_free_cap_flush (cf); }fs/ceph/snap.c +0
-0fs/ceph/snap.c static void ceph_queue_cap_snap(struct ceph_inode_info *ci) · line 495
Quoted 8 lines
fs/ceph/snap.c +2
-0@@ -488,6 +488,8 @@ static void ceph_queue_cap_snap(struct ceph_inode_info *ci)return ; } capsnap->cap_flush.is_capsnap = true; +INIT_LIST_HEAD (&capsnap->cap_flush.i_list); +INIT_LIST_HEAD (&capsnap->cap_flush.g_list);spin_lock (&ci->i_ceph_lock); used =__ceph_caps_used (ci);I'm not certain the second hunk is strictly needed. These either end up on the list or they just get freed. That said, they shouldn't hurt anything and it is more consistent. Merged into testing.
Quoted 2 lines
Ilya, since this is marked for stable, this probably ought to go to Linus in the last v5.14 pile.
I'm inclined to fold this into "ceph: correctly handle releasing an embedded cap flush" which is already queued for 5.14.
Thanks,
Ilya
Quoted 46 lines · Ilya Dryomov
Quoted 45 lines · Jeff Layton
Quoted 32 lines · On Wed, 2021-08-25 at 13:22 +0800, [email protected] wrote:
From: Xiubo Li <[email protected]>
Always init the i_list/g_list in the begining to make sure it won't crash the kernel if someone want to delete the
cap_flushfrom the lists.Cc: [email protected]
URL: https://tracker.ceph.com/issues/52401Signed-off-by Xiubo Li <[email protected]>--- fs/ceph/caps.c | 2 +- fs/ceph/snap.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-)fs/ceph/caps.c +1
-1@@ -3666,7 +3666,7 @@ static void handle_cap_flush_ack(struct inode *inode, u64 flush_tid,while (!list_empty (&to_remove)) { cf =list_first_entry (&to_remove, struct ceph_cap_flush, i_list); -list_del (&cf->i_list); +list_del_init (&cf->i_list);if (!cf->is_capsnap)ceph_free_cap_flush (cf); }fs/ceph/snap.c +0
-0fs/ceph/snap.c static void ceph_queue_cap_snap(struct ceph_inode_info *ci) · line 495
Quoted 8 lines
fs/ceph/snap.c +2
-0@@ -488,6 +488,8 @@ static void ceph_queue_cap_snap(struct ceph_inode_info *ci)return ; } capsnap->cap_flush.is_capsnap = true; +INIT_LIST_HEAD (&capsnap->cap_flush.i_list); +INIT_LIST_HEAD (&capsnap->cap_flush.g_list);spin_lock (&ci->i_ceph_lock); used =__ceph_caps_used (ci);I'm not certain the second hunk is strictly needed. These either end up on the list or they just get freed. That said, they shouldn't hurt anything and it is more consistent. Merged into testing.
Quoted 4 lines
Quoted 2 lines
Ilya, since this is marked for stable, this probably ought to go to Linus in the last v5.14 pile.
I'm inclined to fold this into "ceph: correctly handle releasing an embedded cap flush" which is already queued for 5.14.
Yeah, that's will be better.
Quoted 5 lines
Thanks,
Ilya