Skip to content

Commit

Permalink
Merge tag 'ceph-for-6.1-rc6' of https://github.com/ceph/ceph-client
Browse files Browse the repository at this point in the history
Pull ceph fixes from Ilya Dryomov:
 "Three filesystem bug fixes, intended for stable"

* tag 'ceph-for-6.1-rc6' of https://github.com/ceph/ceph-client:
  ceph: fix NULL pointer dereference for req->r_session
  ceph: avoid putting the realm twice when decoding snaps fails
  ceph: fix a NULL vs IS_ERR() check when calling ceph_lookup_inode()
  MAINTAINERS: git://github.com -> https://github.com for ceph
  • Loading branch information
torvalds committed Nov 17, 2022
2 parents 81ac256 + 5bd76b8 commit ae75334
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 41 deletions.
6 changes: 3 additions & 3 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -4809,7 +4809,7 @@ R: Jeff Layton <[email protected]>
L: [email protected]
S: Supported
W: http://ceph.com/
T: git git://github.com/ceph/ceph-client.git
T: git https://github.com/ceph/ceph-client.git
F: include/linux/ceph/
F: include/linux/crush/
F: net/ceph/
Expand All @@ -4821,7 +4821,7 @@ R: Jeff Layton <[email protected]>
L: [email protected]
S: Supported
W: http://ceph.com/
T: git git://github.com/ceph/ceph-client.git
T: git https://github.com/ceph/ceph-client.git
F: Documentation/filesystems/ceph.rst
F: fs/ceph/

Expand Down Expand Up @@ -17222,7 +17222,7 @@ R: Dongsheng Yang <[email protected]>
L: [email protected]
S: Supported
W: http://ceph.com/
T: git git://github.com/ceph/ceph-client.git
T: git https://github.com/ceph/ceph-client.git
F: Documentation/ABI/testing/sysfs-bus-rbd
F: drivers/block/rbd.c
F: drivers/block/rbd_types.h
Expand Down
48 changes: 12 additions & 36 deletions fs/ceph/caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,6 @@ static int flush_mdlog_and_wait_inode_unsafe_requests(struct inode *inode)
struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_mds_request *req1 = NULL, *req2 = NULL;
unsigned int max_sessions;
int ret, err = 0;

spin_lock(&ci->i_unsafe_lock);
Expand All @@ -2266,28 +2265,24 @@ static int flush_mdlog_and_wait_inode_unsafe_requests(struct inode *inode)
}
spin_unlock(&ci->i_unsafe_lock);

/*
* The mdsc->max_sessions is unlikely to be changed
* mostly, here we will retry it by reallocating the
* sessions array memory to get rid of the mdsc->mutex
* lock.
*/
retry:
max_sessions = mdsc->max_sessions;

/*
* Trigger to flush the journal logs in all the relevant MDSes
* manually, or in the worst case we must wait at most 5 seconds
* to wait the journal logs to be flushed by the MDSes periodically.
*/
if ((req1 || req2) && likely(max_sessions)) {
struct ceph_mds_session **sessions = NULL;
struct ceph_mds_session *s;
if (req1 || req2) {
struct ceph_mds_request *req;
struct ceph_mds_session **sessions;
struct ceph_mds_session *s;
unsigned int max_sessions;
int i;

mutex_lock(&mdsc->mutex);
max_sessions = mdsc->max_sessions;

sessions = kcalloc(max_sessions, sizeof(s), GFP_KERNEL);
if (!sessions) {
mutex_unlock(&mdsc->mutex);
err = -ENOMEM;
goto out;
}
Expand All @@ -2299,16 +2294,6 @@ static int flush_mdlog_and_wait_inode_unsafe_requests(struct inode *inode)
s = req->r_session;
if (!s)
continue;
if (unlikely(s->s_mds >= max_sessions)) {
spin_unlock(&ci->i_unsafe_lock);
for (i = 0; i < max_sessions; i++) {
s = sessions[i];
if (s)
ceph_put_mds_session(s);
}
kfree(sessions);
goto retry;
}
if (!sessions[s->s_mds]) {
s = ceph_get_mds_session(s);
sessions[s->s_mds] = s;
Expand All @@ -2321,16 +2306,6 @@ static int flush_mdlog_and_wait_inode_unsafe_requests(struct inode *inode)
s = req->r_session;
if (!s)
continue;
if (unlikely(s->s_mds >= max_sessions)) {
spin_unlock(&ci->i_unsafe_lock);
for (i = 0; i < max_sessions; i++) {
s = sessions[i];
if (s)
ceph_put_mds_session(s);
}
kfree(sessions);
goto retry;
}
if (!sessions[s->s_mds]) {
s = ceph_get_mds_session(s);
sessions[s->s_mds] = s;
Expand All @@ -2342,11 +2317,12 @@ static int flush_mdlog_and_wait_inode_unsafe_requests(struct inode *inode)
/* the auth MDS */
spin_lock(&ci->i_ceph_lock);
if (ci->i_auth_cap) {
s = ci->i_auth_cap->session;
if (!sessions[s->s_mds])
sessions[s->s_mds] = ceph_get_mds_session(s);
s = ci->i_auth_cap->session;
if (!sessions[s->s_mds])
sessions[s->s_mds] = ceph_get_mds_session(s);
}
spin_unlock(&ci->i_ceph_lock);
mutex_unlock(&mdsc->mutex);

/* send flush mdlog request to MDSes */
for (i = 0; i < max_sessions; i++) {
Expand Down
2 changes: 1 addition & 1 deletion fs/ceph/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2492,7 +2492,7 @@ int ceph_getattr(struct user_namespace *mnt_userns, const struct path *path,
struct inode *parent;

parent = ceph_lookup_inode(sb, ceph_ino(inode));
if (!parent)
if (IS_ERR(parent))
return PTR_ERR(parent);

pci = ceph_inode(parent);
Expand Down
3 changes: 2 additions & 1 deletion fs/ceph/snap.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc,
struct ceph_mds_snap_realm *ri; /* encoded */
__le64 *snaps; /* encoded */
__le64 *prior_parent_snaps; /* encoded */
struct ceph_snap_realm *realm = NULL;
struct ceph_snap_realm *realm;
struct ceph_snap_realm *first_realm = NULL;
struct ceph_snap_realm *realm_to_rebuild = NULL;
int rebuild_snapcs;
Expand All @@ -774,6 +774,7 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc,

dout("%s deletion=%d\n", __func__, deletion);
more:
realm = NULL;
rebuild_snapcs = 0;
ceph_decode_need(&p, e, sizeof(*ri), bad);
ri = p;
Expand Down

0 comments on commit ae75334

Please sign in to comment.