crush kernel updates
cover crush kernel updates
We ripped out support for preferred osd placement in ceph since it was a broken misfeature that nobody used. When I went to mirror those changes on the kernel side I found that a whole bunch of old stuff had never been moved over, including a number of cleanups and an actual bug fix. Everything is now in the wip-crush tree on github.com/ceph/ceph-client.
This code is well tested in the sense that it has been this way on the userland side for ages (with the exception of the first preferred_osds patch). That said, I've only done very basic testing of the kernel code, so it's the crush callers that need attention.
I'd like to get this into the testing branch soon so we can see if it sorts out #2022. A few of these should probably also go to Linus before the next window, too.
sage
Sage Weil (11):
ceph: drop support for preferred_osd pgs
ceph: refactor SETLAYOUT and SETDIRLAYOUT ioctl checks into common
helper
crush: clean up types, const-ness
crush: adjust local retry threshold
crush: be more tolerant of nonsensical crush maps
crush: use a temporary variable to simplify crush_do_rule
crush: remove forcefeed functionality
crush: remove parent maps
crush: fix tree node weight lookup
crush: fix memory leak when destroying tree buckets
crush: warn on do_rule failure
drivers/block/rbd.c | 1 - fs/ceph/file.c | 1 - fs/ceph/ioctl.c | 89 ++++++++++------------- fs/ceph/xattr.c | 9 --- include/linux/ceph/ceph_fs.h | 4 +- include/linux/ceph/osdmap.h | 2 - include/linux/crush/crush.h | 18 ++--- include/linux/crush/mapper.h | 7 +- net/ceph/crush/crush.c | 45 +++--------- net/ceph/crush/mapper.c | 162 +++++++++++++++++------------------------ net/ceph/osdmap.c | 67 +++++------------ 11 files changed, 147 insertions(+), 258 deletions(-)
Signature · 1 line
1.7.9
PATCH 1/11 ceph: drop support for preferred_osd pgs
This was an ill-conceived feature that has been removed from Ceph. Do this gracefully:
- reject attempts to specify a preferred_osd via the ioctl
- stop exposing this information via virtual xattrs
- always fill in -1 for requests, in case we talk to an older server
- don't calculate preferred_osd placements/pgids
--- drivers/block/rbd.c | 1 - fs/ceph/file.c | 1 - fs/ceph/ioctl.c | 15 ++++--------- fs/ceph/xattr.c | 9 -------- include/linux/ceph/ceph_fs.h | 4 +- include/linux/ceph/osdmap.h | 2 - net/ceph/osdmap.c | 47 +++++++++--------------------------------- 7 files changed, 17 insertions(+), 62 deletions(-)
drivers/block/rbd.c +0 -1
@@ -935,7 +935,6 @@ static int rbd_do_request(struct request *rq, layout->fl_stripe_unit =cpu_to_le32 (1 <<RBD_MAX_OBJ_ORDER ); layout->fl_stripe_count =cpu_to_le32 (1 ); layout->fl_object_size =cpu_to_le32 (1 <<RBD_MAX_OBJ_ORDER ); - layout->fl_pg_preferred =cpu_to_le32 (-1 ); layout->fl_pg_pool =cpu_to_le32 (dev->poolid);ceph_calc_raw_layout (osdc, layout, snapid, ofs, &len, &bno, req, ops);
fs/ceph/file.c +0 -1
@@ -54,7 +54,6 @@ prepare_open_request(struct super_block *sb, int flags, int create_mode) req->r_fmode =ceph_flags_to_mode (flags); req->r_args.open.flags =cpu_to_le32 (flags); req->r_args.open.mode =cpu_to_le32 (create_mode); - req->r_args.open.preferred =cpu_to_le32 (-1 ); out:return req; }
fs/ceph/ioctl.c +5 -10
@@ -26,8 +26,7 @@ static long ceph_ioctl_get_layout(struct file *file, void __user *arg) 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.preferred_osd = - (s32 )le32_to_cpu (ci->i_layout.fl_pg_preferred); + l.preferred_osd = (s32)-1 ;if (copy_to_user (arg, &l,sizeof (l)))return -EFAULT ; }
@@ -49,6 +48,10 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)if (copy_from_user (&l, arg,sizeof (l)))return -EFAULT ; +/* preferred_osd is no longer supported */ +if (l.preferred_osd !=-1 ) +return -EINVAL ; +/* validate changed params against current layout */ err =ceph_do_getattr (file->f_dentry->d_inode,CEPH_STAT_CAP_LAYOUT );if (!err) {
@@ -56,8 +59,6 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) nl.stripe_count =ceph_file_layout_stripe_count (ci->i_layout); nl.object_size =ceph_file_layout_object_size (ci->i_layout); nl.data_pool =le32_to_cpu (ci->i_layout.fl_pg_pool); - nl.preferred_osd = - (s32 )le32_to_cpu (ci->i_layout.fl_pg_preferred); }else return err;
@@ -69,8 +70,6 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) nl.object_size = l.object_size;if (l.data_pool) nl.data_pool = l.data_pool; -if (l.preferred_osd) - nl.preferred_osd = l.preferred_osd; if ((nl.object_size & ~PAGE_MASK) || (nl.stripe_unit & ~PAGE_MASK) ||
@@ -106,8 +105,6 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) req->r_args.setlayout.layout.fl_object_size =cpu_to_le32 (l.object_size); req->r_args.setlayout.layout.fl_pg_pool =cpu_to_le32 (l.data_pool); - req->r_args.setlayout.layout.fl_pg_preferred = -cpu_to_le32 (l.preferred_osd); parent_inode =ceph_get_dentry_parent_inode (file->f_dentry); err =ceph_mdsc_do_request (mdsc, parent_inode, req);
@@ -171,8 +168,6 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)cpu_to_le32 (l.object_size); req->r_args.setlayout.layout.fl_pg_pool =cpu_to_le32 (l.data_pool); - req->r_args.setlayout.layout.fl_pg_preferred = -cpu_to_le32 (l.preferred_osd); err =ceph_mdsc_do_request (mdsc, inode, req);ceph_mdsc_put_request (req);
fs/ceph/xattr.c +0 -9
@@ -118,15 +118,6 @@ static size_t ceph_vxattrcb_file_layout(struct ceph_inode_info *ci, char *val, (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)); - -if (ceph_file_layout_pg_preferred (ci->i_layout) >=0 ) { - val += ret; - size -= ret; - ret +=snprintf (val, size,"preferred_osd=%lld\n" , - (unsigned long long )ceph_file_layout_pg_preferred ( - ci->i_layout)); - } -return ret; }
include/linux/ceph/ceph_fs.h +2 -2
@@ -65,7 +65,7 @@ struct ceph_file_layout {__le32 fl_object_stripe_unit;/* UNUSED. for per-object parity, if any */ /* object -> pg layout */ -__le32 fl_pg_preferred;/* preferred primary for pg (-1 for none) */ +__le32 fl_unused;/* unused; used to be preferred primary (-1) */ __le32 fl_pg_pool;/* namespace, crush ruleset, rep level */ } __attribute__ ((packed));
@@ -384,7 +384,7 @@ union ceph_mds_request_args {__le32 stripe_count;/* ... */ __le32 object_size;__le32 file_replication; -__le32 preferred; +__le32 unused;/* used to be preferred osd */ } __attribute__ ((packed)) open;struct {__le32 flags;
include/linux/ceph/osdmap.h +0 -2
@@ -65,8 +65,6 @@ struct ceph_osdmap {#define ceph_file_layout_cas_hash (l) ((__s32)le32_to_cpu((l).fl_cas_hash))#define ceph_file_layout_object_su (l) \ ((__s32)le32_to_cpu((l).fl_object_stripe_unit)) -#define ceph_file_layout_pg_preferred (l) \ - ((__s32)le32_to_cpu((l).fl_pg_preferred))#define ceph_file_layout_pg_pool (l) \ ((__s32)le32_to_cpu((l).fl_pg_pool))
net/ceph/osdmap.c +10 -37
86 lines not on this page · raw message
Signature · 1 line
1.7.9
PATCH 2/11 ceph: refactor SETLAYOUT and SETDIRLAYOUT ioctl checks into common helper
In reply to Sage WeilBoth of these methods perform similar checks; move that code to a helper so that we can ensure the checks are consistent.
--- fs/ceph/ioctl.c | 82 +++++++++++++++++++++++++----------------------------- 1 files changed, 38 insertions(+), 44 deletions(-)
fs/ceph/ioctl.c +38 -44
@@ -34,6 +34,36 @@ static long ceph_ioctl_get_layout(struct file *file, void __user *arg)return err; } +static long __validate_layout (struct ceph_mds_client *mdsc, +struct ceph_ioctl_layout *l) +{ +int i, err; + +/* preferred_osd is no longer supported */ +if (l->preferred_osd !=-1 ) +return -EINVAL ; + +/* validate striping parameters */ +if ((l->object_size & ~PAGE_MASK ) || + (l->stripe_unit & ~PAGE_MASK ) || + ((unsigned )l->object_size % (unsigned )l->stripe_unit)) +return -EINVAL ; + +/* make sure it's a valid data pool */ +mutex_lock (&mdsc->mutex); + err = -EINVAL ; +for (i =0 ; i < mdsc->mdsmap->m_num_data_pg_pools; i++) +if (mdsc->mdsmap->m_data_pg_pools[i] == l->data_pool) { + err =0 ; +break ; + } +mutex_unlock (&mdsc->mutex); +if (err) +return err; + +return 0 ; +} +static long ceph_ioctl_set_layout (struct file *file,void __user *arg) {struct inode *inode = file->f_dentry->d_inode;
@@ -43,15 +73,11 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)struct ceph_ioctl_layout l;struct ceph_inode_info *ci =ceph_inode (file->f_dentry->d_inode);struct ceph_ioctl_layout nl; -int err, i; +int err;if (copy_from_user (&l, arg,sizeof (l)))return -EFAULT ; -/* preferred_osd is no longer supported */ -if (l.preferred_osd !=-1 ) -return -EINVAL ; -/* validate changed params against current layout */ err =ceph_do_getattr (file->f_dentry->d_inode,CEPH_STAT_CAP_LAYOUT );if (!err) {
@@ -71,24 +97,9 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)if (l.data_pool) nl.data_pool = l.data_pool; -if ((nl.object_size & ~PAGE_MASK ) || - (nl.stripe_unit & ~PAGE_MASK ) || - ((unsigned )nl.object_size % (unsigned )nl.stripe_unit)) -return -EINVAL ; - -/* make sure it's a valid data pool */ -if (l.data_pool >0 ) { -mutex_lock (&mdsc->mutex); - err = -EINVAL ; -for (i =0 ; i < mdsc->mdsmap->m_num_data_pg_pools; i++) -if (mdsc->mdsmap->m_data_pg_pools[i] == l.data_pool) { - err =0 ; -break ; - } -mutex_unlock (&mdsc->mutex); -if (err) -return err; - } + err =__validate_layout (mdsc, &nl); +if (err) +return err; req =ceph_mdsc_create_request (mdsc,CEPH_MDS_OP_SETLAYOUT ,USE_AUTH_MDS );
@@ -124,33 +135,16 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg)struct inode *inode = file->f_dentry->d_inode;struct ceph_mds_request *req;struct ceph_ioctl_layout l; -int err, i; +int err;struct ceph_mds_client *mdsc =ceph_sb_to_client (inode->i_sb)->mdsc;/* copy and validate */ if (copy_from_user (&l, arg,sizeof (l)))return -EFAULT ; -if ((l.object_size & ~PAGE_MASK ) || - (l.stripe_unit & ~PAGE_MASK ) || - !l.stripe_unit || - (l.object_size && - (unsigned )l.object_size % (unsigned )l.stripe_unit)) -return -EINVAL ; - -/* make sure it's a valid data pool */ -if (l.data_pool >0 ) { -mutex_lock (&mdsc->mutex); - err = -EINVAL ; -for (i =0 ; i < mdsc->mdsmap->m_num_data_pg_pools; i++) -if (mdsc->mdsmap->m_data_pg_pools[i] == l.data_pool) { - err =0 ; -break ; - } -mutex_unlock (&mdsc->mutex); -if (err) -return err; - } + err =__validate_layout (mdsc, &l); +if (err) +return err; req =ceph_mdsc_create_request (mdsc,CEPH_MDS_OP_SETDIRLAYOUT ,USE_AUTH_MDS );
Signature · 1 line
1.7.9
PATCH 3/11 crush: clean up types, const-ness
In reply to Sage WeilMove various types from int -> __u32 (or similar), and add const as appropriate.
This reflects changes that have been present in the userland implementation for some time.
--- include/linux/crush/crush.h | 2 +- include/linux/crush/mapper.h | 6 ++-- net/ceph/crush/crush.c | 14 ++++---- net/ceph/crush/mapper.c | 71 +++++++++++++++++++++-------------------- 4 files changed, 47 insertions(+), 46 deletions(-)
include/linux/crush/crush.h +1 -1
@@ -168,7 +168,7 @@ struct crush_map {/* crush.c */ -extern int crush_get_bucket_item_weight (struct crush_bucket *b,int pos); +extern int crush_get_bucket_item_weight (const struct crush_bucket *b,int pos);extern void crush_calc_parents (struct crush_map *map);extern void crush_destroy_bucket_uniform (struct crush_bucket_uniform *b);extern void crush_destroy_bucket_list (struct crush_bucket_list *b);
include/linux/crush/mapper.h +3 -3
@@ -10,11 +10,11 @@#include "crush.h" -extern int crush_find_rule (struct crush_map *map,int pool,int type,int size); -extern int crush_do_rule (struct crush_map *map, +extern int crush_find_rule (const struct crush_map *map,int ruleset,int type,int size); +extern int crush_do_rule (const struct crush_map *map,int ruleno,int x,int *result,int result_max,int forcefeed,/* -1 for none */ -__u32 *weights); +const __u32 *weights);#endif
net/ceph/crush/crush.c +7 -7
@@ -23,12 +23,12 @@ const char *crush_bucket_alg_name(int alg)/** * crush_get_bucket_item_weight - Get weight of an item in given bucket -* @b: bucket pointer -* @p: item index in bucket +* @param b bucket pointer +* @param p item index in bucket */ -int crush_get_bucket_item_weight (struct crush_bucket *b,int p) +int crush_get_bucket_item_weight (const struct crush_bucket *b,int p) { -if (p >= b->size) +if ((__u32 )p >= b->size)return 0 ;switch (b->alg) {
@@ -120,14 +120,13 @@ void crush_destroy_bucket(struct crush_bucket *b)/** * crush_destroy - Destroy a crush_map -* @map: crush_map pointer +* @param map crush_map pointer */ void crush_destroy (struct crush_map *map) { -int b; -/* buckets */ if (map->buckets) { +__s32 b;for (b =0 ; b < map->max_buckets; b++) {if (map->buckets[b] ==NULL )continue ;
@@ -138,6 +137,7 @@ void crush_destroy(struct crush_map *map)/* rules */ if (map->rules) { +__u32 b;for (b =0 ; b < map->max_rules; b++)kfree (map->rules[b]);kfree (map->rules);
net/ceph/crush/mapper.c +36 -35
149 lines not on this page · raw message
Signature · 1 line
1.7.9
PATCH 4/11 crush: adjust local retry threshold
In reply to Sage WeilThis small adjustment reflects a change that was made in ceph.git commit af6a9f30696c900a2a8bd7ae24e8ed15fb4964bb, about 6 months ago. An N-1 search is not exhaustive. Fixed ceph.git bug #1594.
--- net/ceph/crush/mapper.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/ceph/crush/mapper.c +1 -1
@@ -415,7 +415,7 @@ reject:if (collide && flocal <3 )/* retry locally a few times */ retry_bucket =1 ; -else if (flocal < in->size + orig_tries) +else if (flocal <= in->size + orig_tries)/* exhaustive bucket search */ retry_bucket =1 ;else if (ftotal <20 )
Signature · 1 line
1.7.9
PATCH 5/11 crush: be more tolerant of nonsensical crush maps
In reply to Sage WeilIf we get a map that doesn't make sense, error out or ignore the badness instead of BUGging out. This reflects the ceph.git commits 9895f0bff7dc68e9b49b572613d242315fb11b6c and 8ded26472058d5205803f244c2f33cb6cb10de79.
--- net/ceph/crush/mapper.c | 33 ++++++++++++++++++++++++--------- 1 files changed, 24 insertions(+), 9 deletions(-)
net/ceph/crush/mapper.c +24 -9
@@ -152,8 +152,8 @@ static int bucket_list_choose(struct crush_bucket_list *bucket,return bucket->h.items[i]; } -BUG_ON (1 ); -return 0 ; +dprintk ("bad list sums for bucket %d\n" , bucket->h.id); +return bucket->h.items[0 ]; }
@@ -239,6 +239,7 @@ static int bucket_straw_choose(struct crush_bucket_straw *bucket,static int crush_bucket_choose (struct crush_bucket *in,int x,int r) {dprintk (" crush_bucket_choose %d x=%d r=%d\n" , in->id, x, r); +BUG_ON (in->size ==0 );switch (in->alg) {case CRUSH_BUCKET_UNIFORM : return bucket_uniform_choose((struct crush_bucket_uniform *)in,
@@ -253,7 +254,7 @@ static int crush_bucket_choose(struct crush_bucket *in, int x, int r)return bucket_straw_choose ((struct crush_bucket_straw *)in, x, r);default : -BUG_ON (1 ); +dprintk ("unknown bucket %d alg %d\n" , in->id, in->alg);return in->items[0 ]; } }
@@ -354,7 +355,11 @@ static int crush_choose(const struct crush_map *map, item =bucket_perm_choose (in, x, r); else item =crush_bucket_choose (in, x, r); -BUG_ON (item >= map->max_devices); +if (item >= map->max_devices) { +dprintk (" bad item %d\n" , item); + skip_rep =1 ; +break ; + }/* desired type? */ if (item <0 )
@@ -365,8 +370,12 @@ static int crush_choose(const struct crush_map *map,/* keep going? */ if (itemtype != type) { -BUG_ON (item >=0 || - (-1 -item) >= map->max_buckets); +if (item >=0 || + (-1 -item) >= map->max_buckets) { +dprintk (" bad item type %d\n" , type); + skip_rep =1 ; +break ; + } in = map->buckets[-1 -item]; retry_bucket =1 ;continue ;
@@ -478,7 +487,10 @@ int crush_do_rule(const struct crush_map *map,int numrep;int firstn; -BUG_ON (ruleno >= map->max_rules); +if ((__u32 )ruleno >= map->max_rules) { +dprintk (" bad ruleno %d\n" , ruleno); +return 0 ; + } rule = map->rules[ruleno]; result_len =0 ;
@@ -528,7 +540,8 @@ int crush_do_rule(const struct crush_map *map, firstn =1 ;case CRUSH_RULE_CHOOSE_LEAF_INDEP :case CRUSH_RULE_CHOOSE_INDEP : -BUG_ON (wsize ==0 ); +if (wsize ==0 ) +break ; recurse_to_leaf = rule->steps[step].op ==
@@ -597,7 +610,9 @@ int crush_do_rule(const struct crush_map *map,break ;default : -BUG_ON (1 ); +dprintk (" unknown op %d at step %d\n" , + curstep->op, step); +break ; } }return result_len;
Signature · 1 line
1.7.9
PATCH 6/11 crush: use a temporary variable to simplify crush_do_rule
In reply to Sage WeilUse a temporary variable here to avoid repeated array lookups and clean up the code a bit.
This reflects ceph.git commit 6b5be27634ad307b471a5bf0db85c4f5c834885f.
--- net/ceph/crush/mapper.c | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-)
net/ceph/crush/mapper.c +11 -9
@@ -519,14 +519,15 @@ int crush_do_rule(const struct crush_map *map, }for (step =0 ; step < rule->len; step++) { +struct crush_rule_step *curstep = &rule->steps[step]; + firstn =0 ; -switch (rule->steps[step].op) { +switch (curstep->op) {case CRUSH_RULE_TAKE : - w[0 ] = rule->steps[step].arg1; + w[0 ] = curstep->arg1;/* find position in force_context/hierarchy */ -while (force_pos >=0 && - force_context[force_pos] != w[0 ]) +while (force_pos >=0 && force_context[force_pos] != w[0 ]) force_pos--;/* and move past it */ if (force_pos >=0 )
@@ -538,15 +539,16 @@ int crush_do_rule(const struct crush_map *map,case CRUSH_RULE_CHOOSE_LEAF_FIRSTN :case CRUSH_RULE_CHOOSE_FIRSTN : firstn =1 ; +/* fall through */ case CRUSH_RULE_CHOOSE_LEAF_INDEP :case CRUSH_RULE_CHOOSE_INDEP :if (wsize ==0 )break ; recurse_to_leaf = - rule->steps[step].op == + curstep->op ==CRUSH_RULE_CHOOSE_LEAF_FIRSTN || - rule->steps[step].op == + curstep->op ==CRUSH_RULE_CHOOSE_LEAF_INDEP ;/* reset output */
@@ -558,7 +560,7 @@ int crush_do_rule(const struct crush_map *map,* basically, numrep <= 0 means relative to * the provided result_max */ - numrep = rule->steps[step].arg1; + numrep = curstep->arg1;if (numrep <=0 ) { numrep += result_max;if (numrep <=0 )
@@ -569,7 +571,7 @@ int crush_do_rule(const struct crush_map *map,/* skip any intermediate types */ while (force_pos && force_context[force_pos] <0 && - rule->steps[step].arg2 != + curstep->arg2 != map->buckets[-1 - force_context[force_pos]]->type) force_pos--;
@@ -583,7 +585,7 @@ int crush_do_rule(const struct crush_map *map, map->buckets[-1 -w[i]], weight, x, numrep, - rule->steps[step].arg2, + curstep->arg2, o+osize, j, firstn, recurse_to_leaf, c+osize);
Signature · 1 line
1.7.9
PATCH 7/11 crush: remove forcefeed functionality
In reply to Sage WeilRemove forcefeed functionality from CRUSH. This is an ugly misfeature that is mostly useless and unused. Remove it.
Reflects ceph.git commit ed974b5000f2851207d860a651809af4a1867942.
--- include/linux/crush/mapper.h | 1 - net/ceph/crush/mapper.c | 48 +----------------------------------------- net/ceph/osdmap.c | 2 +- 3 files changed, 2 insertions(+), 49 deletions(-)
include/linux/crush/mapper.h +0 -1
@@ -14,7 +14,6 @@ extern int crush_find_rule(const struct crush_map *map, int ruleset, int type, iextern int crush_do_rule (const struct crush_map *map,int ruleno,int x,int *result,int result_max, -int forcefeed,/* -1 for none */ const __u32 *weights);#endif
net/ceph/crush/mapper.c +1 -47
77 lines not on this page · raw message
net/ceph/osdmap.c +1 -1
@@ -1069,7 +1069,7 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid, pps += poolid; *num =crush_do_rule (osdmap->crush, ruleno, pps, osds,min_t (int, pool->v.size, *num), --1 , osdmap->osd_weight); + osdmap->osd_weight);return osds; }
Signature · 1 line
1.7.9
PATCH 8/11 crush: remove parent maps
In reply to Sage WeilThese were used for the ill-fated forcefeed feature. Remove them.
Reflects ceph.git commit ebdf80edfecfbd5a842b71fbe5732857994380c1.
--- include/linux/crush/crush.h | 11 ----------- net/ceph/crush/crush.c | 25 ------------------------- net/ceph/osdmap.c | 7 ------- 3 files changed, 0 insertions(+), 43 deletions(-)
include/linux/crush/crush.h +0 -11
@@ -151,16 +151,6 @@ struct crush_map {struct crush_bucket **buckets;struct crush_rule **rules; -/* -* Parent pointers to identify the parent bucket a device or -* bucket in the hierarchy. If an item appears more than -* once, this is the _last_ time it appeared (where buckets -* are processed in bucket id order, from -1 on down to -* -max_buckets. -*/ -__u32 *bucket_parents; -__u32 *device_parents; -__s32 max_buckets;__u32 max_rules;__s32 max_devices;
@@ -169,7 +159,6 @@ struct crush_map {/* crush.c */ extern int crush_get_bucket_item_weight (const struct crush_bucket *b,int pos); -extern void crush_calc_parents (struct crush_map *map);extern void crush_destroy_bucket_uniform (struct crush_bucket_uniform *b);extern void crush_destroy_bucket_list (struct crush_bucket_list *b);extern void crush_destroy_bucket_tree (struct crush_bucket_tree *b);
net/ceph/crush/crush.c +0 -25
@@ -46,29 +46,6 @@ int crush_get_bucket_item_weight(const struct crush_bucket *b, int p)return 0 ; } -/** -* crush_calc_parents - Calculate parent vectors for the given crush map. -* @map: crush_map pointer -*/ -void crush_calc_parents (struct crush_map *map) -{ -int i, b, c; - -for (b =0 ; b < map->max_buckets; b++) { -if (map->buckets[b] ==NULL ) -continue ; -for (i =0 ; i < map->buckets[b]->size; i++) { - c = map->buckets[b]->items[i]; -BUG_ON (c >= map->max_devices || - c < -map->max_buckets); -if (c >=0 ) - map->device_parents[c] = map->buckets[b]->id; -else - map->bucket_parents[-1 -c] = map->buckets[b]->id; - } - } -} -void crush_destroy_bucket_uniform (struct crush_bucket_uniform *b) {kfree (b->h.perm);
@@ -143,8 +120,6 @@ void crush_destroy(struct crush_map *map)kfree (map->rules); } -kfree (map->bucket_parents); -kfree (map->device_parents);kfree (map); }
net/ceph/osdmap.c +0 -7
@@ -161,13 +161,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end) c->max_rules =ceph_decode_32 (p); c->max_devices =ceph_decode_32 (p); - c->device_parents =kcalloc (c->max_devices,sizeof (u32),GFP_NOFS ); -if (c->device_parents ==NULL ) - goto badmem; - c->bucket_parents =kcalloc (c->max_buckets,sizeof (u32),GFP_NOFS ); -if (c->bucket_parents ==NULL ) - goto badmem; - c->buckets =kcalloc (c->max_buckets,sizeof (*c->buckets),GFP_NOFS );if (c->buckets ==NULL ) goto badmem;
Signature · 1 line
1.7.9
PATCH 9/11 crush: fix tree node weight lookup
In reply to Sage WeilFix the node weight lookup for tree buckets by using a correct accessor.
Reflects ceph.git commit d287ade5bcbdca82a3aef145b92924cf1e856733.
--- include/linux/crush/crush.h | 5 +++++ net/ceph/crush/crush.c | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-)
include/linux/crush/crush.h +5 -0
@@ -166,4 +166,9 @@ extern void crush_destroy_bucket_straw(struct crush_bucket_straw *b);extern void crush_destroy_bucket (struct crush_bucket *b);extern void crush_destroy (struct crush_map *map); +static inline int crush_calc_tree_node (int i) +{ +return ((i+1 ) <<1 )-1 ; +} +#endif
net/ceph/crush/crush.c +1 -3
@@ -37,9 +37,7 @@ int crush_get_bucket_item_weight(const struct crush_bucket *b, int p)case CRUSH_BUCKET_LIST :return ((struct crush_bucket_list *)b)->item_weights[p];case CRUSH_BUCKET_TREE : -if (p &1 ) -return ((struct crush_bucket_tree *)b)->node_weights[p]; -return 0 ; +return ((struct crush_bucket_tree *)b)->node_weights[crush_calc_tree_node (p)];case CRUSH_BUCKET_STRAW :return ((struct crush_bucket_straw *)b)->item_weights[p]; }
Signature · 1 line
1.7.9
PATCH 10/11 crush: fix memory leak when destroying tree buckets
In reply to Sage WeilReflects ceph.git commit 46d63d98434b3bc9dad2fc9ab23cbaedc3bcb0e4.
--- net/ceph/crush/crush.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
net/ceph/crush/crush.c +2 -0
@@ -62,6 +62,8 @@ void crush_destroy_bucket_list(struct crush_bucket_list *b)void crush_destroy_bucket_tree (struct crush_bucket_tree *b) { +kfree (b->h.perm); +kfree (b->h.items);kfree (b->node_weights);kfree (b); }
Signature · 1 line
1.7.9
PATCH 11/11 crush: warn on do_rule failure
In reply to Sage WeilIf we get an error code from crush_do_rule(), print an error to the console.
--- net/ceph/osdmap.c | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-)
net/ceph/osdmap.c +11 -4
@@ -1027,7 +1027,7 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid,struct ceph_pg_mapping *pg;struct ceph_pg_pool_info *pool;int ruleno; -unsigned poolid, ps, pps, t; +unsigned poolid, ps, pps, t, r; poolid =le32_to_cpu (pgid.pool); ps =le16_to_cpu (pgid.ps);
@@ -1060,9 +1060,16 @@ static int *calc_pg_raw(struct ceph_osdmap *osdmap, struct ceph_pg pgid,le32_to_cpu (pool->v.pgp_num), pool->pgp_num_mask); pps += poolid; - *num =crush_do_rule (osdmap->crush, ruleno, pps, osds, -min_t (int, pool->v.size, *num), - osdmap->osd_weight); + r =crush_do_rule (osdmap->crush, ruleno, pps, osds, +min_t (int, pool->v.size, *num), + osdmap->osd_weight); +if (r <0 ) { +pr_err ("error %d from crush rule: pool %d ruleset %d type %d" +" size %d\n" , r, poolid, pool->v.crush_ruleset, + pool->v.type, pool->v.size); +return NULL ; + } + *num = r;return osds; }
Signature · 1 line
1.7.9