Skip to content

Commit d6c2f41

Browse files
HolyShitManidryomov
authored andcommitted
libceph: fix log output race condition in OSD client
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>
1 parent 7d0a66e commit d6c2f41

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

net/ceph/osd_client.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,8 +1280,7 @@ static struct ceph_osd *create_osd(struct ceph_osd_client *osdc, int onum)
12801280
static struct ceph_osd *get_osd(struct ceph_osd *osd)
12811281
{
12821282
if (refcount_inc_not_zero(&osd->o_ref)) {
1283-
dout("get_osd %p %d -> %d\n", osd, refcount_read(&osd->o_ref)-1,
1284-
refcount_read(&osd->o_ref));
1283+
dout("get_osd %p -> %d\n", osd, refcount_read(&osd->o_ref));
12851284
return osd;
12861285
} else {
12871286
dout("get_osd %p FAIL\n", osd);
@@ -1291,8 +1290,7 @@ static struct ceph_osd *get_osd(struct ceph_osd *osd)
12911290

12921291
static void put_osd(struct ceph_osd *osd)
12931292
{
1294-
dout("put_osd %p %d -> %d\n", osd, refcount_read(&osd->o_ref),
1295-
refcount_read(&osd->o_ref) - 1);
1293+
dout("put_osd %p -> %d\n", osd, refcount_read(&osd->o_ref) - 1);
12961294
if (refcount_dec_and_test(&osd->o_ref)) {
12971295
osd_cleanup(osd);
12981296
kfree(osd);

0 commit comments

Comments
 (0)