Commit 64ebe312 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'ceph-for-4.17-rc3' of git://github.com/ceph/ceph-client

Pull ceph fixes from Ilya Dryomov:
 "A CephFS quota follow-up and fixes for two older issues in the
  messenger layer, marked for stable"

* tag 'ceph-for-4.17-rc3' of git://github.com/ceph/ceph-client:
  libceph: validate con->state at the top of try_write()
  libceph: reschedule a tick in finish_hunting()
  libceph: un-backoff on tick when we have a authenticated session
  ceph: check if mds create snaprealm when setting quota
parents d8a33273 9c55ad1c
...@@ -228,7 +228,15 @@ static size_t ceph_vxattrcb_dir_rctime(struct ceph_inode_info *ci, char *val, ...@@ -228,7 +228,15 @@ static size_t ceph_vxattrcb_dir_rctime(struct ceph_inode_info *ci, char *val,
static bool ceph_vxattrcb_quota_exists(struct ceph_inode_info *ci) static bool ceph_vxattrcb_quota_exists(struct ceph_inode_info *ci)
{ {
return (ci->i_max_files || ci->i_max_bytes); bool ret = false;
spin_lock(&ci->i_ceph_lock);
if ((ci->i_max_files || ci->i_max_bytes) &&
ci->i_vino.snap == CEPH_NOSNAP &&
ci->i_snap_realm &&
ci->i_snap_realm->ino == ci->i_vino.ino)
ret = true;
spin_unlock(&ci->i_ceph_lock);
return ret;
} }
static size_t ceph_vxattrcb_quota(struct ceph_inode_info *ci, char *val, static size_t ceph_vxattrcb_quota(struct ceph_inode_info *ci, char *val,
...@@ -1008,14 +1016,19 @@ int __ceph_setxattr(struct inode *inode, const char *name, ...@@ -1008,14 +1016,19 @@ int __ceph_setxattr(struct inode *inode, const char *name,
char *newval = NULL; char *newval = NULL;
struct ceph_inode_xattr *xattr = NULL; struct ceph_inode_xattr *xattr = NULL;
int required_blob_size; int required_blob_size;
bool check_realm = false;
bool lock_snap_rwsem = false; bool lock_snap_rwsem = false;
if (ceph_snap(inode) != CEPH_NOSNAP) if (ceph_snap(inode) != CEPH_NOSNAP)
return -EROFS; return -EROFS;
vxattr = ceph_match_vxattr(inode, name); vxattr = ceph_match_vxattr(inode, name);
if (vxattr && vxattr->readonly) if (vxattr) {
if (vxattr->readonly)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (value && !strncmp(vxattr->name, "ceph.quota", 10))
check_realm = true;
}
/* pass any unhandled ceph.* xattrs through to the MDS */ /* pass any unhandled ceph.* xattrs through to the MDS */
if (!strncmp(name, XATTR_CEPH_PREFIX, XATTR_CEPH_PREFIX_LEN)) if (!strncmp(name, XATTR_CEPH_PREFIX, XATTR_CEPH_PREFIX_LEN))
...@@ -1109,6 +1122,15 @@ int __ceph_setxattr(struct inode *inode, const char *name, ...@@ -1109,6 +1122,15 @@ int __ceph_setxattr(struct inode *inode, const char *name,
err = -EBUSY; err = -EBUSY;
} else { } else {
err = ceph_sync_setxattr(inode, name, value, size, flags); err = ceph_sync_setxattr(inode, name, value, size, flags);
if (err >= 0 && check_realm) {
/* check if snaprealm was created for quota inode */
spin_lock(&ci->i_ceph_lock);
if ((ci->i_max_files || ci->i_max_bytes) &&
!(ci->i_snap_realm &&
ci->i_snap_realm->ino == ci->i_vino.ino))
err = -EOPNOTSUPP;
spin_unlock(&ci->i_ceph_lock);
}
} }
out: out:
ceph_free_cap_flush(prealloc_cf); ceph_free_cap_flush(prealloc_cf);
......
...@@ -2569,6 +2569,11 @@ static int try_write(struct ceph_connection *con) ...@@ -2569,6 +2569,11 @@ static int try_write(struct ceph_connection *con)
int ret = 1; int ret = 1;
dout("try_write start %p state %lu\n", con, con->state); dout("try_write start %p state %lu\n", con, con->state);
if (con->state != CON_STATE_PREOPEN &&
con->state != CON_STATE_CONNECTING &&
con->state != CON_STATE_NEGOTIATING &&
con->state != CON_STATE_OPEN)
return 0;
more: more:
dout("try_write out_kvec_bytes %d\n", con->out_kvec_bytes); dout("try_write out_kvec_bytes %d\n", con->out_kvec_bytes);
...@@ -2594,6 +2599,8 @@ static int try_write(struct ceph_connection *con) ...@@ -2594,6 +2599,8 @@ static int try_write(struct ceph_connection *con)
} }
more_kvec: more_kvec:
BUG_ON(!con->sock);
/* kvec data queued? */ /* kvec data queued? */
if (con->out_kvec_left) { if (con->out_kvec_left) {
ret = write_partial_kvec(con); ret = write_partial_kvec(con);
......
...@@ -209,6 +209,14 @@ static void reopen_session(struct ceph_mon_client *monc) ...@@ -209,6 +209,14 @@ static void reopen_session(struct ceph_mon_client *monc)
__open_session(monc); __open_session(monc);
} }
static void un_backoff(struct ceph_mon_client *monc)
{
monc->hunt_mult /= 2; /* reduce by 50% */
if (monc->hunt_mult < 1)
monc->hunt_mult = 1;
dout("%s hunt_mult now %d\n", __func__, monc->hunt_mult);
}
/* /*
* Reschedule delayed work timer. * Reschedule delayed work timer.
*/ */
...@@ -963,6 +971,7 @@ static void delayed_work(struct work_struct *work) ...@@ -963,6 +971,7 @@ static void delayed_work(struct work_struct *work)
if (!monc->hunting) { if (!monc->hunting) {
ceph_con_keepalive(&monc->con); ceph_con_keepalive(&monc->con);
__validate_auth(monc); __validate_auth(monc);
un_backoff(monc);
} }
if (is_auth && if (is_auth &&
...@@ -1123,9 +1132,8 @@ static void finish_hunting(struct ceph_mon_client *monc) ...@@ -1123,9 +1132,8 @@ static void finish_hunting(struct ceph_mon_client *monc)
dout("%s found mon%d\n", __func__, monc->cur_mon); dout("%s found mon%d\n", __func__, monc->cur_mon);
monc->hunting = false; monc->hunting = false;
monc->had_a_connection = true; monc->had_a_connection = true;
monc->hunt_mult /= 2; /* reduce by 50% */ un_backoff(monc);
if (monc->hunt_mult < 1) __schedule_delayed(monc);
monc->hunt_mult = 1;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment