]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
libceph: fix log output race condition in OSD client
authorSimon Buttgereit <simon.buttgereit@tu-ilmenau.de>
Thu, 25 Sep 2025 07:57:26 +0000 (09:57 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 10 Dec 2025 10:50:53 +0000 (11:50 +0100)
OSD client logging has a problem in get_osd() and put_osd().
For one logging output refcount_read() is called twice. If recount
value changes between both calls logging output is not consistent.

This patch prints out only the resulting value.

[ idryomov: don't make the log messages more verbose ]

Signed-off-by: Simon Buttgereit <simon.buttgereit@tu-ilmenau.de>
Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
net/ceph/osd_client.c

index 6664ea73ccf81b12199142b92bddde8a2ed471e4..3667319b949ddcdab76ff7182a08a39b50d83b16 100644 (file)
@@ -1280,8 +1280,7 @@ static struct ceph_osd *create_osd(struct ceph_osd_client *osdc, int onum)
 static struct ceph_osd *get_osd(struct ceph_osd *osd)
 {
        if (refcount_inc_not_zero(&osd->o_ref)) {
-               dout("get_osd %p %d -> %d\n", osd, refcount_read(&osd->o_ref)-1,
-                    refcount_read(&osd->o_ref));
+               dout("get_osd %p -> %d\n", osd, refcount_read(&osd->o_ref));
                return osd;
        } else {
                dout("get_osd %p FAIL\n", osd);
@@ -1291,8 +1290,7 @@ static struct ceph_osd *get_osd(struct ceph_osd *osd)
 
 static void put_osd(struct ceph_osd *osd)
 {
-       dout("put_osd %p %d -> %d\n", osd, refcount_read(&osd->o_ref),
-            refcount_read(&osd->o_ref) - 1);
+       dout("put_osd %p -> %d\n", osd, refcount_read(&osd->o_ref) - 1);
        if (refcount_dec_and_test(&osd->o_ref)) {
                osd_cleanup(osd);
                kfree(osd);