Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/sage/ceph-client

Pull Ceph updates from Sage Weil:
 "There is the long-awaited discard support for RBD (Guangliang Zhao,
  Josh Durgin), a pile of RBD bug fixes that didn't belong in late -rc's
  (Ilya Dryomov, Li RongQing), a pile of fs/ceph bug fixes and
  performance and debugging improvements (Yan, Zheng, John Spray), and a
  smattering of cleanups (Chao Yu, Fabian Frederick, Joe Perches)"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client: (40 commits)
  ceph: fix divide-by-zero in __validate_layout()
  rbd: rbd workqueues need a resque worker
  libceph: ceph-msgr workqueue needs a resque worker
  ceph: fix bool assignments
  libceph: separate multiple ops with commas in debugfs output
  libceph: sync osd op definitions in rados.h
  libceph: remove redundant declaration
  ceph: additional debugfs output
  ceph: export ceph_session_state_name function
  ceph: include the initial ACL in create/mkdir/mknod MDS requests
  ceph: use pagelist to present MDS request data
  libceph: reference counting pagelist
  ceph: fix llistxattr on symlink
  ceph: send client metadata to MDS
  ceph: remove redundant code for max file size verification
  ceph: remove redundant io_iter_advance()
  ceph: move ceph_find_inode() outside the s_mutex
  ceph: request xattrs if xattr_version is zero
  rbd: set the remaining discard properties to enable support
  rbd: use helpers to handle discard for layered images correctly
  ...
  • Loading branch information
torvalds committed Oct 15, 2014
2 parents ce9d7f7 + 0bc6228 commit 6b04908
Show file tree
Hide file tree
Showing 25 changed files with 948 additions and 623 deletions.
396 changes: 276 additions & 120 deletions drivers/block/rbd.c

Large diffs are not rendered by default.

125 changes: 99 additions & 26 deletions fs/ceph/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,36 +169,109 @@ int ceph_set_acl(struct inode *inode, struct posix_acl *acl, int type)
return ret;
}

int ceph_init_acl(struct dentry *dentry, struct inode *inode, struct inode *dir)
int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
struct ceph_acls_info *info)
{
struct posix_acl *default_acl, *acl;
umode_t new_mode = inode->i_mode;
int error;

error = posix_acl_create(dir, &new_mode, &default_acl, &acl);
if (error)
return error;

if (!default_acl && !acl) {
cache_no_acl(inode);
if (new_mode != inode->i_mode) {
struct iattr newattrs = {
.ia_mode = new_mode,
.ia_valid = ATTR_MODE,
};
error = ceph_setattr(dentry, &newattrs);
struct posix_acl *acl, *default_acl;
size_t val_size1 = 0, val_size2 = 0;
struct ceph_pagelist *pagelist = NULL;
void *tmp_buf = NULL;
int err;

err = posix_acl_create(dir, mode, &default_acl, &acl);
if (err)
return err;

if (acl) {
int ret = posix_acl_equiv_mode(acl, mode);
if (ret < 0)
goto out_err;
if (ret == 0) {
posix_acl_release(acl);
acl = NULL;
}
return error;
}

if (default_acl) {
error = ceph_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
posix_acl_release(default_acl);
}
if (!default_acl && !acl)
return 0;

if (acl)
val_size1 = posix_acl_xattr_size(acl->a_count);
if (default_acl)
val_size2 = posix_acl_xattr_size(default_acl->a_count);

err = -ENOMEM;
tmp_buf = kmalloc(max(val_size1, val_size2), GFP_NOFS);
if (!tmp_buf)
goto out_err;
pagelist = kmalloc(sizeof(struct ceph_pagelist), GFP_NOFS);
if (!pagelist)
goto out_err;
ceph_pagelist_init(pagelist);

err = ceph_pagelist_reserve(pagelist, PAGE_SIZE);
if (err)
goto out_err;

ceph_pagelist_encode_32(pagelist, acl && default_acl ? 2 : 1);

if (acl) {
if (!error)
error = ceph_set_acl(inode, acl, ACL_TYPE_ACCESS);
posix_acl_release(acl);
size_t len = strlen(POSIX_ACL_XATTR_ACCESS);
err = ceph_pagelist_reserve(pagelist, len + val_size1 + 8);
if (err)
goto out_err;
ceph_pagelist_encode_string(pagelist, POSIX_ACL_XATTR_ACCESS,
len);
err = posix_acl_to_xattr(&init_user_ns, acl,
tmp_buf, val_size1);
if (err < 0)
goto out_err;
ceph_pagelist_encode_32(pagelist, val_size1);
ceph_pagelist_append(pagelist, tmp_buf, val_size1);
}
return error;
if (default_acl) {
size_t len = strlen(POSIX_ACL_XATTR_DEFAULT);
err = ceph_pagelist_reserve(pagelist, len + val_size2 + 8);
if (err)
goto out_err;
err = ceph_pagelist_encode_string(pagelist,
POSIX_ACL_XATTR_DEFAULT, len);
err = posix_acl_to_xattr(&init_user_ns, default_acl,
tmp_buf, val_size2);
if (err < 0)
goto out_err;
ceph_pagelist_encode_32(pagelist, val_size2);
ceph_pagelist_append(pagelist, tmp_buf, val_size2);
}

kfree(tmp_buf);

info->acl = acl;
info->default_acl = default_acl;
info->pagelist = pagelist;
return 0;

out_err:
posix_acl_release(acl);
posix_acl_release(default_acl);
kfree(tmp_buf);
if (pagelist)
ceph_pagelist_release(pagelist);
return err;
}

void ceph_init_inode_acls(struct inode* inode, struct ceph_acls_info *info)
{
if (!inode)
return;
ceph_set_cached_acl(inode, ACL_TYPE_ACCESS, info->acl);
ceph_set_cached_acl(inode, ACL_TYPE_DEFAULT, info->default_acl);
}

void ceph_release_acls_info(struct ceph_acls_info *info)
{
posix_acl_release(info->acl);
posix_acl_release(info->default_acl);
if (info->pagelist)
ceph_pagelist_release(info->pagelist);
}
9 changes: 0 additions & 9 deletions fs/ceph/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1076,12 +1076,6 @@ static int ceph_update_writeable_page(struct file *file,
/* past end of file? */
i_size = inode->i_size; /* caller holds i_mutex */

if (i_size + len > inode->i_sb->s_maxbytes) {
/* file is too big */
r = -EINVAL;
goto fail;
}

if (page_off >= i_size ||
(pos_in_page == 0 && (pos+len) >= i_size &&
end_in_page - pos_in_page != PAGE_CACHE_SIZE)) {
Expand All @@ -1099,9 +1093,6 @@ static int ceph_update_writeable_page(struct file *file,
if (r < 0)
goto fail_nosnap;
goto retry_locked;

fail:
up_read(&mdsc->snap_rwsem);
fail_nosnap:
unlock_page(page);
return r;
Expand Down
37 changes: 19 additions & 18 deletions fs/ceph/caps.c
Original file line number Diff line number Diff line change
Expand Up @@ -2397,12 +2397,12 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
u64 max_size = le64_to_cpu(grant->max_size);
struct timespec mtime, atime, ctime;
int check_caps = 0;
bool wake = 0;
bool writeback = 0;
bool queue_trunc = 0;
bool queue_invalidate = 0;
bool queue_revalidate = 0;
bool deleted_inode = 0;
bool wake = false;
bool writeback = false;
bool queue_trunc = false;
bool queue_invalidate = false;
bool queue_revalidate = false;
bool deleted_inode = false;

dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n",
inode, cap, mds, seq, ceph_cap_string(newcaps));
Expand Down Expand Up @@ -2437,7 +2437,7 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
/* there were locked pages.. invalidate later
in a separate thread. */
if (ci->i_rdcache_revoking != ci->i_rdcache_gen) {
queue_invalidate = 1;
queue_invalidate = true;
ci->i_rdcache_revoking = ci->i_rdcache_gen;
}
}
Expand Down Expand Up @@ -2466,7 +2466,7 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
set_nlink(inode, le32_to_cpu(grant->nlink));
if (inode->i_nlink == 0 &&
(newcaps & (CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL)))
deleted_inode = 1;
deleted_inode = true;
}

if ((issued & CEPH_CAP_XATTR_EXCL) == 0 && grant->xattr_len) {
Expand All @@ -2487,7 +2487,7 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
/* Do we need to revalidate our fscache cookie. Don't bother on the
* first cache cap as we already validate at cookie creation time. */
if ((issued & CEPH_CAP_FILE_CACHE) && ci->i_rdcache_gen > 1)
queue_revalidate = 1;
queue_revalidate = true;

if (newcaps & CEPH_CAP_ANY_RD) {
/* ctime/mtime/atime? */
Expand Down Expand Up @@ -2516,7 +2516,7 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
ci->i_wanted_max_size = 0; /* reset */
ci->i_requested_max_size = 0;
}
wake = 1;
wake = true;
}
}

Expand Down Expand Up @@ -2546,7 +2546,7 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
ceph_cap_string(newcaps),
ceph_cap_string(revoking));
if (revoking & used & CEPH_CAP_FILE_BUFFER)
writeback = 1; /* initiate writeback; will delay ack */
writeback = true; /* initiate writeback; will delay ack */
else if (revoking == CEPH_CAP_FILE_CACHE &&
(newcaps & CEPH_CAP_FILE_LAZYIO) == 0 &&
queue_invalidate)
Expand All @@ -2572,7 +2572,7 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
cap->implemented |= newcaps; /* add bits only, to
* avoid stepping on a
* pending revocation */
wake = 1;
wake = true;
}
BUG_ON(cap->issued & ~cap->implemented);

Expand All @@ -2586,7 +2586,7 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
kick_flushing_inode_caps(mdsc, session, inode);
up_read(&mdsc->snap_rwsem);
if (newcaps & ~issued)
wake = 1;
wake = true;
}

if (queue_trunc) {
Expand Down Expand Up @@ -3045,6 +3045,12 @@ void ceph_handle_caps(struct ceph_mds_session *session,
}
}

/* lookup ino */
inode = ceph_find_inode(sb, vino);
ci = ceph_inode(inode);
dout(" op %s ino %llx.%llx inode %p\n", ceph_cap_op_name(op), vino.ino,
vino.snap, inode);

mutex_lock(&session->s_mutex);
session->s_seq++;
dout(" mds%d seq %lld cap seq %u\n", session->s_mds, session->s_seq,
Expand All @@ -3053,11 +3059,6 @@ void ceph_handle_caps(struct ceph_mds_session *session,
if (op == CEPH_CAP_OP_IMPORT)
ceph_add_cap_releases(mdsc, session);

/* lookup ino */
inode = ceph_find_inode(sb, vino);
ci = ceph_inode(inode);
dout(" op %s ino %llx.%llx inode %p\n", ceph_cap_op_name(op), vino.ino,
vino.snap, inode);
if (!inode) {
dout(" i don't have ino %llx\n", vino.ino);

Expand Down
46 changes: 46 additions & 0 deletions fs/ceph/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,47 @@ static int dentry_lru_show(struct seq_file *s, void *ptr)
return 0;
}

static int mds_sessions_show(struct seq_file *s, void *ptr)
{
struct ceph_fs_client *fsc = s->private;
struct ceph_mds_client *mdsc = fsc->mdsc;
struct ceph_auth_client *ac = fsc->client->monc.auth;
struct ceph_options *opt = fsc->client->options;
int mds = -1;

mutex_lock(&mdsc->mutex);

/* The 'num' portion of an 'entity name' */
seq_printf(s, "global_id %llu\n", ac->global_id);

/* The -o name mount argument */
seq_printf(s, "name \"%s\"\n", opt->name ? opt->name : "");

/* The list of MDS session rank+state */
for (mds = 0; mds < mdsc->max_sessions; mds++) {
struct ceph_mds_session *session =
__ceph_lookup_mds_session(mdsc, mds);
if (!session) {
continue;
}
mutex_unlock(&mdsc->mutex);
seq_printf(s, "mds.%d %s\n",
session->s_mds,
ceph_session_state_name(session->s_state));

ceph_put_mds_session(session);
mutex_lock(&mdsc->mutex);
}
mutex_unlock(&mdsc->mutex);

return 0;
}

CEPH_DEFINE_SHOW_FUNC(mdsmap_show)
CEPH_DEFINE_SHOW_FUNC(mdsc_show)
CEPH_DEFINE_SHOW_FUNC(caps_show)
CEPH_DEFINE_SHOW_FUNC(dentry_lru_show)
CEPH_DEFINE_SHOW_FUNC(mds_sessions_show)


/*
Expand Down Expand Up @@ -193,6 +230,7 @@ void ceph_fs_debugfs_cleanup(struct ceph_fs_client *fsc)
debugfs_remove(fsc->debugfs_bdi);
debugfs_remove(fsc->debugfs_congestion_kb);
debugfs_remove(fsc->debugfs_mdsmap);
debugfs_remove(fsc->debugfs_mds_sessions);
debugfs_remove(fsc->debugfs_caps);
debugfs_remove(fsc->debugfs_mdsc);
debugfs_remove(fsc->debugfs_dentry_lru);
Expand Down Expand Up @@ -231,6 +269,14 @@ int ceph_fs_debugfs_init(struct ceph_fs_client *fsc)
if (!fsc->debugfs_mdsmap)
goto out;

fsc->debugfs_mds_sessions = debugfs_create_file("mds_sessions",
0600,
fsc->client->debugfs_dir,
fsc,
&mds_sessions_show_fops);
if (!fsc->debugfs_mds_sessions)
goto out;

fsc->debugfs_mdsc = debugfs_create_file("mdsc",
0600,
fsc->client->debugfs_dir,
Expand Down
Loading

0 comments on commit 6b04908

Please sign in to comment.