From e1e56300cac30fe8d9db296107905f5936648c3c Mon Sep 17 00:00:00 2001 From: Yang Sheng Date: Fri, 4 Dec 2015 14:28:33 +0800 Subject: [PATCH] LU-7085 lov: trying smaller memory allocations Reduce struct lov_io_sub to smaller memory usage on wide-stripe file systems. Signed-off-by: Yang Sheng Change-Id: Ie92cec079f6514efca71663af1ae6ae1e34c73cb Reviewed-on: http://review.whamcloud.com/17476 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Bob Glossman Reviewed-by: Jian Yu Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- lustre/include/cl_object.h | 30 +++++++++---------- lustre/llite/dcache.c | 2 +- lustre/llite/file.c | 20 ++++++------- lustre/llite/glimpse.c | 4 +-- lustre/llite/lcommon_cl.c | 8 +++--- lustre/llite/lcommon_misc.c | 4 +-- lustre/llite/llite_internal.h | 2 +- lustre/llite/lloop.c | 2 +- lustre/llite/lproc_llite.c | 2 +- lustre/llite/rw26.c | 6 ++-- lustre/llite/vvp_dev.c | 10 +++---- lustre/llite/xattr.c | 2 +- lustre/lov/lov_cl_internal.h | 67 +++++++++++++++++++++---------------------- lustre/lov/lov_object.c | 2 +- lustre/obdclass/cl_object.c | 12 ++++---- lustre/obdecho/echo_client.c | 10 +++---- lustre/osc/lproc_osc.c | 2 +- lustre/osc/osc_request.c | 2 +- 18 files changed, 93 insertions(+), 94 deletions(-) diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index d45aacc..4de3d2e 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -2453,23 +2453,23 @@ void cl_sync_io_end(const struct lu_env *env, struct cl_sync_io *anchor); * @{ */ struct cl_env_nest { - int cen_refcheck; - void *cen_cookie; + __u16 cen_refcheck; + void *cen_cookie; }; -struct lu_env *cl_env_peek (int *refcheck); -struct lu_env *cl_env_get (int *refcheck); -struct lu_env *cl_env_alloc (int *refcheck, __u32 tags); -struct lu_env *cl_env_nested_get (struct cl_env_nest *nest); -void cl_env_put (struct lu_env *env, int *refcheck); -void cl_env_nested_put (struct cl_env_nest *nest, struct lu_env *env); -void *cl_env_reenter (void); -void cl_env_reexit (void *cookie); -void cl_env_implant (struct lu_env *env, int *refcheck); -void cl_env_unplant (struct lu_env *env, int *refcheck); -unsigned cl_env_cache_purge(unsigned nr); -struct lu_env *cl_env_percpu_get (void); -void cl_env_percpu_put (struct lu_env *env); +struct lu_env *cl_env_peek(__u16 *refcheck); +struct lu_env *cl_env_get(__u16 *refcheck); +struct lu_env *cl_env_alloc(__u16 *refcheck, __u32 tags); +struct lu_env *cl_env_nested_get(struct cl_env_nest *nest); +void cl_env_put(struct lu_env *env, __u16 *refcheck); +void cl_env_nested_put(struct cl_env_nest *nest, struct lu_env *env); +void *cl_env_reenter(void); +void cl_env_reexit(void *cookie); +void cl_env_implant(struct lu_env *env, __u16 *refcheck); +void cl_env_unplant(struct lu_env *env, __u16 *refcheck); +unsigned cl_env_cache_purge(unsigned nr); +struct lu_env *cl_env_percpu_get(void); +void cl_env_percpu_put(struct lu_env *env); /** @} cl_env */ diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index fc3343e..4ec4421 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -138,7 +138,7 @@ static inline int return_if_equal(struct ldlm_lock *lock, void *data) static int find_cbdata(struct inode *inode) { struct lu_env *env; - int refcheck; + __u16 refcheck; struct ll_sb_info *sbi = ll_i2sbi(inode); int rc = 0; ENTRY; diff --git a/lustre/llite/file.c b/lustre/llite/file.c index 285e360..0592d26 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -1175,7 +1175,7 @@ static ssize_t ll_file_read_iter(struct kiocb *iocb, struct iov_iter *to) struct vvp_io_args *args; struct lu_env *env; ssize_t result; - int refcheck; + __u16 refcheck; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1199,7 +1199,7 @@ static ssize_t ll_file_write_iter(struct kiocb *iocb, struct iov_iter *from) struct vvp_io_args *args; struct lu_env *env; ssize_t result; - int refcheck; + __u16 refcheck; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1262,7 +1262,7 @@ static ssize_t ll_file_aio_read(struct kiocb *iocb, const struct iovec *iov, if (nr_segs == 1) { struct lu_env *env; - int refcheck; + __u16 refcheck; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1308,7 +1308,7 @@ static ssize_t ll_file_read(struct file *file, char __user *buf, size_t count, struct iovec iov = { .iov_base = buf, .iov_len = count }; struct kiocb *kiocb; ssize_t result; - int refcheck; + __u16 refcheck; ENTRY; env = cl_env_get(&refcheck); @@ -1350,7 +1350,7 @@ static ssize_t ll_file_aio_write(struct kiocb *iocb, const struct iovec *iov, if (nr_segs == 1) { struct lu_env *env; - int refcheck; + __u16 refcheck; env = cl_env_get(&refcheck); if (IS_ERR(env)) @@ -1397,7 +1397,7 @@ static ssize_t ll_file_write(struct file *file, const char __user *buf, .iov_len = count }; struct kiocb *kiocb; ssize_t result; - int refcheck; + __u16 refcheck; ENTRY; env = cl_env_get(&refcheck); @@ -1431,7 +1431,7 @@ static ssize_t ll_file_splice_read(struct file *in_file, loff_t *ppos, struct lu_env *env; struct vvp_io_args *args; ssize_t result; - int refcheck; + __u16 refcheck; ENTRY; env = cl_env_get(&refcheck); @@ -1590,7 +1590,7 @@ static int ll_file_getstripe(struct inode *inode, struct lov_user_md __user *lum) { struct lu_env *env; - int refcheck; + __u16 refcheck; int rc; ENTRY; @@ -1768,7 +1768,7 @@ static int ll_do_fiemap(struct inode *inode, struct fiemap *fiemap, size_t num_bytes) { struct lu_env *env; - int refcheck; + __u16 refcheck; int rc = 0; struct ll_fiemap_info_key fmkey = { .lfik_name = KEY_FIEMAP, }; ENTRY; @@ -1874,7 +1874,7 @@ int ll_data_version(struct inode *inode, __u64 *data_version, int flags) struct cl_object *obj = ll_i2info(inode)->lli_clob; struct lu_env *env; struct cl_io *io; - int refcheck; + __u16 refcheck; int result; ENTRY; diff --git a/lustre/llite/glimpse.c b/lustre/llite/glimpse.c index d374c81..f0751e7 100644 --- a/lustre/llite/glimpse.c +++ b/lustre/llite/glimpse.c @@ -145,7 +145,7 @@ int cl_glimpse_lock(const struct lu_env *env, struct cl_io *io, } static int cl_io_get(struct inode *inode, struct lu_env **envout, - struct cl_io **ioout, int *refcheck) + struct cl_io **ioout, __u16 *refcheck) { struct lu_env *env; struct cl_io *io; @@ -182,8 +182,8 @@ int cl_glimpse_size0(struct inode *inode, int agl) */ struct lu_env *env = NULL; struct cl_io *io = NULL; + __u16 refcheck; int result; - int refcheck; ENTRY; diff --git a/lustre/llite/lcommon_cl.c b/lustre/llite/lcommon_cl.c index 6433bb7b..673bfbd 100644 --- a/lustre/llite/lcommon_cl.c +++ b/lustre/llite/lcommon_cl.c @@ -64,7 +64,7 @@ * mutex. */ struct lu_env *cl_inode_fini_env; -int cl_inode_fini_refcheck; +__u16 cl_inode_fini_refcheck; /** * A mutex serializing calls to slp_inode_fini() under extreme memory @@ -78,7 +78,7 @@ int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr, struct lu_env *env; struct cl_io *io; int result; - int refcheck; + __u16 refcheck; ENTRY; @@ -142,7 +142,7 @@ int cl_file_inode_init(struct inode *inode, struct lustre_md *md) } }; int result = 0; - int refcheck; + __u16 refcheck; LASSERT(md->body->mbo_valid & OBD_MD_FLID); LASSERT(S_ISREG(inode->i_mode)); @@ -228,7 +228,7 @@ void cl_inode_fini(struct inode *inode) struct lu_env *env; struct ll_inode_info *lli = ll_i2info(inode); struct cl_object *clob = lli->lli_clob; - int refcheck; + __u16 refcheck; int emergency; if (clob != NULL) { diff --git a/lustre/llite/lcommon_misc.c b/lustre/llite/lcommon_misc.c index 5f7eaaf..43e243c 100644 --- a/lustre/llite/lcommon_misc.c +++ b/lustre/llite/lcommon_misc.c @@ -126,7 +126,7 @@ int cl_get_grouplock(struct cl_object *obj, unsigned long gid, int nonblock, struct cl_lock *lock; struct cl_lock_descr *descr; __u32 enqflags; - int refcheck; + __u16 refcheck; int rc; env = cl_env_get(&refcheck); @@ -180,7 +180,7 @@ void cl_put_grouplock(struct ll_grouplock *lg) struct lu_env *env = lg->lg_env; struct cl_io *io = lg->lg_io; struct cl_lock *lock = lg->lg_lock; - int refcheck; + __u16 refcheck; LASSERT(lg->lg_env != NULL); LASSERT(lg->lg_gid != 0); diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 1b0a8ee..15530dc 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -1490,7 +1490,7 @@ int cl_setattr_ost(struct cl_object *obj, const struct iattr *attr, unsigned int attr_flags); extern struct lu_env *cl_inode_fini_env; -extern int cl_inode_fini_refcheck; +extern __u16 cl_inode_fini_refcheck; int cl_file_inode_init(struct inode *inode, struct lustre_md *md); void cl_inode_fini(struct inode *inode); diff --git a/lustre/llite/lloop.c b/lustre/llite/lloop.c index 3bf9bf4..f3b9288 100644 --- a/lustre/llite/lloop.c +++ b/lustre/llite/lloop.c @@ -450,7 +450,7 @@ static int loop_thread(void *data) unsigned long total_count = 0; struct lu_env *env; - int refcheck; + __u16 refcheck; int ret = 0; set_user_nice(current, -20); diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 53dd7ac..e631f50 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -433,7 +433,7 @@ ll_max_cached_mb_seq_write(struct file *file, const char __user *buffer, long diff = 0; long nrpages = 0; long pages_number; - int refcheck; + __u16 refcheck; int mult; long rc; char kernbuf[128]; diff --git a/lustre/llite/rw26.c b/lustre/llite/rw26.c index 83fa263..b2d6e31 100644 --- a/lustre/llite/rw26.c +++ b/lustre/llite/rw26.c @@ -88,7 +88,7 @@ static void ll_invalidatepage(struct page *vmpage, struct cl_page *page; struct cl_object *obj; - int refcheck; + __u16 refcheck; LASSERT(PageLocked(vmpage)); LASSERT(!PageWriteback(vmpage)); @@ -362,7 +362,7 @@ ll_direct_IO( ssize_t count = iov_iter_count(iter); ssize_t tot_bytes = 0, result = 0; size_t size = MAX_DIO_SIZE; - int refcheck; + __u16 refcheck; /* FIXME: io smaller than PAGE_SIZE is broken on ia64 ??? */ if ((file_offset & ~PAGE_MASK) || (count & ~PAGE_MASK)) @@ -495,7 +495,7 @@ ll_direct_IO(int rw, struct kiocb *iocb, const struct iovec *iov, ssize_t tot_bytes = 0, result = 0; unsigned long seg = 0; size_t size = MAX_DIO_SIZE; - int refcheck; + __u16 refcheck; ENTRY; /* FIXME: io smaller than PAGE_SIZE is broken on ia64 ??? */ diff --git a/lustre/llite/vvp_dev.c b/lustre/llite/vvp_dev.c index d0b03a5..61b8bb9 100644 --- a/lustre/llite/vvp_dev.c +++ b/lustre/llite/vvp_dev.c @@ -317,7 +317,7 @@ int cl_sb_init(struct super_block *sb) struct cl_device *cl; struct lu_env *env; int rc = 0; - int refcheck; + __u16 refcheck; sbi = ll_s2sbi(sb); env = cl_env_get(&refcheck); @@ -339,7 +339,7 @@ int cl_sb_fini(struct super_block *sb) struct ll_sb_info *sbi; struct lu_env *env; struct cl_device *cld; - int refcheck; + __u16 refcheck; int result; ENTRY; @@ -541,7 +541,7 @@ static int vvp_pgcache_show(struct seq_file *f, void *v) struct cl_object *clob; struct lu_env *env; struct vvp_pgcache_id id; - int refcheck; + __u16 refcheck; int result; env = cl_env_get(&refcheck); @@ -587,7 +587,7 @@ static void *vvp_pgcache_start(struct seq_file *f, loff_t *pos) { struct ll_sb_info *sbi; struct lu_env *env; - int refcheck; + __u16 refcheck; sbi = f->private; @@ -611,7 +611,7 @@ static void *vvp_pgcache_next(struct seq_file *f, void *v, loff_t *pos) { struct ll_sb_info *sbi; struct lu_env *env; - int refcheck; + __u16 refcheck; env = cl_env_get(&refcheck); if (!IS_ERR(env)) { diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c index 66125d7..6e282af 100644 --- a/lustre/llite/xattr.c +++ b/lustre/llite/xattr.c @@ -529,7 +529,7 @@ static ssize_t ll_getxattr_lov(struct inode *inode, void *buf, size_t buf_size) .cl_buf.lb_buf = buf, .cl_buf.lb_len = buf_size, }; - int refcheck; + __u16 refcheck; if (obj == NULL) RETURN(-ENODATA); diff --git a/lustre/lov/lov_cl_internal.h b/lustre/lov/lov_cl_internal.h index 1cac50a..cde1ff4 100644 --- a/lustre/lov/lov_cl_internal.h +++ b/lustre/lov/lov_cl_internal.h @@ -121,7 +121,7 @@ struct lov_device_emerg { * * \see cl_env_get() */ - int emrg_refcheck; + __u16 emrg_refcheck; }; struct lov_device { @@ -381,40 +381,39 @@ struct lov_thread_info { * State that lov_io maintains for every sub-io. */ struct lov_io_sub { - int sub_stripe; - /** - * sub-io for a stripe. Ideally sub-io's can be stopped and resumed - * independently, with lov acting as a scheduler to maximize overall - * throughput. - */ - struct cl_io *sub_io; - /** - * Linkage into a list (hanging off lov_io::lis_active) of all - * sub-io's active for the current IO iteration. - */ + __u16 sub_stripe; + /** + * environment's refcheck. + * + * \see cl_env_get() + */ + __u16 sub_refcheck; + __u16 sub_reenter; + /** + * true, iff cl_io_init() was successfully executed against + * lov_io_sub::sub_io. + */ + __u16 sub_io_initialized:1, + /** + * True, iff lov_io_sub::sub_io and lov_io_sub::sub_env weren't + * allocated, but borrowed from a per-device emergency pool. + */ + sub_borrowed:1; + /** + * Linkage into a list (hanging off lov_io::lis_active) of all + * sub-io's active for the current IO iteration. + */ struct list_head sub_linkage; - /** - * true, iff cl_io_init() was successfully executed against - * lov_io_sub::sub_io. - */ - int sub_io_initialized; - /** - * True, iff lov_io_sub::sub_io and lov_io_sub::sub_env weren't - * allocated, but borrowed from a per-device emergency pool. - */ - int sub_borrowed; - /** - * environment, in which sub-io executes. - */ - struct lu_env *sub_env; - /** - * environment's refcheck. - * - * \see cl_env_get() - */ - int sub_refcheck; - int sub_refcheck2; - int sub_reenter; + /** + * sub-io for a stripe. Ideally sub-io's can be stopped and resumed + * independently, with lov acting as a scheduler to maximize overall + * throughput. + */ + struct cl_io *sub_io; + /** + * environment, in which sub-io executes. + */ + struct lu_env *sub_env; }; /** diff --git a/lustre/lov/lov_object.c b/lustre/lov/lov_object.c index f731146..1f2ccca 100644 --- a/lustre/lov/lov_object.c +++ b/lustre/lov/lov_object.c @@ -772,7 +772,7 @@ static int lov_layout_change(const struct lu_env *unused, const struct lov_layout_operations *new_ops; void *cookie; struct lu_env *env; - int refcheck; + __u16 refcheck; int rc; ENTRY; diff --git a/lustre/obdclass/cl_object.c b/lustre/obdclass/cl_object.c index 19c17f8..d34b431 100644 --- a/lustre/obdclass/cl_object.c +++ b/lustre/obdclass/cl_object.c @@ -893,7 +893,7 @@ static inline struct cl_env *cl_env_container(struct lu_env *env) return container_of(env, struct cl_env, ce_lu); } -struct lu_env *cl_env_peek(int *refcheck) +struct lu_env *cl_env_peek(__u16 *refcheck) { struct lu_env *env; struct cl_env *cle; @@ -927,7 +927,7 @@ struct lu_env *cl_env_peek(int *refcheck) * * \see cl_env_put() */ -struct lu_env *cl_env_get(int *refcheck) +struct lu_env *cl_env_get(__u16 *refcheck) { struct lu_env *env; @@ -952,7 +952,7 @@ EXPORT_SYMBOL(cl_env_get); * * \see cl_env_get() */ -struct lu_env *cl_env_alloc(int *refcheck, __u32 tags) +struct lu_env *cl_env_alloc(__u16 *refcheck, __u32 tags) { struct lu_env *env; @@ -1010,7 +1010,7 @@ EXPORT_SYMBOL(cl_env_cache_purge); * this thread is using environment and it is returned to the allocation * cache, or freed straight away, if cache is large enough. */ -void cl_env_put(struct lu_env *env, int *refcheck) +void cl_env_put(struct lu_env *env, __u16 *refcheck) { struct cl_env *cle; @@ -1072,7 +1072,7 @@ EXPORT_SYMBOL(cl_env_reexit); * * \see cl_env_unplant() */ -void cl_env_implant(struct lu_env *env, int *refcheck) +void cl_env_implant(struct lu_env *env, __u16 *refcheck) { struct cl_env *cle = cl_env_container(env); @@ -1087,7 +1087,7 @@ EXPORT_SYMBOL(cl_env_implant); /** * Detach environment installed earlier by cl_env_implant(). */ -void cl_env_unplant(struct lu_env *env, int *refcheck) +void cl_env_unplant(struct lu_env *env, __u16 *refcheck) { struct cl_env *cle = cl_env_container(env); diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index f936795..d47bc16 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -1115,7 +1115,7 @@ cl_echo_object_find(struct echo_device *d, const struct ost_id *oi) struct cl_object *obj; struct lov_oinfo *oinfo = NULL; struct lu_fid *fid; - int refcheck; + __u16 refcheck; int rc; ENTRY; @@ -1175,7 +1175,7 @@ static int cl_echo_object_put(struct echo_object *eco) { struct lu_env *env; struct cl_object *obj = echo_obj2cl(eco); - int refcheck; + __u16 refcheck; ENTRY; env = cl_env_get(&refcheck); @@ -1295,9 +1295,9 @@ static int cl_echo_object_brw(struct echo_object *eco, int rw, u64 offset, struct cl_page *clp; struct lustre_handle lh = { 0 }; int page_size = cl_page_size(obj); - int refcheck; int rc; int i; + __u16 refcheck; ENTRY; LASSERT((offset & ~PAGE_MASK) == 0); @@ -2060,7 +2060,7 @@ static int echo_md_handler(struct echo_device *ed, int command, struct echo_thread_info *info; struct lu_device *ld = ed->ed_next; struct lu_env *env; - int refcheck; + __u16 refcheck; struct lu_object *parent; char *name = NULL; int namelen = data->ioc_plen2; @@ -2644,7 +2644,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len, } case OBD_IOC_ECHO_ALLOC_SEQ: { struct lu_env *cl_env; - int refcheck; + __u16 refcheck; __u64 seq; int max_count; diff --git a/lustre/osc/lproc_osc.c b/lustre/osc/lproc_osc.c index a98ef84..983442f 100644 --- a/lustre/osc/lproc_osc.c +++ b/lustre/osc/lproc_osc.c @@ -231,7 +231,7 @@ osc_cached_mb_seq_write(struct file *file, const char __user *buffer, rc = atomic_long_read(&cli->cl_lru_in_list) - pages_number; if (rc > 0) { struct lu_env *env; - int refcheck; + __u16 refcheck; env = cl_env_get(&refcheck); if (!IS_ERR(env)) { diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index ee7d04a..2ab31b4 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -2533,7 +2533,7 @@ static int osc_import_event(struct obd_device *obd, case IMP_EVENT_INVALIDATE: { struct ldlm_namespace *ns = obd->obd_namespace; struct lu_env *env; - int refcheck; + __u16 refcheck; ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY); -- 1.8.3.1