X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdfilter%2Ffilter_internal.h;h=5d1e11987885d87c3005f2368f8fd50a13463877;hb=d800fc41a1abdaf7aaf6c0e3e7ddcdec489985a8;hp=d73a4687787ab38a51eb2c9403480177499cda7e;hpb=1317f6241b86e1fc90a4d2dc836e9a25eeaaeb04;p=fs%2Flustre-release.git diff --git a/lustre/obdfilter/filter_internal.h b/lustre/obdfilter/filter_internal.h index d73a468..5d1e119 100644 --- a/lustre/obdfilter/filter_internal.h +++ b/lustre/obdfilter/filter_internal.h @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -16,8 +14,8 @@ * in the LICENSE file that accompanied this code). * * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see [sun.com URL with a - * copy of GPLv2]. + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or @@ -26,8 +24,10 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2011, Whamcloud, Inc. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -40,10 +40,10 @@ #ifdef __KERNEL__ # include #endif -#include #include #include #include +#include #include #define FILTER_LAYOUT_VERSION "2" @@ -59,6 +59,7 @@ OBD_INCOMPAT_COMMON_LR) #define FILTER_GRANT_CHUNK (2ULL * PTLRPC_MAX_BRW_SIZE) +#define FILTER_GRANT_SHRINK_LIMIT (16ULL * FILTER_GRANT_CHUNK) #define GRANT_FOR_LLOG(obd) 16 extern struct file_operations filter_per_export_stats_fops; @@ -69,20 +70,15 @@ extern struct file_operations filter_per_nid_stats_fops; OBD_MD_FLSIZE | OBD_MD_FLBLOCKS | OBD_MD_FLBLKSZ|\ OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME) -struct filter_fid { - struct ll_fid ff_fid; /* ff_fid.f_type == file stripe number */ - __u64 ff_objid; - __u64 ff_group; -}; - /* per-client-per-object persistent state (LRU) */ struct filter_mod_data { - struct list_head fmd_list; /* linked to fed_mod_list */ - __u64 fmd_id; /* object being written to */ - __u64 fmd_gr; /* group being written to */ - __u64 fmd_mactime_xid;/* xid highest {m,a,c}time setattr */ - unsigned long fmd_expire; /* jiffies when it should expire */ - int fmd_refcount; /* reference counter - list holds 1 */ + cfs_list_t fmd_list; /* linked to fed_mod_list */ + __u64 fmd_id; /* object being written to */ + __u64 fmd_gr; /* group being written to */ + __u64 fmd_mactime_xid;/* xid highest {m,a,c}time + * setattr */ + unsigned long fmd_expire; /* jiffies when it should expire */ + int fmd_refcount; /* reference counter, list holds 1 */ }; #ifdef HAVE_BGL_SUPPORT @@ -91,21 +87,50 @@ struct filter_mod_data { #define FILTER_FMD_MAX_NUM_DEFAULT 32 #endif /* Client cache seconds */ -#define FILTER_FMD_MAX_AGE_DEFAULT ((obd_timeout + 10) * HZ) +#define FILTER_FMD_MAX_AGE_DEFAULT ((obd_timeout + 10) * CFS_HZ) + +#ifndef HAVE_PAGE_CONSTANT +#define mapping_cap_page_constant_write(mapping) 0 +#define SetPageConstant(page) do {} while (0) +#define ClearPageConstant(page) do {} while (0) +#endif struct filter_mod_data *filter_fmd_find(struct obd_export *exp, - obd_id objid, obd_gr group); + obd_id objid, obd_seq seq); struct filter_mod_data *filter_fmd_get(struct obd_export *exp, - obd_id objid, obd_gr group); + obd_id objid, obd_seq seq); void filter_fmd_put(struct obd_export *exp, struct filter_mod_data *fmd); void filter_fmd_expire(struct obd_export *exp); enum { LPROC_FILTER_READ_BYTES = 0, LPROC_FILTER_WRITE_BYTES = 1, + LPROC_FILTER_GET_PAGE = 2, + LPROC_FILTER_NO_PAGE = 3, + LPROC_FILTER_CACHE_ACCESS = 4, + LPROC_FILTER_CACHE_HIT = 5, + LPROC_FILTER_CACHE_MISS = 6, LPROC_FILTER_LAST, }; +/* for job stats */ +enum { + LPROC_FILTER_STATS_READ = 0, + LPROC_FILTER_STATS_WRITE = 1, + LPROC_FILTER_STATS_SETATTR = 2, + LPROC_FILTER_STATS_PUNCH = 3, + LPROC_FILTER_STATS_SYNC = 4, + LPROC_FILTER_STATS_LAST, +}; + +static inline void filter_counter_incr(struct obd_export *exp, int opcode, + char *jobid, long amount) +{ + if (exp->exp_obd && exp->exp_obd->u.obt.obt_jobstats.ojs_hash && + (exp->exp_connect_flags & OBD_CONNECT_JOBSTATS)) + lprocfs_job_stats_log(exp->exp_obd, jobid, opcode, amount); +} + //#define FILTER_MAX_CACHE_SIZE (32 * 1024 * 1024) /* was OBD_OBJECT_EOF */ #define FILTER_MAX_CACHE_SIZE OBD_OBJECT_EOF @@ -115,67 +140,85 @@ enum { extern int *obdfilter_created_scratchpad; extern void target_recovery_fini(struct obd_device *obd); -extern void target_recovery_init(struct obd_device *obd, +extern void target_recovery_init(struct lu_target *lut, svc_handler_t handler); /* filter.c */ void f_dput(struct dentry *); struct dentry *filter_fid2dentry(struct obd_device *, struct dentry *dir, - obd_gr group, obd_id id); -struct dentry *__filter_oa2dentry(struct obd_device *obd, struct obdo *oa, + obd_seq seq, obd_id id); +struct dentry *__filter_oa2dentry(struct obd_device *obd, struct ost_id *ostid, const char *what, int quiet); -#define filter_oa2dentry(obd, oa) __filter_oa2dentry(obd, oa, __FUNCTION__, 0) +#define filter_oa2dentry(obd, ostid) __filter_oa2dentry(obd, ostid, \ + __func__, 0) -int filter_finish_transno(struct obd_export *, struct obd_trans_info *, int rc, - int force_sync); +int filter_finish_transno(struct obd_export *, struct inode *, + struct obd_trans_info *, int rc, int force_sync); __u64 filter_next_id(struct filter_obd *, struct obdo *); -__u64 filter_last_id(struct filter_obd *, obd_gr group); +__u64 filter_last_id(struct filter_obd *, obd_seq seq); int filter_update_fidea(struct obd_export *exp, struct inode *inode, void *handle, struct obdo *oa); -int filter_update_server_data(struct obd_device *, struct file *, - struct lr_server_data *, int force_sync); -int filter_update_last_objid(struct obd_device *, obd_gr, int force_sync); +int filter_update_server_data(struct obd_device *); +int filter_update_last_objid(struct obd_device *, obd_seq, int force_sync); int filter_common_setup(struct obd_device *, struct lustre_cfg *lcfg, void *option); -int filter_destroy(struct obd_export *exp, struct obdo *oa, - struct lov_stripe_md *md, struct obd_trans_info *, - struct obd_export *); +int filter_destroy(const struct lu_env *env, struct obd_export *exp, + struct obdo *oa, struct lov_stripe_md *md, + struct obd_trans_info *, struct obd_export *, void *); int filter_setattr_internal(struct obd_export *exp, struct dentry *dentry, struct obdo *oa, struct obd_trans_info *oti); -int filter_setattr(struct obd_export *exp, struct obd_info *oinfo, - struct obd_trans_info *oti); +int filter_setattr(const struct lu_env *env, struct obd_export *exp, + struct obd_info *oinfo, struct obd_trans_info *oti); -struct dentry *filter_create_object(struct obd_device *obd, struct obdo *oa); +int filter_create(const struct lu_env *env, struct obd_export *exp, + struct obdo *oa, struct lov_stripe_md **ea, + struct obd_trans_info *oti); -struct obd_llog_group *filter_find_olg(struct obd_device *obd, int group); +struct obd_llog_group *filter_find_olg(struct obd_device *obd, int seq); /* filter_lvb.c */ extern struct ldlm_valblock_ops filter_lvbo; /* filter_io.c */ -int filter_preprw(int cmd, struct obd_export *, struct obdo *, int objcount, - struct obd_ioobj *, int niocount, struct niobuf_remote *, - struct niobuf_local *, struct obd_trans_info *, +int filter_preprw(const struct lu_env *env, int cmd, struct obd_export *, + struct obdo *, int objcount, + struct obd_ioobj *, struct niobuf_remote *, + int *, struct niobuf_local *, struct obd_trans_info *, struct lustre_capa *); -int filter_commitrw(int cmd, struct obd_export *, struct obdo *, int objcount, - struct obd_ioobj *, int niocount, struct niobuf_local *, - struct obd_trans_info *, int rc); -int filter_brw(int cmd, struct obd_export *, struct obd_info *oinfo, - obd_count oa_bufs, struct brw_page *pga, struct obd_trans_info *); -void flip_into_page_cache(struct inode *inode, struct page *new_page); +int filter_commitrw(const struct lu_env *, int cmd, struct obd_export *, + struct obdo *, int objcount, + struct obd_ioobj *, struct niobuf_remote *, int, + struct niobuf_local *, struct obd_trans_info *, int rc); +void filter_release_cache(struct obd_device *, struct obd_ioobj *, + struct niobuf_remote *, struct inode *); /* filter_io_*.c */ -struct filter_iobuf; +struct filter_iobuf { + cfs_hlist_node_t dr_hlist; + __u64 dr_hkey; + /* number of reqs being processed */ + cfs_atomic_t dr_numreqs; + cfs_waitq_t dr_wait; + int dr_max_pages; + int dr_npages; + int dr_error; + unsigned int dr_ignore_quota:1; + struct page **dr_pages; + unsigned long *dr_blocks; + struct filter_obd *dr_filter; +}; + int filter_commitrw_write(struct obd_export *exp, struct obdo *oa, int objcount, - struct obd_ioobj *obj, int niocount, + struct obd_ioobj *obj, struct niobuf_remote *, int, struct niobuf_local *res, struct obd_trans_info *oti, int rc); obd_size filter_grant_space_left(struct obd_export *exp); long filter_grant(struct obd_export *exp, obd_size current_grant, - obd_size want, obd_size fs_space_left); + obd_size want, obd_size fs_space_left, int conservative); void filter_grant_commit(struct obd_export *exp, int niocount, struct niobuf_local *res); +void filter_grant_incoming(struct obd_export *exp, struct obdo *oa); struct filter_iobuf *filter_alloc_iobuf(struct filter_obd *, int rw, int num_pages); void filter_free_iobuf(struct filter_iobuf *iobuf); @@ -209,6 +252,7 @@ void filter_tally(struct obd_export *exp, struct page **pages, int nr_pages, unsigned long *blocks, int blocks_per_page, int wr); int lproc_filter_attach_seqstat(struct obd_device *dev); void lprocfs_filter_init_vars(struct lprocfs_static_vars *lvars); +void filter_stats_counter_init(struct lprocfs_stats *stats); #else static inline void filter_tally(struct obd_export *exp, struct page **pages, int nr_pages, unsigned long *blocks, @@ -218,24 +262,32 @@ static void lprocfs_filter_init_vars(struct lprocfs_static_vars *lvars) { memset(lvars, 0, sizeof(*lvars)); } +static inline void filter_stats_counter_init(struct lprocfs_stats *stats) {} #endif /* Quota stuff */ extern quota_interface_t *filter_quota_interface_ref; -/* Capability */ -static inline __u64 obdo_mdsno(struct obdo *oa) -{ - return oa->o_gr - FILTER_GROUP_MDS0; -} - int filter_update_capa_key(struct obd_device *obd, struct lustre_capa_key *key); -int filter_auth_capa(struct obd_export *exp, struct lu_fid *fid, __u64 mdsid, +int filter_auth_capa(struct obd_export *exp, struct lu_fid *fid, obd_seq seq, struct lustre_capa *capa, __u64 opc); +int filter_capa_fixoa(struct obd_export *exp, struct obdo *oa, obd_seq seq, + struct lustre_capa *capa); void filter_free_capa_keys(struct filter_obd *filter); void blacklist_add(uid_t uid); void blacklist_del(uid_t uid); int blacklist_display(char *buf, int bufsize); +/* sync on lock cancel is useless when we force a journal flush, + * and if we enable async journal commit, we should also turn on + * sync on lock cancel if it is not enabled already. */ +static inline void filter_slc_set(struct filter_obd *filter) +{ + if (filter->fo_syncjournal == 1) + filter->fo_sync_lock_cancel = NEVER_SYNC_ON_CANCEL; + else if (filter->fo_sync_lock_cancel == NEVER_SYNC_ON_CANCEL) + filter->fo_sync_lock_cancel = ALWAYS_SYNC_ON_CANCEL; +} + #endif /* _FILTER_INTERNAL_H */