From: Dan Carpenter <dan.carpenter@oracle.com>
To: zyan@redhat.com
Cc: ceph-devel@vger.kernel.org
Subject: re: ceph: cleanup ceph_flush_snaps()
Date: Wed, 3 Aug 2016 13:55:36 +0300 [thread overview]
Message-ID: <20160803105536.GA22419@mwanda> (raw)
Hello Yan, Zheng,
This is a semi-automatic email about new static checker warnings.
The patch ed9b430c9ba9: "ceph: cleanup ceph_flush_snaps()" from Jul
5, 2016, leads to the following Smatch complaint:
fs/ceph/caps.c:1387 ceph_flush_snaps()
warn: variable dereferenced before check 'psession' (see line 1350)
fs/ceph/caps.c
1349 struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
1350 struct ceph_mds_session *session = *psession;
^^^^^^^^^
New code assume psession can't be NULL.
1351 int mds;
1352 dout("ceph_flush_snaps %p\n", inode);
1353 retry:
1354 spin_lock(&ci->i_ceph_lock);
1355 if (!(ci->i_ceph_flags & CEPH_I_FLUSH_SNAPS)) {
1356 dout(" no capsnap needs flush, doing nothing\n");
1357 goto out;
1358 }
1359 if (!ci->i_auth_cap) {
1360 dout(" no auth cap (migrating?), doing nothing\n");
1361 goto out;
1362 }
1363
1364 mds = ci->i_auth_cap->session->s_mds;
1365 if (session && session->s_mds != mds) {
1366 dout(" oops, wrong session %p mutex\n", session);
1367 mutex_unlock(&session->s_mutex);
1368 ceph_put_mds_session(session);
1369 session = NULL;
1370 }
1371 if (!session) {
1372 spin_unlock(&ci->i_ceph_lock);
1373 mutex_lock(&mdsc->mutex);
1374 session = __ceph_lookup_mds_session(mdsc, mds);
1375 mutex_unlock(&mdsc->mutex);
1376 if (session) {
1377 dout(" inverting session/ino locks on %p\n", session);
1378 mutex_lock(&session->s_mutex);
1379 }
1380 goto retry;
1381 }
1382
1383 __ceph_flush_snaps(ci, session);
1384 out:
1385 spin_unlock(&ci->i_ceph_lock);
1386
1387 if (psession) {
^^^^^^^^
Old code assumed it could be.
1388 *psession = session;
1389 } else {
regards,
dan carpenter
reply other threads:[~2016-08-03 10:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160803105536.GA22419@mwanda \
--to=dan.carpenter@oracle.com \
--cc=ceph-devel@vger.kernel.org \
--cc=zyan@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.