inet: inet_defrag: Removing the usage of refcount_inc_not_zero
Subsystems (3)
PATCH 1/1 inet: inet_defrag: Removing the usage of refcount_inc_not_zero
Remove refcount_inc_not_zero as per the listed TODO in the file. Used spin_(un)lock and refcount_* functions for synchronization.
Signed-off-by Abhinav Jain <[email protected]>
--- net/ipv4/inet_fragment.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/ipv4/inet_fragment.c +7 -2
@@ -358,7 +358,6 @@ static struct inet_frag_queue *inet_frag_create(struct fqdir *fqdir,return q; } -/* TODO : call from rcu_read_lock() and no longer use refcount_inc_not_zero() */ struct inet_frag_queue *inet_frag_find (struct fqdir *fqdir,void *key) {/* This pairs with WRITE_ONCE() in fqdir_pre_exit(). */
@@ -375,8 +374,14 @@ struct inet_frag_queue *inet_frag_find(struct fqdir *fqdir, void *key) fq =inet_frag_create (fqdir, key, &prev);if (!IS_ERR_OR_NULL (prev)) { fq = prev; -if (!refcount_inc_not_zero (&fq->refcnt)) +spin_lock (&fq->lock); +if (refcount_read (&fq->refcnt) >0 ) { +refcount_inc (&fq->refcnt); +spin_unlock (&fq->lock); + }else { +spin_unlock (&fq->lock); fq =NULL ; + } }rcu_read_unlock ();return fq;
Signature · 1 line
2.34.1
Quoted 25 lines · Abhinav Jain
Remove
refcount_inc_not_zeroas per the listed TODO in the file. Used spin_(un)lock and refcount_* functions for synchronization.Signed-off-by Abhinav Jain <[email protected]>--- net/ipv4/inet_fragment.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)net/ipv4/inet_fragment.c +0
-1@@ -358,7 +358,6 @@ static struct inet_frag_queue *inet_frag_create(struct fqdir *fqdir,return q; } -/* TODO : call from rcu_read_lock() and no longer use refcount_inc_not_zero() */ struct inet_frag_queue *inet_frag_find (struct fqdir *fqdir,void *key) {/* This pairs with WRITE_ONCE() in fqdir_pre_exit(). */ @@ -375,8 +374,14 @@ struct inet_frag_queue *inet_frag_find(struct fqdir *fqdir, void *key) fq =inet_frag_create (fqdir, key, &prev);if (!IS_ERR_OR_NULL (prev)) { fq = prev;
net/ipv4/inet_fragment.c struct inet_frag_queue *inet_frag_find(struct fqdir *fqdir, void *key) · line 385
Quoted 10 lines
net/ipv4/inet_fragment.c +7
-1-if (!refcount_inc_not_zero (&fq->refcnt)) +spin_lock (&fq->lock); +if (refcount_read (&fq->refcnt) >0 ) { +refcount_inc (&fq->refcnt); +spin_unlock (&fq->lock); + }else { +spin_unlock (&fq->lock); fq =NULL ; + }
This is bogus. I do not think you understood the comment.