Rados pool namespace support
cover Rados pool namespace support
This series adds pool namespae support for libceph and cephfs. I also pushed the code to https://github.com/ceph/ceph-client/tree/wip-fs-filelayout2.
Yan, Zheng (6):
libceph: define new ceph_file_layout structure
libceph: introduce pool namespace cache
libceph: rados pool namesapce support
libceph: make sure redirect does not change namespace
libceph: calculate request message size according to namespace
ceph: rados pool namesapce support
drivers/block/rbd.c | 17 ++--- fs/ceph/addr.c | 78 +++++++++++++++++----- fs/ceph/caps.c | 47 +++++++++---- fs/ceph/file.c | 15 +++-- fs/ceph/inode.c | 15 ++++- fs/ceph/ioctl.c | 22 +++--- fs/ceph/mds_client.c | 11 +++ fs/ceph/mds_client.h | 6 +- fs/ceph/xattr.c | 90 ++++++++++++++++--------- include/linux/ceph/ceph_features.h | 1 + include/linux/ceph/ceph_fs.h | 53 +++++++-------- include/linux/ceph/libceph.h | 1 + include/linux/ceph/osd_client.h | 2 + include/linux/ceph/osdmap.h | 1 + include/linux/ceph/pool_ns.h | 47 +++++++++++++ net/ceph/Makefile | 2 +- net/ceph/ceph_common.c | 2 + net/ceph/ceph_fs.c | 33 ++++++++- net/ceph/osd_client.c | 73 +++++++++++++++----- net/ceph/osdmap.c | 39 ++++++++--- net/ceph/pool_ns.c | 133 +++++++++++++++++++++++++++++++++++++ 21 files changed, 539 insertions(+), 149 deletions(-) create mode 100644 include/linux/ceph/pool_ns.h create mode 100644 net/ceph/pool_ns.c
Signature · 1 line
2.5.0
PATCH 1/6 libceph: define new ceph_file_layout structure
Define new ceph_file_layout structure and rename old ceph_file_layout to ceph_file_layout_legacy. This is preparation for adding namespace to ceph_file_layout structure.
--- drivers/block/rbd.c | 12 +++++------ fs/ceph/addr.c | 18 ++++++++-------- fs/ceph/caps.c | 6 +++++- fs/ceph/file.c | 6 +++--- fs/ceph/inode.c | 5 +++-- fs/ceph/ioctl.c | 22 +++++++++---------- fs/ceph/mds_client.h | 2 +- fs/ceph/xattr.c | 28 ++++++++++--------------- include/linux/ceph/ceph_fs.h | 50 +++++++++++++++++++------------------------- net/ceph/ceph_fs.c | 30 +++++++++++++++++++++++--- net/ceph/osd_client.c | 4 ++-- net/ceph/osdmap.c | 6 +++--- 12 files changed, 102 insertions(+), 87 deletions(-)
drivers/block/rbd.c +6 -6
@@ -1967,7 +1967,7 @@ static struct ceph_osd_request *rbd_osd_req_create( osd_req->r_callback = rbd_osd_req_callback; osd_req->r_priv = obj_request; - osd_req->r_base_oloc.pool =ceph_file_layout_pg_pool (rbd_dev->layout); + osd_req->r_base_oloc.pool = rbd_dev->layout.pool_id;ceph_oid_set_name (&osd_req->r_base_oid, obj_request->object_name);return osd_req;
@@ -2012,7 +2012,7 @@ rbd_osd_req_create_copyup(struct rbd_obj_request *obj_request) osd_req->r_callback = rbd_osd_req_callback; osd_req->r_priv = obj_request; - osd_req->r_base_oloc.pool =ceph_file_layout_pg_pool (rbd_dev->layout); + osd_req->r_base_oloc.pool = rbd_dev->layout.pool_id;ceph_oid_set_name (&osd_req->r_base_oid, obj_request->object_name);return osd_req;
@@ -4084,10 +4084,10 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,/* Initialize the layout used for all rbd requests */ - rbd_dev->layout.fl_stripe_unit =cpu_to_le32 (1 <<RBD_MAX_OBJ_ORDER ); - rbd_dev->layout.fl_stripe_count =cpu_to_le32 (1 ); - rbd_dev->layout.fl_object_size =cpu_to_le32 (1 <<RBD_MAX_OBJ_ORDER ); - rbd_dev->layout.fl_pg_pool =cpu_to_le32 ((u32 ) spec->pool_id); + rbd_dev->layout.stripe_unit =1 <<RBD_MAX_OBJ_ORDER ; + rbd_dev->layout.stripe_count =1 ; + rbd_dev->layout.object_size =1 <<RBD_MAX_OBJ_ORDER ; + rbd_dev->layout.pool_id = spec->pool_id;/* * If this is a mapping rbd_dev (as opposed to a parent one),
fs/ceph/addr.c +9 -9
@@ -1701,7 +1701,7 @@ enum { POOL_WRITE = 2, }; -static int __ceph_pool_perm_get (struct ceph_inode_info *ci,u32 pool) +static int __ceph_pool_perm_get (struct ceph_inode_info *ci,s64 pool) {struct ceph_fs_client *fsc =ceph_inode_to_client (&ci->vfs_inode);struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -1728,7 +1728,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, u32 pool)if (*p) goto out; -dout ("__ceph_pool_perm_get pool %u no perm cached\n" , pool); +dout ("__ceph_pool_perm_get pool %lld no perm cached\n" , pool);down_write (&mdsc->pool_perm_rwsem); parent =NULL ;
@@ -1833,13 +1833,13 @@ out_unlock: out:if (!err) err = have; -dout ("__ceph_pool_perm_get pool %u result = %d\n" , pool, err); +dout ("__ceph_pool_perm_get pool %lld result = %d\n" , pool, err);return err; }int ceph_pool_perm_check (struct ceph_inode_info *ci,int need) { -u32 pool; +s64 pool;int ret, flags; if (ceph_test_mount_opt(ceph_inode_to_client(&ci->vfs_inode),
@@ -1848,17 +1848,17 @@ int ceph_pool_perm_check(struct ceph_inode_info *ci, int need)spin_lock (&ci->i_ceph_lock); flags = ci->i_ceph_flags; - pool =ceph_file_layout_pg_pool (ci->i_layout); + pool = ci->i_layout.pool_id;spin_unlock (&ci->i_ceph_lock); check:if (flags &CEPH_I_POOL_PERM ) {if ((need &CEPH_CAP_FILE_RD ) && !(flags &CEPH_I_POOL_RD )) { -dout ("ceph_pool_perm_check pool %u no read perm\n" , +dout ("ceph_pool_perm_check pool %lld no read perm\n" , pool);return -EPERM ; }if ((need &CEPH_CAP_FILE_WR ) && !(flags &CEPH_I_POOL_WR )) { -dout ("ceph_pool_perm_check pool %u no write perm\n" , +dout ("ceph_pool_perm_check pool %lld no write perm\n" , pool);return -EPERM ; }
@@ -1876,10 +1876,10 @@ check: flags |=CEPH_I_POOL_WR ;spin_lock (&ci->i_ceph_lock); -if (pool ==ceph_file_layout_pg_pool (ci->i_layout)) { +if (pool == ci->i_layout.pool_id) { ci->i_ceph_flags = flags; }else { - pool =ceph_file_layout_pg_pool (ci->i_layout); + pool = ci->i_layout.pool_id; flags = ci->i_ceph_flags; }spin_unlock (&ci->i_ceph_lock);
fs/ceph/caps.c +5 -1
@@ -2875,7 +2875,11 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,if (newcaps & (CEPH_CAP_ANY_FILE_RD |CEPH_CAP_ANY_FILE_WR )) {/* file layout may have changed */ - ci->i_layout = grant->layout; +s64 old_pool = ci->i_layout.pool_id; +ceph_file_layout_from_legacy (&ci->i_layout, &grant->layout); +if (ci->i_layout.pool_id != old_pool) + ci->i_ceph_flags &= ~CEPH_I_POOL_PERM ; +/* size/truncate_seq? */ queue_trunc = ceph_fill_file_size(inode, issued, le32_to_cpu(grant->truncate_seq),
fs/ceph/file.c +3 -3
@@ -1537,9 +1537,9 @@ static int ceph_zero_objects(struct inode *inode, loff_t offset, loff_t length) {int ret =0 ;struct ceph_inode_info *ci =ceph_inode (inode); -s32 stripe_unit =ceph_file_layout_su (ci->i_layout); -s32 stripe_count =ceph_file_layout_stripe_count (ci->i_layout); -s32 object_size =ceph_file_layout_object_size (ci->i_layout); +s32 stripe_unit = ci->i_layout.stripe_unit; +s32 stripe_count = ci->i_layout.stripe_count; +s32 object_size = ci->i_layout.object_size;u64 object_set_size = object_size * stripe_count;u64 nearly, t;
fs/ceph/inode.c +3 -2
@@ -753,9 +753,10 @@ static int fill_inode(struct inode *inode, struct page *locked_page,if (new_version || (new_issued & (CEPH_CAP_ANY_FILE_RD |CEPH_CAP_ANY_FILE_WR ))) { -if (ci->i_layout.fl_pg_pool != info->layout.fl_pg_pool) +s64 old_pool = ci->i_layout.pool_id; +ceph_file_layout_from_legacy (&ci->i_layout, &info->layout); +if (ci->i_layout.pool_id != old_pool) ci->i_ceph_flags &= ~CEPH_I_POOL_PERM ; - ci->i_layout = info->layout; queue_trunc = ceph_fill_file_size(inode, issued, le32_to_cpu(info->truncate_seq),
fs/ceph/ioctl.c +11 -11
@@ -21,10 +21,10 @@ static long ceph_ioctl_get_layout(struct file *file, void __user *arg) err =ceph_do_getattr (file_inode (file),CEPH_STAT_CAP_LAYOUT , false);if (!err) { - l.stripe_unit =ceph_file_layout_su (ci->i_layout); - l.stripe_count =ceph_file_layout_stripe_count (ci->i_layout); - l.object_size =ceph_file_layout_object_size (ci->i_layout); - l.data_pool =le32_to_cpu (ci->i_layout.fl_pg_pool); + l.stripe_unit = ci->i_layout.stripe_unit; + l.stripe_count = ci->i_layout.stripe_count; + l.object_size = ci->i_layout.object_size; + l.data_pool = ci->i_layout.pool_id; l.preferred_osd = (s32)-1 ;if (copy_to_user (arg, &l,sizeof (l)))return -EFAULT ;
@@ -82,19 +82,19 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)if (l.stripe_count) nl.stripe_count = l.stripe_count;else - nl.stripe_count =ceph_file_layout_stripe_count (ci->i_layout); + nl.stripe_count = ci->i_layout.stripe_count;if (l.stripe_unit) nl.stripe_unit = l.stripe_unit;else - nl.stripe_unit =ceph_file_layout_su (ci->i_layout); + nl.stripe_unit = ci->i_layout.stripe_unit;if (l.object_size) nl.object_size = l.object_size;else - nl.object_size =ceph_file_layout_object_size (ci->i_layout); + nl.object_size = ci->i_layout.object_size;if (l.data_pool) nl.data_pool = l.data_pool;else - nl.data_pool =ceph_file_layout_pg_pool (ci->i_layout); + nl.data_pool = ci->i_layout.pool_id;/* this is obsolete, and always -1 */ nl.preferred_osd =le64_to_cpu (-1 );
@@ -202,8 +202,8 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)return -EIO ; } dl.file_offset -= dl.object_offset; - dl.object_size =ceph_file_layout_object_size (ci->i_layout); - dl.block_size =ceph_file_layout_su (ci->i_layout); + dl.object_size = ci->i_layout.object_size; + dl.block_size = ci->i_layout.stripe_unit;/* block_offset = object_offset % block_size */ tmp = dl.object_offset;
@@ -212,7 +212,7 @@ static long ceph_ioctl_get_dataloc(struct file *file, void __user *arg)snprintf (dl.object_name,sizeof (dl.object_name),"%llx.%08llx" ,ceph_ino (inode), dl.object_no); - oloc.pool =ceph_file_layout_pg_pool (ci->i_layout); + oloc.pool = ci->i_layout.pool_id;ceph_oid_set_name (&oid, dl.object_name); r =ceph_oloc_oid_to_pg (osdc->osdmap, &oloc, &oid, &pgid);
fs/ceph/mds_client.h +1 -1
@@ -267,8 +267,8 @@ struct ceph_mds_request {struct ceph_pool_perm {struct rb_node node; -u32 pool;int perm; +s64 pool; };/*
fs/ceph/xattr.c +11 -17
@@ -70,7 +70,7 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,int ret;struct ceph_fs_client *fsc =ceph_sb_to_client (ci->vfs_inode.i_sb);struct ceph_osd_client *osdc = &fsc->client->osdc; -s64 pool =ceph_file_layout_pg_pool (ci->i_layout); +s64 pool = ci->i_layout.pool_id;const char *pool_name;char buf[128 ];
@@ -80,10 +80,9 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,if (pool_name) {size_t len =strlen (pool_name); ret =snprintf (buf,sizeof (buf), -"stripe_unit=%lld stripe_count=%lld object_size=%lld pool=" , - (unsigned long long )ceph_file_layout_su (ci->i_layout), - (unsigned long long )ceph_file_layout_stripe_count (ci->i_layout), - (unsigned long long )ceph_file_layout_object_size (ci->i_layout)); +"stripe_unit=%u stripe_count=%u object_size=%u pool=" , + ci->i_layout.stripe_unit, ci->i_layout.stripe_count, + ci->i_layout.object_size);if (!size) { ret += len; }else if (ret + len > size) {
@@ -95,11 +94,9 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val, } }else { ret =snprintf (buf,sizeof (buf), -"stripe_unit=%lld stripe_count=%lld object_size=%lld pool=%lld" , - (unsigned long long )ceph_file_layout_su (ci->i_layout), - (unsigned long long )ceph_file_layout_stripe_count (ci->i_layout), - (unsigned long long )ceph_file_layout_object_size (ci->i_layout), - (unsigned long long )pool); +"stripe_unit=%u stripe_count=%u object_size=%u pool=%lld" , + ci->i_layout.stripe_unit, ci->i_layout.stripe_count, + ci->i_layout.object_size, (unsigned long long )pool);if (size) {if (ret <= size)memcpy (val, buf, ret);
@@ -114,22 +111,19 @@ static size_t ceph_vxattrcb_layout(struct ceph_inode_info *ci, char *val,static size_t ceph_vxattrcb_layout_stripe_unit (struct ceph_inode_info *ci,char *val,size_t size) { -return snprintf (val, size,"%lld" , - (unsigned long long )ceph_file_layout_su (ci->i_layout)); +return snprintf (val, size,"%u" , ci->i_layout.stripe_unit); }static size_t ceph_vxattrcb_layout_stripe_count (struct ceph_inode_info *ci,char *val,size_t size) { -return snprintf (val, size,"%lld" , - (unsigned long long )ceph_file_layout_stripe_count (ci->i_layout)); +return snprintf (val, size,"%u" , ci->i_layout.stripe_count); }static size_t ceph_vxattrcb_layout_object_size (struct ceph_inode_info *ci,char *val,size_t size) { -return snprintf (val, size,"%lld" , - (unsigned long long )ceph_file_layout_object_size (ci->i_layout)); +return snprintf (val, size,"%u" , ci->i_layout.object_size); } static size_t ceph_vxattrcb_layout_pool(struct ceph_inode_info *ci,
@@ -138,7 +132,7 @@ static size_t ceph_vxattrcb_layout_pool(struct ceph_inode_info *ci,int ret;struct ceph_fs_client *fsc =ceph_sb_to_client (ci->vfs_inode.i_sb);struct ceph_osd_client *osdc = &fsc->client->osdc; -s64 pool =ceph_file_layout_pg_pool (ci->i_layout); +s64 pool = ci->i_layout.pool_id;const char *pool_name;down_read (&osdc->map_sem);
include/linux/ceph/ceph_fs.h +21 -29
84 lines not on this page · raw message
net/ceph/ceph_fs.c +27 -3
@@ -9,9 +9,9 @@*/ int ceph_file_layout_is_valid (const struct ceph_file_layout *layout) { -__u32 su =le32_to_cpu (layout->fl_stripe_unit); -__u32 sc =le32_to_cpu (layout->fl_stripe_count); -__u32 os =le32_to_cpu (layout->fl_object_size); +__u32 su = layout->stripe_unit; +__u32 sc = layout->stripe_count; +__u32 os = layout->object_size;/* stripe unit, object size must be non-zero, 64k increment */ if (!su || (su & (CEPH_MIN_STRIPE_UNIT -1 )))
@@ -27,6 +27,30 @@ int ceph_file_layout_is_valid(const struct ceph_file_layout *layout)return 1 ; } +void ceph_file_layout_from_legacy (struct ceph_file_layout *fl, +struct ceph_file_layout_legacy *legacy) +{ + fl->stripe_unit =le32_to_cpu (legacy->fl_stripe_unit); + fl->stripe_count =le32_to_cpu (legacy->fl_stripe_count); + fl->object_size =le32_to_cpu (legacy->fl_object_size); + fl->pool_id =le64_to_cpu (legacy->fl_pg_pool); +if (fl->pool_id ==0 ) + fl->pool_id =-1 ; +} +EXPORT_SYMBOL (ceph_file_layout_from_legacy); + +void ceph_file_layout_to_legacy (struct ceph_file_layout *fl, +struct ceph_file_layout_legacy *legacy) +{ + legacy->fl_stripe_unit =cpu_to_le32 (fl->stripe_unit); + legacy->fl_stripe_count =cpu_to_le32 (fl->stripe_count); + legacy->fl_object_size =cpu_to_le32 (fl->object_size); +if (fl->pool_id >=0 ) + legacy->fl_pg_pool =cpu_to_le64 (fl->pool_id); +else + legacy->fl_pg_pool =0 ; +} +EXPORT_SYMBOL (ceph_file_layout_to_legacy);int ceph_flags_to_mode (int flags) {
net/ceph/osd_client.c +2 -2
@@ -848,7 +848,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,if (opcode ==CEPH_OSD_OP_CREATE || opcode ==CEPH_OSD_OP_DELETE ) {osd_req_op_init (req, which, opcode,0 ); }else { -u32 object_size =le32_to_cpu (layout->fl_object_size); +u32 object_size = layout->object_size;u32 object_base = off - objoff;if (!(truncate_seq ==1 && truncate_size ==-1ULL )) {if (truncate_size <= object_base) {
@@ -863,7 +863,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, truncate_size, truncate_seq); } - req->r_base_oloc.pool =ceph_file_layout_pg_pool (*layout); + req->r_base_oloc.pool = layout->pool_id;snprintf (req->r_base_oid.name,sizeof (req->r_base_oid.name),"%llx.%08llx" , vino.ino, objnum);
net/ceph/osdmap.c +3 -3
@@ -1397,9 +1397,9 @@ int ceph_calc_file_object_mapping(struct ceph_file_layout *layout, u64 *ono, u64 *oxoff, u64 *oxlen) { -u32 osize =le32_to_cpu (layout->fl_object_size); -u32 su =le32_to_cpu (layout->fl_stripe_unit); -u32 sc =le32_to_cpu (layout->fl_stripe_count); +u32 osize = layout->object_size; +u32 su = layout->stripe_unit; +u32 sc = layout->stripe_count;u32 bl, stripeno, stripepos, objsetno;u32 su_per_object;u64 t, su_offset;
Signature · 1 line
2.5.0
PATCH 2/6 libceph: introduce pool namespace cache
In reply to Yan, ZhengThis allows namespace data structure to be shared by cephfs inodes with same layout.
--- include/linux/ceph/libceph.h | 1 + include/linux/ceph/pool_ns.h | 47 +++++++++++++++ net/ceph/Makefile | 2 +- net/ceph/ceph_common.c | 2 + net/ceph/pool_ns.c | 133 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 include/linux/ceph/pool_ns.h create mode 100644 net/ceph/pool_ns.c
include/linux/ceph/libceph.h +1 -0
@@ -21,6 +21,7 @@#include <linux/ceph/mon_client.h> #include <linux/ceph/osd_client.h> #include <linux/ceph/ceph_fs.h> +#include <linux/ceph/pool_ns.h> /* * mount options
include/linux/ceph/pool_ns.h new file +47 -0
47 lines not on this page · raw message
net/ceph/Makefile +1 -1
@@ -11,5 +11,5 @@ libceph-y := ceph_common.o messenger.o msgpool.o buffer.o pagelist.o \ crypto.o armor.o \ auth_x.o \ ceph_fs.o ceph_strings.o ceph_hash.o \ - pagevec.o snapshot.o + pagevec.o snapshot.o pool_ns.o
net/ceph/ceph_common.c +2 -0
@@ -25,6 +25,7 @@#include <linux/ceph/decode.h> #include <linux/ceph/mon_client.h> #include <linux/ceph/auth.h> +#include <linux/ceph/pool_ns.h> #include "crypto.h"
@@ -751,6 +752,7 @@ static void __exit exit_ceph_lib(void)ceph_msgr_exit ();ceph_crypto_shutdown ();ceph_debugfs_cleanup (); +ceph_pool_ns_cleanup (); }module_init (init_ceph_lib);
net/ceph/pool_ns.c new file +133 -0
133 lines not on this page · raw message
Signature · 1 line
2.5.0
Re: [PATCH 2/6] libceph: introduce pool namespace cache
Quoted 4 lines · Zheng
This allows namespace data structure to be shared by cephfs inodes with same layout.
Signed-off-by Yan, Zheng <[email protected]>
Quoted 9 lines
--- include/linux/ceph/libceph.h | 1 + include/linux/ceph/pool_ns.h | 47 +++++++++++++++ net/ceph/Makefile | 2 +- net/ceph/ceph_common.c | 2 + net/ceph/pool_ns.c | 133 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 include/linux/ceph/pool_ns.h create mode 100644 net/ceph/pool_ns.c
Would it make sense to rename this string_table and make it generic? There's nothing ceph (or pool ns) specific about it that I can see.
sage
Quoted 245 lines
include/linux/ceph/libceph.h +1
-0@@ -21,6 +21,7 @@#include <linux/ceph/mon_client.h> #include <linux/ceph/osd_client.h> #include <linux/ceph/ceph_fs.h> +#include <linux/ceph/pool_ns.h> /* * mount options include/linux/ceph/pool_ns.h new file +47
-0@@ -0,0 +1,47 @@ +#ifndef _FS_CEPH_POOL_NS_H +#define _FS_CEPH_POOL_NS_H + +#include <linux/types.h> +#include <linux/kref.h> +#include <linux/rbtree.h> +#include <linux/rcupdate.h> + +struct ceph_pool_ns { +struct kref kref; +union { +struct rb_node node; +struct rcu_head rcu; + }; +size_t name_len; +char name[]; +}; + +extern void ceph_release_pool_ns (struct kref *ref); +extern struct ceph_pool_ns *ceph_find_or_create_pool_ns (const char *str, +size_t len); +extern struct ceph_pool_ns *ceph_try_get_pool_ns (struct ceph_pool_ns **pns); +extern void ceph_pool_ns_cleanup (void ); + +static inline void ceph_get_pool_ns (struct ceph_pool_ns *ns) +{ +kref_get (&ns->kref); +} + +static inline void ceph_put_pool_ns (struct ceph_pool_ns *ns) +{ +if (!ns) +return ; +kref_put (&ns->kref, ceph_release_pool_ns); +} + +static inline int ceph_compare_pool_ns (struct ceph_pool_ns *ns, +const char * str,size_t len) +{ +size_t nsl = ns ? ns->name_len :0 ; +if (nsl != len) +return nsl - len; +if (nsl ==0 ) +return 0 ; +return strncmp (ns->name, str, len); +} +#endif net/ceph/Makefile +1
-1@@ -11,5 +11,5 @@ libceph-y := ceph_common.o messenger.o msgpool.o buffer.o pagelist.o \ crypto.o armor.o \ auth_x.o \ ceph_fs.o ceph_strings.o ceph_hash.o \ - pagevec.o snapshot.o + pagevec.o snapshot.o pool_ns.onet/ceph/ceph_common.c +2
-0@@ -25,6 +25,7 @@#include <linux/ceph/decode.h> #include <linux/ceph/mon_client.h> #include <linux/ceph/auth.h> +#include <linux/ceph/pool_ns.h> #include "crypto.h" @@ -751,6 +752,7 @@ static void __exit exit_ceph_lib(void)ceph_msgr_exit ();ceph_crypto_shutdown ();ceph_debugfs_cleanup (); +ceph_pool_ns_cleanup (); }module_init (init_ceph_lib);net/ceph/pool_ns.c new file +133
-0@@ -0,0 +1,133 @@ +#include <linux/slab.h> +#include <linux/gfp.h> +#include <linux/string.h> +#include <linux/spinlock.h> +#include <linux/ceph/pool_ns.h> + +static DEFINE_SPINLOCK (pool_ns_lock); +static struct rb_root pool_ns_tree =RB_ROOT ; + +struct ceph_pool_ns *ceph_find_or_create_pool_ns (const char * name,size_t len) +{ +struct ceph_pool_ns *ns, *exist; +struct rb_node **p, *parent; +int ret; + + exist =NULL ; +spin_lock (&pool_ns_lock); + p = &pool_ns_tree.rb_node; +while (*p) { + exist = rb_entry(*p, struct ceph_pool_ns, node); + ret =ceph_compare_pool_ns (exist, name, len); +if (ret >0 ) + p = &(*p)->rb_left; +else if (ret <0 ) + p = &(*p)->rb_right; +else +break ; + exist =NULL ; + } +if (exist && !kref_get_unless_zero (&exist->kref)) { +rb_erase (&exist->node, &pool_ns_tree); +RB_CLEAR_NODE (&exist->node); + exist =NULL ; + } +spin_unlock (&pool_ns_lock); +if (exist) +return exist; + + ns =kmalloc (sizeof (*ns) + len +1 ,GFP_NOFS ); +if (!ns) +return NULL ; + +kref_init (&ns->kref); + ns->name_len = len; +memcpy (ns->name, name, len); + ns->name[len] =0 ; + +retry: + exist =NULL ; + parent =NULL ; + p = &pool_ns_tree.rb_node; +spin_lock (&pool_ns_lock); +while (*p) { + parent = *p; + exist = rb_entry(*p, struct ceph_pool_ns, node); + ret =ceph_compare_pool_ns (exist, name, len); +if (ret >0 ) + p = &(*p)->rb_left; +else if (ret <0 ) + p = &(*p)->rb_right; +else +break ; + exist =NULL ; + } + ret =0 ; +if (!exist) { +rb_link_node (&ns->node, parent, p); +rb_insert_color (&ns->node, &pool_ns_tree); + }else if (!kref_get_unless_zero (&exist->kref)) { +rb_erase (&exist->node, &pool_ns_tree); +RB_CLEAR_NODE (&exist->node); + ret = -EAGAIN ; + } +spin_unlock (&pool_ns_lock); +if (ret == -EAGAIN ) + goto retry; + +if (exist) { +kfree (ns); + ns = exist; + } + +return ns; +} +EXPORT_SYMBOL (ceph_find_or_create_pool_ns); + +static void ceph_free_pool_ns (struct rcu_head *head) +{ + struct ceph_pool_ns *ns = container_of(head, struct ceph_pool_ns, rcu); +kfree (ns); +} + +void ceph_release_pool_ns (struct kref *ref) +{ + struct ceph_pool_ns *ns = container_of(ref, struct ceph_pool_ns, kref); + +spin_lock (&pool_ns_lock); +if (!RB_EMPTY_NODE (&ns->node)) { +rb_erase (&ns->node, &pool_ns_tree); +RB_CLEAR_NODE (&ns->node); + } +spin_unlock (&pool_ns_lock); + +call_rcu (&ns->rcu, ceph_free_pool_ns); +} +EXPORT_SYMBOL (ceph_release_pool_ns); + +struct ceph_pool_ns *ceph_try_get_pool_ns (struct ceph_pool_ns **pns) +{ +struct ceph_pool_ns *ns; +rcu_read_lock (); + ns =rcu_dereference (*pns); +if (ns && !kref_get_unless_zero (&ns->kref)) + ns =NULL ; +rcu_read_unlock (); +return ns; +} +EXPORT_SYMBOL (ceph_try_get_pool_ns); + +void ceph_pool_ns_cleanup (void ) +{ +struct rb_node *p; +struct ceph_pool_ns *ns; +if (RB_EMPTY_ROOT (&pool_ns_tree)) +return ; + +pr_err ("libceph: detect pool ns leaks\n" ); +while ((p =rb_first (&pool_ns_tree))) { + ns = rb_entry(p, struct ceph_pool_ns, node); +rb_erase (p, &pool_ns_tree); +kfree (ns); + } +}Signature · 6 lines
2.5.0 -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/6 libceph: rados pool namesapce support
In reply to Yan, Zheng--- drivers/block/rbd.c | 1 + fs/ceph/inode.c | 3 +++ include/linux/ceph/ceph_fs.h | 2 ++ include/linux/ceph/osdmap.h | 2 ++ net/ceph/ceph_fs.c | 1 + net/ceph/osd_client.c | 42 +++++++++++++++++++++++++++++++----------- net/ceph/osdmap.c | 33 +++++++++++++++++++++++++++------ 7 files changed, 67 insertions(+), 17 deletions(-)
drivers/block/rbd.c +1 -0
@@ -4088,6 +4088,7 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc, rbd_dev->layout.stripe_count =1 ; rbd_dev->layout.object_size =1 <<RBD_MAX_OBJ_ORDER ; rbd_dev->layout.pool_id = spec->pool_id; + rbd_dev->layout.pool_ns =NULL ;/* * If this is a mapping rbd_dev (as opposed to a parent one),
fs/ceph/inode.c +3 -0
@@ -396,6 +396,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb) ci->i_symlink =NULL ;memset (&ci->i_dir_layout,0 ,sizeof (ci->i_dir_layout)); +memset (&ci->i_layout,0 ,sizeof (ci->i_layout)); ci->i_fragtree =RB_ROOT ;mutex_init (&ci->i_fragtree_mutex);
@@ -518,6 +519,8 @@ void ceph_destroy_inode(struct inode *inode)if (ci->i_xattrs.prealloc_blob)ceph_buffer_put (ci->i_xattrs.prealloc_blob); +ceph_put_pool_ns (ci->i_layout.pool_ns); +call_rcu (&inode->i_rcu, ceph_i_callback); }
include/linux/ceph/ceph_fs.h +2 -0
@@ -53,6 +53,7 @@ struct ceph_file_layout_legacy {__le32 fl_pg_pool;/* namespace, crush ruleset, rep level */ } __attribute__ ((packed)); +struct ceph_pool_ns ;/* * ceph_file_layout - describe data layout for a file/inode */
@@ -62,6 +63,7 @@ struct ceph_file_layout {u32 stripe_count;/* over this many objects */ u32 object_size;/* until objects are this big */ s64 pool_id;/* rados pool id */ +struct ceph_pool_ns *pool_ns;/* rados pool namespace */ };extern int ceph_file_layout_is_valid (const struct ceph_file_layout *layout);
include/linux/ceph/osdmap.h +2 -0
@@ -55,6 +55,7 @@ static inline bool ceph_can_shift_osds(struct ceph_pg_pool_info *pool)struct ceph_object_locator {s64 pool; +struct ceph_pool_ns *pool_ns; };/*
@@ -63,6 +64,7 @@ struct ceph_object_locator {* (probably outdated: must be >= RBD_MAX_MD_NAME_LEN -- currently 100) */ #define CEPH_MAX_OID_NAME_LEN 100 +#define CEPH_MAX_NAMESPACE_LEN 100struct ceph_object_id {char name[CEPH_MAX_OID_NAME_LEN ];
net/ceph/ceph_fs.c +1 -0
@@ -36,6 +36,7 @@ void ceph_file_layout_from_legacy(struct ceph_file_layout *fl, fl->pool_id =le64_to_cpu (legacy->fl_pg_pool);if (fl->pool_id ==0 ) fl->pool_id =-1 ; + fl->pool_ns =NULL ; }EXPORT_SYMBOL (ceph_file_layout_from_legacy);
net/ceph/osd_client.c +31 -11
108 lines not on this page · raw message
net/ceph/osdmap.c +27 -6
@@ -1470,12 +1470,33 @@ int ceph_oloc_oid_to_pg(struct ceph_osdmap *osdmap,if (!pi)return -EIO ; - pg_out->pool = oloc->pool; - pg_out->seed =ceph_str_hash (pi->object_hash, oid->name, - oid->name_len); - -dout ("%s '%.*s' pgid %llu.%x\n" , __func__, oid->name_len, oid->name, - pg_out->pool, pg_out->seed); +if (!oloc->pool_ns) { + pg_out->pool = oloc->pool; + pg_out->seed =ceph_str_hash (pi->object_hash, oid->name, + oid->name_len); +dout ("%s '%.*s' pgid %llu.%x\n" , __func__, + oid->name_len, oid->name, pg_out->pool, pg_out->seed); + }else { +char stack_buf[256 ]; +char *buf = stack_buf; +int nsl = oloc->pool_ns->name_len; +size_t total = nsl +1 + oid->name_len; +if (total >sizeof (stack_buf)) { + buf =kmalloc (total,GFP_NOFS ); +if (!buf) +return -ENOMEM ; + } +memcpy (buf, oloc->pool_ns->name, nsl); + buf[nsl] ='\037' ; +memcpy (buf + nsl +1 , oid->name, oid->name_len); + pg_out->pool = oloc->pool; + pg_out->seed =ceph_str_hash (pi->object_hash, buf, total); +if (buf != stack_buf) +kfree (buf); +dout ("%s '%.*s' ns '%.*s' pgid %llu.%x\n" , __func__, + oid->name_len, oid->name, nsl, oloc->pool_ns->name, + pg_out->pool, pg_out->seed); + }return 0 ; }EXPORT_SYMBOL (ceph_oloc_oid_to_pg);
Signature · 1 line
2.5.0
PATCH 4/6 libceph: make sure redirect does not change namespace
In reply to Yan, Zheng--- net/ceph/osd_client.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
net/ceph/osd_client.c +15 -0
@@ -1725,10 +1725,23 @@ static int ceph_oloc_decode(void **p, void *end, }if (struct_v >=5 ) { +bool changed = false;u32 ns_len =ceph_decode_32 (p);if (ns_len >0 ) {ceph_decode_need (p, end, ns_len, e_inval); +if (oloc->pool !=-1 && + (!oloc->pool_ns || +ceph_compare_pool_ns (oloc->pool_ns, *p, ns_len))) + changed = true; *p += ns_len; + }else { +if (oloc->pool !=-1 && oloc->pool_ns) + changed = true; + } +if (changed) { +/* redirect changes namespace */ +pr_warn ("ceph_object_locator::nspace is changed\n" ); + goto e_inval; } }
@@ -1901,7 +1914,9 @@ static void handle_reply(struct ceph_osd_client *osdc, struct ceph_msg *msg) }if (decode_redir) { + redir.oloc.pool_ns = req->r_target_oloc.pool_ns; err =ceph_redirect_decode (&p, end, &redir); + redir.oloc.pool_ns =NULL ;if (err) goto bad_put; }else {
Signature · 1 line
2.5.0
PATCH 5/6 libceph: calculate request message size according to namespace
In reply to Yan, Zheng--- drivers/block/rbd.c | 4 ++-- fs/ceph/addr.c | 4 ++-- fs/ceph/file.c | 5 +++-- include/linux/ceph/osd_client.h | 2 ++ include/linux/ceph/osdmap.h | 1 - net/ceph/osd_client.c | 20 +++++++++++++------- 6 files changed, 22 insertions(+), 14 deletions(-)
drivers/block/rbd.c +2 -2
@@ -1954,7 +1954,7 @@ static struct ceph_osd_request *rbd_osd_req_create(/* Allocate and initialize the request, for the num_ops ops */ osdc = &rbd_dev->rbd_client->client->osdc; - osd_req =ceph_osdc_alloc_request (osdc, snapc, num_ops, false, + osd_req =ceph_osdc_alloc_request (osdc, snapc,NULL , num_ops, false,GFP_ATOMIC );if (!osd_req)return NULL ;/* ENOMEM */
@@ -2003,7 +2003,7 @@ rbd_osd_req_create_copyup(struct rbd_obj_request *obj_request) snapc = img_request->snapc; rbd_dev = img_request->rbd_dev; osdc = &rbd_dev->rbd_client->client->osdc; - osd_req =ceph_osdc_alloc_request (osdc, snapc, num_osd_ops, + osd_req =ceph_osdc_alloc_request (osdc, snapc,NULL , num_osd_ops, false,GFP_ATOMIC );if (!osd_req)return NULL ;/* ENOMEM */
fs/ceph/addr.c +2 -2
@@ -1750,7 +1750,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, s64 pool) } rd_req =ceph_osdc_alloc_request (&fsc->client->osdc, - ceph_empty_snapc, + ceph_empty_snapc,NULL ,1 , false,GFP_NOFS );if (!rd_req) { err = -ENOMEM ;
@@ -1765,7 +1765,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, s64 pool) rd_req->r_base_oid.name_len =strlen (rd_req->r_base_oid.name); wr_req =ceph_osdc_alloc_request (&fsc->client->osdc, - ceph_empty_snapc, + ceph_empty_snapc,NULL ,1 , false,GFP_NOFS );if (!wr_req) { err = -ENOMEM ;
fs/ceph/file.c +3 -2
@@ -696,8 +696,9 @@ static void ceph_aio_retry_work(struct work_struct *work) }spin_unlock (&ci->i_ceph_lock); - req =ceph_osdc_alloc_request (orig_req->r_osdc, snapc,2 , - false,GFP_NOFS ); + req =ceph_osdc_alloc_request (orig_req->r_osdc, snapc, + orig_req->r_base_oloc.pool_ns, +2 , false,GFP_NOFS );if (!req) { ret = -ENOMEM ; req = orig_req;
include/linux/ceph/osd_client.h +2 -0
@@ -14,6 +14,7 @@struct ceph_msg ;struct ceph_snap_context ; +struct ceph_pool_ns ;struct ceph_osd_request ;struct ceph_osd_client ;struct ceph_authorizer ;
@@ -321,6 +322,7 @@ extern void osd_req_op_alloc_hint_init(struct ceph_osd_request *osd_req,extern struct ceph_osd_request *ceph_osdc_alloc_request (struct ceph_osd_client *osdc,struct ceph_snap_context *snapc, +struct ceph_pool_ns *pool_ns,unsigned int num_ops,bool use_mempool,gfp_t gfp_flags);
include/linux/ceph/osdmap.h +0 -1
@@ -64,7 +64,6 @@ struct ceph_object_locator {* (probably outdated: must be >= RBD_MAX_MD_NAME_LEN -- currently 100) */ #define CEPH_MAX_OID_NAME_LEN 100 -#define CEPH_MAX_NAMESPACE_LEN 100struct ceph_object_id {char name[CEPH_MAX_OID_NAME_LEN ];
net/ceph/osd_client.c +13 -7
@@ -366,6 +366,7 @@ EXPORT_SYMBOL(ceph_osdc_put_request);struct ceph_osd_request *ceph_osdc_alloc_request (struct ceph_osd_client *osdc,struct ceph_snap_context *snapc, +struct ceph_pool_ns *pool_ns,unsigned int num_ops,bool use_mempool,gfp_t gfp_flags)
@@ -436,7 +437,8 @@ struct ceph_osd_request *ceph_osdc_alloc_request(struct ceph_osd_client *osdc,/* create request message; allow space for oid */ msg_size =4 +4 +8 +8 +4 +8 ; - msg_size +=2 +4 +8 +4 +4 +4 +CEPH_MAX_NAMESPACE_LEN ;/* oloc */ + msg_size +=2 +4 +8 +4 +4 +4 + + (pool_ns ? pool_ns->name_len :0 );/* oloc */ msg_size +=1 +8 +4 +4 ;/* pg_t */ msg_size +=4 +CEPH_MAX_OID_NAME_LEN ;/* oid */ msg_size +=2 + num_ops *sizeof (struct ceph_osd_op );
@@ -825,6 +827,7 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, bool use_mempool) {struct ceph_osd_request *req; +struct ceph_pool_ns *pool_ns;u64 objnum =0 ;u64 objoff =0 ;u64 objlen =0 ;
@@ -834,12 +837,18 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, opcode !=CEPH_OSD_OP_ZERO && opcode !=CEPH_OSD_OP_TRUNCATE && opcode != CEPH_OSD_OP_CREATE && opcode != CEPH_OSD_OP_DELETE); - req =ceph_osdc_alloc_request (osdc, snapc, num_ops, use_mempool, -GFP_NOFS ); -if (!req) + pool_ns =ceph_try_get_pool_ns (&layout->pool_ns); + + req =ceph_osdc_alloc_request (osdc, snapc, pool_ns, num_ops, + use_mempool,GFP_NOFS ); +if (!req) { +ceph_put_pool_ns (pool_ns);return ERR_PTR (-ENOMEM ); + } req->r_flags = flags; + req->r_base_oloc.pool = layout->pool_id; + req->r_base_oloc.pool_ns = pool_ns;/* calculate max write size */ r =calc_layout (layout, off, plen, &objnum, &objoff, &objlen);
@@ -866,9 +875,6 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc, truncate_size, truncate_seq); } - req->r_base_oloc.pool = layout->pool_id; - req->r_base_oloc.pool_ns =ceph_try_get_pool_ns (&layout->pool_ns); -snprintf (req->r_base_oid.name,sizeof (req->r_base_oid.name),"%llx.%08llx" , vino.ino, objnum); req->r_base_oid.name_len =strlen (req->r_base_oid.name);
Signature · 1 line
2.5.0
PATCH 6/6 ceph: rados pool namesapce support
In reply to Yan, Zheng--- fs/ceph/addr.c | 68 ++++++++++++++++++++++++++++++-------- fs/ceph/caps.c | 43 +++++++++++++++++------- fs/ceph/file.c | 4 ++- fs/ceph/inode.c | 9 ++++- fs/ceph/mds_client.c | 11 ++++++ fs/ceph/mds_client.h | 4 +++ fs/ceph/xattr.c | 66 ++++++++++++++++++++++++++---------- include/linux/ceph/ceph_features.h | 1 + include/linux/ceph/ceph_fs.h | 3 +- net/ceph/ceph_fs.c | 6 ++-- 10 files changed, 167 insertions(+), 48 deletions(-)
fs/ceph/addr.c +55 -13
@@ -1701,7 +1701,8 @@ enum { POOL_WRITE = 2, }; -static int __ceph_pool_perm_get (struct ceph_inode_info *ci,s64 pool) +static int __ceph_pool_perm_get (struct ceph_inode_info *ci, +s64 pool,struct ceph_pool_ns *pool_ns) {struct ceph_fs_client *fsc =ceph_inode_to_client (&ci->vfs_inode);struct ceph_mds_client *mdsc = fsc->mdsc;
@@ -1709,6 +1710,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, s64 pool)struct rb_node **p, *parent;struct ceph_pool_perm *perm;struct page **pages; +size_t pool_ns_len;int err =0 , err2 =0 , have =0 ;down_read (&mdsc->pool_perm_rwsem);
@@ -1720,17 +1722,28 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, s64 pool)else if (pool > perm->pool) p = &(*p)->rb_right;else { - have = perm->perm; -break ; +int ret =ceph_compare_pool_ns (pool_ns, + perm->pool_ns, + perm->pool_ns_len); +if (ret <0 ) + p = &(*p)->rb_left; +else if (ret >0 ) + p = &(*p)->rb_right; +else { + have = perm->perm; +break ; + } } }up_read (&mdsc->pool_perm_rwsem);if (*p) goto out; -dout ("__ceph_pool_perm_get pool %lld no perm cached\n" , pool); +dout ("__ceph_pool_perm_get pool %lld ns %.*s no perm cached\n" , + pool, (int )pool_ns->name_len, pool_ns->name);down_write (&mdsc->pool_perm_rwsem); + p = &mdsc->pool_perm_tree.rb_node; parent =NULL ;while (*p) { parent = *p;
@@ -1740,8 +1753,17 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, s64 pool)else if (pool > perm->pool) p = &(*p)->rb_right;else { - have = perm->perm; -break ; +int ret =ceph_compare_pool_ns (pool_ns, + perm->pool_ns, + perm->pool_ns_len); +if (ret <0 ) + p = &(*p)->rb_left; +else if (ret >0 ) + p = &(*p)->rb_right; +else { + have = perm->perm; +break ; + } } }if (*p) {
@@ -1750,7 +1772,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, s64 pool) } rd_req =ceph_osdc_alloc_request (&fsc->client->osdc, - ceph_empty_snapc,NULL , + ceph_empty_snapc, pool_ns,1 , false,GFP_NOFS );if (!rd_req) { err = -ENOMEM ;
@@ -1760,12 +1782,15 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, s64 pool) rd_req->r_flags =CEPH_OSD_FLAG_READ ;osd_req_op_init (rd_req,0 ,CEPH_OSD_OP_STAT ,0 ); rd_req->r_base_oloc.pool = pool; + rd_req->r_base_oloc.pool_ns = pool_ns; +if (pool_ns) +ceph_get_pool_ns (pool_ns);snprintf (rd_req->r_base_oid.name,sizeof (rd_req->r_base_oid.name),"%llx.00000000" , ci->i_vino.ino); rd_req->r_base_oid.name_len =strlen (rd_req->r_base_oid.name); wr_req =ceph_osdc_alloc_request (&fsc->client->osdc, - ceph_empty_snapc,NULL , + ceph_empty_snapc, pool_ns,1 , false,GFP_NOFS );if (!wr_req) { err = -ENOMEM ;
@@ -1776,6 +1801,9 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, s64 pool)CEPH_OSD_FLAG_ACK |CEPH_OSD_FLAG_ONDISK ;osd_req_op_init (wr_req,0 ,CEPH_OSD_OP_CREATE ,CEPH_OSD_OP_FLAG_EXCL ); wr_req->r_base_oloc.pool = pool; + wr_req->r_base_oloc.pool_ns = pool_ns; +if (pool_ns) +ceph_get_pool_ns (pool_ns); wr_req->r_base_oid = rd_req->r_base_oid;/* one page should be large enough for STAT data */
@@ -1812,7 +1840,8 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, s64 pool) goto out_unlock; } - perm =kmalloc (sizeof (*perm),GFP_NOFS ); + pool_ns_len = pool_ns ? pool_ns->name_len :0 ; + perm =kmalloc (sizeof (*perm) + pool_ns_len +1 ,GFP_NOFS );if (!perm) { err = -ENOMEM ; goto out_unlock;
@@ -1820,6 +1849,11 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci, s64 pool) perm->pool = pool; perm->perm = have; + perm->pool_ns_len = pool_ns_len; +if (pool_ns_len >0 ) +memcpy (perm->pool_ns, pool_ns->name, pool_ns_len); + perm->pool_ns[pool_ns_len] =0 ; +rb_link_node (&perm->node, parent, p);rb_insert_color (&perm->node, &mdsc->pool_perm_tree); err =0 ;
@@ -1833,13 +1867,18 @@ out_unlock: out:if (!err) err = have; -dout ("__ceph_pool_perm_get pool %lld result = %d\n" , pool, err); +if (pool_ns) +dout ("__ceph_pool_perm_get pool %lld ns %.*s result = %d\n" , + pool, (int )pool_ns->name_len, pool_ns->name, err); +else +dout ("__ceph_pool_perm_get pool %lld result = %d\n" , pool, err);return err; }int ceph_pool_perm_check (struct ceph_inode_info *ci,int need) {s64 pool; +struct ceph_pool_ns *pool_ns;int ret, flags; if (ceph_test_mount_opt(ceph_inode_to_client(&ci->vfs_inode),
@@ -1865,7 +1904,9 @@ check:return 0 ; } - ret =__ceph_pool_perm_get (ci, pool); + pool_ns =ceph_try_get_pool_ns (&ci->i_layout.pool_ns); + ret =__ceph_pool_perm_get (ci, pool, pool_ns); +ceph_put_pool_ns (pool_ns);if (ret <0 )return ret;
@@ -1876,8 +1917,9 @@ check: flags |=CEPH_I_POOL_WR ;spin_lock (&ci->i_ceph_lock); -if (pool == ci->i_layout.pool_id) { - ci->i_ceph_flags = flags; +if (pool == ci->i_layout.pool_id && + pool_ns == ci->i_layout.pool_ns) { + ci->i_ceph_flags |= flags; }else { pool = ci->i_layout.pool_id; flags = ci->i_ceph_flags;
fs/ceph/caps.c +31 -12
103 lines not on this page · raw message
fs/ceph/file.c +3 -1
@@ -708,8 +708,10 @@ static void ceph_aio_retry_work(struct work_struct *work) req->r_flags =CEPH_OSD_FLAG_ORDERSNAP |CEPH_OSD_FLAG_ONDISK |CEPH_OSD_FLAG_WRITE ; - req->r_base_oloc = orig_req->r_base_oloc; req->r_base_oid = orig_req->r_base_oid; + req->r_base_oloc = orig_req->r_base_oloc; +if (req->r_base_oloc.pool_ns) +ceph_get_pool_ns (req->r_base_oloc.pool_ns); req->r_ops[0 ] = orig_req->r_ops[0 ];osd_req_op_init (req,1 ,CEPH_OSD_OP_STARTSYNC ,0 );
fs/ceph/inode.c +8 -1
@@ -675,6 +675,7 @@ static int fill_inode(struct inode *inode, struct page *locked_page,int issued =0 , implemented, new_issued;struct timespec mtime, atime, ctime;struct ceph_buffer *xattr_blob =NULL ; +struct ceph_pool_ns *pool_ns =NULL ;struct ceph_cap *new_cap =NULL ;int err =0 ;bool wake = false;
@@ -702,6 +703,10 @@ static int fill_inode(struct inode *inode, struct page *locked_page, iinfo->xattr_len); } +if (iinfo->pool_ns_len >0 ) + pool_ns =ceph_find_or_create_pool_ns (iinfo->pool_ns_data, + iinfo->pool_ns_len); +spin_lock (&ci->i_ceph_lock);/*
@@ -757,7 +762,8 @@ static int fill_inode(struct inode *inode, struct page *locked_page,if (new_version || (new_issued & (CEPH_CAP_ANY_FILE_RD |CEPH_CAP_ANY_FILE_WR ))) {s64 old_pool = ci->i_layout.pool_id; -ceph_file_layout_from_legacy (&ci->i_layout, &info->layout); +ceph_file_layout_from_legacy (&ci->i_layout, &info->layout, + &pool_ns);if (ci->i_layout.pool_id != old_pool) ci->i_ceph_flags &= ~CEPH_I_POOL_PERM ;
@@ -923,6 +929,7 @@ out:ceph_put_cap (mdsc, new_cap);if (xattr_blob)ceph_buffer_put (xattr_blob); +ceph_put_pool_ns (pool_ns);return err; }
fs/ceph/mds_client.c +11 -0
@@ -100,6 +100,17 @@ static int parse_reply_info_in(void **p, void *end, }else info->inline_version =CEPH_INLINE_NONE ; + info->pool_ns_len =0 ; + info->pool_ns_data =NULL ; +if (features &CEPH_FEATURE_FS_FILE_LAYOUT_V2 ) { +ceph_decode_32_safe (p, end, info->pool_ns_len, bad); +if (info->pool_ns_len >0 ) { +ceph_decode_need (p, end, info->pool_ns_len, bad); + info->pool_ns_data = *p; + *p += info->pool_ns_len; + } + } +return 0 ; bad:return err;
fs/ceph/mds_client.h +4 -0
@@ -44,6 +44,8 @@ struct ceph_mds_reply_info_in {u64 inline_version;u32 inline_len;char *inline_data; +u32 pool_ns_len; +char *pool_ns_data; };/*
@@ -269,6 +271,8 @@ struct ceph_pool_perm {struct rb_node node;int perm;s64 pool; +size_t pool_ns_len; +char pool_ns[]; };/*
fs/ceph/xattr.c +48 -18
110 lines not on this page · raw message
include/linux/ceph/ceph_features.h +1 -0
@@ -75,6 +75,7 @@#define CEPH_FEATURE_CRUSH_TUNABLES5 (1ULL<<58)/* chooseleaf stable mode */ // duplicated since it was introduced at the same time as CEPH_FEATURE_CRUSH_TUNABLES5 #define CEPH_FEATURE_NEW_OSDOPREPLY_ENCODING (1ULL<<58)/* New, v7 encoding */ +#define CEPH_FEATURE_FS_FILE_LAYOUT_V2 (1ULL<<58)/* overlap with tunables5 */ /* * The introduction of CEPH_FEATURE_OSD_SNAPMAPPER caused the feature
include/linux/ceph/ceph_fs.h +2 -1
@@ -68,7 +68,8 @@ struct ceph_file_layout {extern int ceph_file_layout_is_valid (const struct ceph_file_layout *layout);extern void ceph_file_layout_from_legacy (struct ceph_file_layout *fl, -struct ceph_file_layout_legacy *legacy); +struct ceph_file_layout_legacy *legacy, +struct ceph_pool_ns **pns);extern void ceph_file_layout_to_legacy (struct ceph_file_layout *fl,struct ceph_file_layout_legacy *legacy);
net/ceph/ceph_fs.c +4 -2
@@ -3,6 +3,7 @@*/ #include <linux/module.h> #include <linux/ceph/types.h> +#include <linux/ceph/pool_ns.h> /* * return true if @layout appears to be valid
@@ -28,7 +29,8 @@ int ceph_file_layout_is_valid(const struct ceph_file_layout *layout) }void ceph_file_layout_from_legacy (struct ceph_file_layout *fl, -struct ceph_file_layout_legacy *legacy) +struct ceph_file_layout_legacy *legacy, +struct ceph_pool_ns **pns) { fl->stripe_unit =le32_to_cpu (legacy->fl_stripe_unit); fl->stripe_count =le32_to_cpu (legacy->fl_stripe_count);
@@ -36,7 +38,7 @@ void ceph_file_layout_from_legacy(struct ceph_file_layout *fl, fl->pool_id =le64_to_cpu (legacy->fl_pg_pool);if (fl->pool_id ==0 ) fl->pool_id =-1 ; - fl->pool_ns =NULL ; + *pns =xchg (&fl->pool_ns, *pns); }EXPORT_SYMBOL (ceph_file_layout_from_legacy);
Signature · 1 line
2.5.0