X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Finclude%2Fobd.h;h=bf14b7d24e684b2be8d3ea665ec1d358ff6a4a5f;hp=7b50f69042c57000152bec770cd2819b7df62337;hb=586e95a5b3f7b9525d78e7efc9f2949387fc9d54;hpb=1bdf0d6fcbe11efdf67ebdb09f04955b9ce88de4 diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 7b50f69..bf14b7d 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -27,7 +27,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2012, Intel Corporation. + * Copyright (c) 2011, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -57,18 +57,18 @@ #define IOC_MDC_MAX_NR 50 #include +#include +#include #ifdef HAVE_SERVER_SUPPORT # include +# include #endif #include -#include #include +#include #include #include -#include - - #define MAX_OBD_DEVICES 8192 struct osc_async_rc { @@ -78,17 +78,15 @@ struct osc_async_rc { }; struct lov_oinfo { /* per-stripe data structure */ - struct ost_id loi_oi; /* object ID/Sequence on the target OST */ - int loi_ost_idx; /* OST stripe index in lov_tgt_desc->tgts */ - int loi_ost_gen; /* generation of this loi_ost_idx */ - - unsigned long loi_kms_valid:1; - __u64 loi_kms; /* known minimum size */ - struct ost_lvb loi_lvb; - struct osc_async_rc loi_ar; + struct ost_id loi_oi; /* object ID/Sequence on the target OST */ + int loi_ost_idx; /* OST stripe index in lov_tgt_desc->tgts */ + int loi_ost_gen; /* generation of this loi_ost_idx */ + + unsigned long loi_kms_valid:1; + __u64 loi_kms; /* known minimum size */ + struct ost_lvb loi_lvb; + struct osc_async_rc loi_ar; }; -#define loi_id loi_oi.oi_id -#define loi_seq loi_oi.oi_seq static inline void loi_kms_set(struct lov_oinfo *oinfo, __u64 kms) { @@ -110,7 +108,7 @@ struct lov_stripe_md { __u64 lsm_maxbytes; struct { /* Public members. */ - struct ost_id lw_object_oid; /* lov object id/seq */ + struct ost_id lw_object_oi; /* lov object id/seq */ /* LOV-private members start here -- only for use in lov/. */ __u32 lw_magic; @@ -124,9 +122,7 @@ struct lov_stripe_md { struct lov_oinfo *lsm_oinfo[0]; }; -#define lsm_object_oid lsm_wire.lw_object_oid -#define lsm_object_id lsm_wire.lw_object_oid.oi_id -#define lsm_object_seq lsm_wire.lw_object_oid.oi_seq +#define lsm_oi lsm_wire.lw_object_oi #define lsm_magic lsm_wire.lw_magic #define lsm_layout_gen lsm_wire.lw_layout_gen #define lsm_stripe_size lsm_wire.lw_stripe_size @@ -134,6 +130,20 @@ struct lov_stripe_md { #define lsm_stripe_count lsm_wire.lw_stripe_count #define lsm_pool_name lsm_wire.lw_pool_name +static inline bool lsm_is_released(struct lov_stripe_md *lsm) +{ + return !!(lsm->lsm_pattern & LOV_PATTERN_F_RELEASED); +} + +static inline bool lsm_has_objects(struct lov_stripe_md *lsm) +{ + if (lsm == NULL) + return false; + if (lsm_is_released(lsm)) + return false; + return true; +} + struct obd_info; typedef int (*obd_enqueue_update_f)(void *cookie, int rc); @@ -205,32 +215,32 @@ static inline int lov_lum_lsm_cmp(struct lov_user_md *lum, } static inline int lov_lum_swab_if_needed(struct lov_user_md_v3 *lumv3, - int *lmm_magic, - struct lov_user_md *lum) + int *lmm_magic, + struct lov_user_md *lum) { - if (lum && cfs_copy_from_user(lumv3, lum,sizeof(struct lov_user_md_v1))) - return -EFAULT; - - *lmm_magic = lumv3->lmm_magic; - - if (*lmm_magic == __swab32(LOV_USER_MAGIC_V1)) { - lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lumv3); - *lmm_magic = LOV_USER_MAGIC_V1; - } else if (*lmm_magic == LOV_USER_MAGIC_V3) { - if (lum && cfs_copy_from_user(lumv3, lum, sizeof(*lumv3))) - return -EFAULT; - } else if (*lmm_magic == __swab32(LOV_USER_MAGIC_V3)) { - if (lum && cfs_copy_from_user(lumv3, lum, sizeof(*lumv3))) - return -EFAULT; - lustre_swab_lov_user_md_v3(lumv3); - *lmm_magic = LOV_USER_MAGIC_V3; - } else if (*lmm_magic != LOV_USER_MAGIC_V1) { - CDEBUG(D_IOCTL, - "bad userland LOV MAGIC: %#08x != %#08x nor %#08x\n", - *lmm_magic, LOV_USER_MAGIC_V1, LOV_USER_MAGIC_V3); - return -EINVAL; - } - return 0; + if (lum && copy_from_user(lumv3, lum, sizeof(struct lov_user_md_v1))) + return -EFAULT; + + *lmm_magic = lumv3->lmm_magic; + + if (*lmm_magic == __swab32(LOV_USER_MAGIC_V1)) { + lustre_swab_lov_user_md_v1((struct lov_user_md_v1 *)lumv3); + *lmm_magic = LOV_USER_MAGIC_V1; + } else if (*lmm_magic == LOV_USER_MAGIC_V3) { + if (lum && copy_from_user(lumv3, lum, sizeof(*lumv3))) + return -EFAULT; + } else if (*lmm_magic == __swab32(LOV_USER_MAGIC_V3)) { + if (lum && copy_from_user(lumv3, lum, sizeof(*lumv3))) + return -EFAULT; + lustre_swab_lov_user_md_v3(lumv3); + *lmm_magic = LOV_USER_MAGIC_V3; + } else if (*lmm_magic != LOV_USER_MAGIC_V1) { + CDEBUG(D_IOCTL, + "bad userland LOV MAGIC: %#08x != %#08x nor %#08x\n", + *lmm_magic, LOV_USER_MAGIC_V1, LOV_USER_MAGIC_V3); + return -EINVAL; + } + return 0; } void lov_stripe_lock(struct lov_stripe_md *md); @@ -248,149 +258,31 @@ struct obd_type { }; struct brw_page { - obd_off off; - cfs_page_t *pg; - int count; - obd_flag flag; -}; - -/* Individual type definitions */ - -struct ost_server_data; - -struct osd_properties { - size_t osd_max_ea_size; -}; - -#define OBT_MAGIC 0xBDDECEAE -/* hold common fields for "target" device */ -struct obd_device_target { - __u32 obt_magic; - __u32 obt_instance; - struct super_block *obt_sb; - /** last_rcvd file */ - struct file *obt_rcvd_filp; -#ifdef HAVE_SERVER_SUPPORT - struct lu_target *obt_lut; -#endif - __u64 obt_mount_count; - struct rw_semaphore obt_rwsem; - struct vfsmount *obt_vfsmnt; - struct file *obt_health_check_filp; - struct osd_properties obt_osd_properties; - struct obd_job_stats obt_jobstats; + obd_off off; + struct page *pg; + int count; + obd_flag flag; }; /* llog contexts */ enum llog_ctxt_id { - LLOG_CONFIG_ORIG_CTXT = 0, - LLOG_CONFIG_REPL_CTXT, - LLOG_MDS_OST_ORIG_CTXT, - LLOG_MDS_OST_REPL_CTXT, - LLOG_SIZE_ORIG_CTXT, - LLOG_SIZE_REPL_CTXT, - LLOG_RD1_ORIG_CTXT, - LLOG_RD1_REPL_CTXT, - LLOG_TEST_ORIG_CTXT, - LLOG_TEST_REPL_CTXT, - LLOG_LOVEA_ORIG_CTXT, - LLOG_LOVEA_REPL_CTXT, - LLOG_CHANGELOG_ORIG_CTXT, /**< changelog generation on mdd */ - LLOG_CHANGELOG_REPL_CTXT, /**< changelog access on clients */ - LLOG_CHANGELOG_USER_ORIG_CTXT, /**< for multiple changelog consumers */ - LLOG_MAX_CTXTS -}; - -#define FILTER_SUBDIR_COUNT 32 /* set to zero for no subdirs */ - -struct filter_subdirs { - cfs_dentry_t *dentry[FILTER_SUBDIR_COUNT]; -}; - - -struct filter_ext { - __u64 fe_start; - __u64 fe_end; -}; - -struct filter_obd { - /* NB this field MUST be first */ - struct obd_device_target fo_obt; - const char *fo_fstype; - - int fo_group_count; - cfs_dentry_t *fo_dentry_O; - cfs_dentry_t **fo_dentry_O_groups; - struct filter_subdirs *fo_dentry_O_sub; - struct mutex fo_init_lock; /* group initialization lock*/ - int fo_committed_group; - - spinlock_t fo_objidlock; /* protect fo_lastobjid */ - - unsigned long fo_destroys_in_progress; - struct mutex fo_create_locks[FILTER_SUBDIR_COUNT]; - - cfs_list_t fo_export_list; - int fo_subdir_count; - - obd_size fo_tot_dirty; /* protected by obd_osfs_lock */ - obd_size fo_tot_granted; /* all values in bytes */ - obd_size fo_tot_pending; - int fo_tot_granted_clients; - - obd_size fo_readcache_max_filesize; - spinlock_t fo_flags_lock; - unsigned int fo_read_cache:1, /**< enable read-only cache */ - fo_writethrough_cache:1,/**< read cache writes */ - fo_mds_ost_sync:1, /**< MDS-OST orphan recovery*/ - fo_raid_degraded:1;/**< RAID device degraded */ - - struct obd_import *fo_mdc_imp; - struct obd_uuid fo_mdc_uuid; - struct lustre_handle fo_mdc_conn; - struct file **fo_last_objid_files; - __u64 *fo_last_objids; /* last created objid for groups, - * protected by fo_objidlock */ - - struct mutex fo_alloc_lock; - - cfs_atomic_t fo_r_in_flight; - cfs_atomic_t fo_w_in_flight; - - /* - * per-filter pool of kiobuf's allocated by filter_common_setup() and - * torn down by filter_cleanup(). - * - * This pool contains kiobuf used by - * filter_{prep,commit}rw_{read,write}() and is shared by all OST - * threads. - * - * Locking: protected by internal lock of cfs_hash, pool can be - * found from this hash table by t_id of ptlrpc_thread. - */ - struct cfs_hash *fo_iobuf_hash; - - cfs_list_t fo_llog_list; - spinlock_t fo_llog_list_lock; - - struct brw_stats fo_filter_stats; - - int fo_fmd_max_num; /* per exp filter_mod_data */ - int fo_fmd_max_age; /* jiffies to fmd expiry */ - unsigned long fo_syncjournal:1, /* sync journal on writes */ - fo_sync_lock_cancel:2;/* sync on lock cancel */ - - - /* sptlrpc stuff */ - rwlock_t fo_sptlrpc_lock; - struct sptlrpc_rule_set fo_sptlrpc_rset; - - /* capability related */ - unsigned int fo_fl_oss_capa; - cfs_list_t fo_capa_keys; - cfs_hlist_head_t *fo_capa_hash; - struct llog_commit_master *fo_lcm; - int fo_sec_level; + LLOG_CONFIG_ORIG_CTXT = 0, + LLOG_CONFIG_REPL_CTXT, + LLOG_MDS_OST_ORIG_CTXT, + LLOG_MDS_OST_REPL_CTXT, + LLOG_SIZE_ORIG_CTXT, + LLOG_SIZE_REPL_CTXT, + LLOG_RD1_ORIG_CTXT, + LLOG_RD1_REPL_CTXT, + LLOG_TEST_ORIG_CTXT, + LLOG_TEST_REPL_CTXT, + LLOG_LOVEA_ORIG_CTXT, + LLOG_LOVEA_REPL_CTXT, + LLOG_CHANGELOG_ORIG_CTXT, /**< changelog generation on mdd */ + LLOG_CHANGELOG_REPL_CTXT, /**< changelog access on clients */ + LLOG_CHANGELOG_USER_ORIG_CTXT, /**< for multiple changelog consumers */ + LLOG_AGENT_ORIG_CTXT, /**< agent requests generation on cdt */ + LLOG_MAX_CTXTS }; struct timeout_item { @@ -437,9 +329,6 @@ struct client_obd { enum lustre_sec_part cl_sp_to; struct sptlrpc_flavor cl_flvr_mgc; /* fixed flavor of mgc->mgs */ - //struct llog_canceld_ctxt *cl_llcd; /* it's included by obd_llog_ctxt */ - void *cl_llcd_offset; - /* the grant values are protected by loi_list_lock below */ long cl_dirty; /* all _dirty_ in bytes */ long cl_dirty_max; /* allowed w/o rpc */ @@ -458,7 +347,7 @@ struct client_obd { int cl_grant_shrink_interval; /* seconds */ /* A chunk is an optimal size used by osc_extent to determine - * the extent size. A chunk is max(CFS_PAGE_SIZE, OST block size) */ + * the extent size. A chunk is max(PAGE_CACHE_SIZE, OST block size) */ int cl_chunkbits; int cl_chunk; int cl_extent_tax; /* extent overhead, by bytes */ @@ -494,7 +383,7 @@ struct client_obd { /* just a sum of the loi/lop pending numbers to be exported by /proc */ cfs_atomic_t cl_pending_w_pages; cfs_atomic_t cl_pending_r_pages; - int cl_max_pages_per_rpc; + __u32 cl_max_pages_per_rpc; int cl_max_rpcs_in_flight; struct obd_histogram cl_read_rpc_hist; struct obd_histogram cl_write_rpc_hist; @@ -515,15 +404,15 @@ struct client_obd { /* number of in flight destroy rpcs is limited to max_rpcs_in_flight */ cfs_atomic_t cl_destroy_in_flight; - cfs_waitq_t cl_destroy_waitq; + wait_queue_head_t cl_destroy_waitq; struct mdc_rpc_lock *cl_rpc_lock; struct mdc_rpc_lock *cl_close_lock; /* mgc datastruct */ struct semaphore cl_mgc_sem; - struct vfsmount *cl_mgc_vfsmnt; - struct dentry *cl_mgc_configs_dir; + struct local_oid_storage *cl_mgc_los; + struct dt_object *cl_mgc_configs_dir; cfs_atomic_t cl_mgc_refcount; struct obd_export *cl_mgc_mgsexp; @@ -561,25 +450,6 @@ struct obd_id_info { obd_id *data; }; -/* */ - -struct echo_obd { - struct obd_device_target eo_obt; - struct obdo eo_oa; - spinlock_t eo_lock; - __u64 eo_lastino; - struct lustre_handle eo_nl_lock; - cfs_atomic_t eo_prep; -}; - -struct ost_obd { - struct ptlrpc_service *ost_service; - struct ptlrpc_service *ost_create_service; - struct ptlrpc_service *ost_io_service; - struct ptlrpc_service *ost_seq_service; - struct mutex ost_health_mutex; -}; - struct echo_client_obd { struct obd_export *ec_exp; /* the local connection to osc/lov */ spinlock_t ec_lock; @@ -647,10 +517,10 @@ struct lov_qos { lq_reset:1, /* zero current penalties */ lq_statfs_in_progress:1; /* statfs op in progress */ - /* qos statfs data */ - struct lov_statfs_data *lq_statfs_data; - cfs_waitq_t lq_statfs_waitq; /* waitqueue to notify statfs - * requests completion */ + /* qos statfs data */ + struct lov_statfs_data *lq_statfs_data; + wait_queue_head_t lq_statfs_waitq; /* waitqueue to notify statfs + * requests completion */ }; struct lov_tgt_desc { @@ -703,8 +573,10 @@ struct lov_obd { cfs_proc_dir_entry_t *lov_pool_proc_entry; enum lustre_sec_part lov_sp_me; - /* Cached LRU pages from upper layer */ + /* Cached LRU and unstable data from upper layer */ void *lov_cache; + + struct rw_semaphore lov_notify_lock; }; struct lmv_tgt_desc { @@ -747,14 +619,14 @@ struct lmv_obd { }; struct niobuf_local { - __u64 lnb_file_offset; - __u32 lnb_page_offset; - __u32 len; - __u32 flags; - cfs_page_t *page; - cfs_dentry_t *dentry; - int lnb_grant_used; - int rc; + __u64 lnb_file_offset; + __u32 lnb_page_offset; + __u32 len; + __u32 flags; + struct page *page; + struct dentry *dentry; + int lnb_grant_used; + int rc; }; #define LUSTRE_FLD_NAME "fld" @@ -837,7 +709,7 @@ struct obd_trans_info { struct llog_cookie *oti_logcookies; int oti_numcookies; /** synchronous write is needed */ - long oti_sync_write:1; + unsigned long oti_sync_write:1; /* initial thread handling transaction */ struct ptlrpc_thread * oti_thread; @@ -956,45 +828,11 @@ struct target_recovery_data { struct completion trd_finishing; }; -/** - * In HEAD for CMD, the object is created in group number which is 3>= - * or indexing starts from 3. To test this assertions are added to disallow - * group 0. But to run 2.0 mds server on 1.8.x disk format (i.e. interop_mode) - * object in group 0 needs to be allowed. - * So for interop mode following changes needs to be done: - * 1. No need to assert on group 0 or allow group 0 - * 2. The group number indexing starts from 0 instead of 3 - */ - -#define LASSERT_SEQ_IS_MDT(seq) LASSERT(fid_seq_is_mdt(seq)) - -static inline __u64 objseq_to_mdsno(obd_seq seq) -{ - LASSERT_SEQ_IS_MDT(seq); - if (seq == FID_SEQ_OST_MDT0) - return 0; - return seq - FID_SEQ_OST_MDT1 + 1; -} - -static inline int mdt_to_obd_objseq(int mdtid) -{ - /** - * MDS0 uses seq 0 pre FID-on-OST, other MDSes will use seq from - * FID_SEQ_OST_MDT1 - */ - if (mdtid) - return FID_SEQ_OST_MDT1 + mdtid - 1; - return 0; -} - struct obd_llog_group { - cfs_list_t olg_list; - int olg_seq; - struct llog_ctxt *olg_ctxts[LLOG_MAX_CTXTS]; - cfs_waitq_t olg_waitq; + int olg_seq; + struct llog_ctxt *olg_ctxts[LLOG_MAX_CTXTS]; + wait_queue_head_t olg_waitq; spinlock_t olg_lock; - struct obd_export *olg_exp; - int olg_initializing; struct mutex olg_cat_processing; }; @@ -1003,35 +841,38 @@ struct obd_llog_group { #define OBD_DEV_BY_DEVNAME 0xffffd0de struct obd_device { - struct obd_type *obd_type; - __u32 obd_magic; + struct obd_type *obd_type; + __u32 obd_magic; /* common and UUID name of this device */ - char obd_name[MAX_OBD_NAME]; - struct obd_uuid obd_uuid; - - struct lu_device *obd_lu_dev; - - int obd_minor; - /* bitfield modification is protected by obd_dev_lock */ - unsigned long obd_attached:1, /* finished attach */ - obd_set_up:1, /* finished setup */ - obd_recovering:1, /* there are recoverable clients */ - obd_abort_recovery:1,/* recovery expired */ - obd_version_recov:1, /* obd uses version checking */ - obd_replayable:1, /* recovery is enabled; inform clients */ - obd_no_transno:1, /* no committed-transno notification */ - obd_no_recov:1, /* fail instead of retry messages */ - obd_stopping:1, /* started cleanup */ - obd_starting:1, /* started setup */ - obd_force:1, /* cleanup with > 0 obd refcount */ - obd_fail:1, /* cleanup with failover */ - obd_async_recov:1, /* allow asynchronous orphan cleanup */ - obd_no_conn:1, /* deny new connections */ - obd_inactive:1, /* device active/inactive - * (for /proc/status only!!) */ - obd_no_ir:1, /* no imperative recovery. */ - obd_process_conf:1; /* device is processing mgs config */ + char obd_name[MAX_OBD_NAME]; + struct obd_uuid obd_uuid; + int obd_minor; + struct lu_device *obd_lu_dev; + + /* bitfield modification is protected by obd_dev_lock */ + unsigned long + obd_attached:1, /* finished attach */ + obd_set_up:1, /* finished setup */ + obd_recovering:1, /* there are recoverable clients */ + obd_abort_recovery:1, /* recovery expired */ + obd_version_recov:1, /* obd uses version checking */ + obd_replayable:1, /* recovery is enabled; + * inform clients */ + obd_no_transno:1, /* no committed-transno notification */ + obd_no_recov:1, /* fail instead of retry messages */ + obd_stopping:1, /* started cleanup */ + obd_starting:1, /* started setup */ + obd_force:1, /* cleanup with > 0 obd refcount */ + obd_fail:1, /* cleanup with failover */ + obd_async_recov:1, /* allow asynchronous orphan cleanup */ + obd_no_conn:1, /* deny new connections */ + obd_inactive:1, /* device active/inactive + * (for /proc/status only!!) */ + obd_no_ir:1, /* no imperative recovery. */ + obd_process_conf:1, /* device is processing mgs config */ + obd_uses_nid_stats:1; /* maintain per-client OBD stats */ + /* use separate field as it is set in interrupt to don't mess with * protection of other bits using _bh lock */ unsigned long obd_recovery_expired:1; @@ -1043,7 +884,6 @@ struct obd_device { cfs_hash_t *obd_nid_stats_hash; cfs_list_t obd_nid_stats; cfs_atomic_t obd_refcount; - cfs_waitq_t obd_refcount_waitq; cfs_list_t obd_exports; cfs_list_t obd_unlinked_exports; cfs_list_t obd_delayed_exports; @@ -1055,7 +895,6 @@ struct obd_device { spinlock_t obd_dev_lock; /* protect OBD bitfield above */ struct mutex obd_dev_mutex; __u64 obd_last_committed; - struct fsfilt_operations *obd_fsops; spinlock_t obd_osfs_lock; struct obd_statfs obd_osfs; /* locked by obd_osfs_lock */ __u64 obd_osfs_age; @@ -1077,16 +916,16 @@ struct obd_device { * obd_next_recovery_transno value */ spinlock_t obd_recovery_task_lock; __u64 obd_next_recovery_transno; - int obd_replayed_requests; - int obd_requests_queued_for_recovery; - cfs_waitq_t obd_next_transno_waitq; - /* protected by obd_recovery_task_lock */ - cfs_timer_t obd_recovery_timer; - time_t obd_recovery_start; /* seconds */ - time_t obd_recovery_end; /* seconds, for lprocfs_status */ - int obd_recovery_time_hard; - int obd_recovery_timeout; - int obd_recovery_ir_factor; + int obd_replayed_requests; + int obd_requests_queued_for_recovery; + wait_queue_head_t obd_next_transno_waitq; + /* protected by obd_recovery_task_lock */ + struct timer_list obd_recovery_timer; + time_t obd_recovery_start; /* seconds */ + time_t obd_recovery_end; /* seconds, for lprocfs_status */ + int obd_recovery_time_hard; + int obd_recovery_timeout; + int obd_recovery_ir_factor; /* new recovery stuff from CMD2 */ struct target_recovery_data obd_recovery_data; @@ -1097,32 +936,33 @@ struct obd_device { cfs_list_t obd_req_replay_queue; cfs_list_t obd_lock_replay_queue; cfs_list_t obd_final_req_queue; - int obd_recovery_stage; - - union { - struct obd_device_target obt; - struct filter_obd filter; - struct client_obd cli; - struct ost_obd ost; - struct echo_client_obd echo_client; - struct echo_obd echo; - struct lov_obd lov; - struct lmv_obd lmv; - } u; - /* Fields used by LProcFS */ - unsigned int obd_cntr_base; - struct lprocfs_stats *obd_stats; - - unsigned int md_cntr_base; - struct lprocfs_stats *md_stats; + + union { +#ifdef HAVE_SERVER_SUPPORT + struct obd_device_target obt; + struct filter_obd filter; + struct ost_obd ost; + struct echo_obd echo; +#endif + struct client_obd cli; + struct echo_client_obd echo_client; + struct lov_obd lov; + struct lmv_obd lmv; + } u; + /* Fields used by LProcFS */ + unsigned int obd_cntr_base; + struct lprocfs_stats *obd_stats; + + unsigned int obd_md_cntr_base; + struct lprocfs_stats *obd_md_stats; cfs_proc_dir_entry_t *obd_proc_entry; cfs_proc_dir_entry_t *obd_proc_exports_entry; cfs_proc_dir_entry_t *obd_svc_procroot; struct lprocfs_stats *obd_svc_stats; - cfs_atomic_t obd_evict_inprogress; - cfs_waitq_t obd_evict_inprogress_waitq; - cfs_list_t obd_evict_list; /* protected with pet_lock */ + cfs_atomic_t obd_evict_inprogress; + wait_queue_head_t obd_evict_inprogress_waitq; + cfs_list_t obd_evict_list; /* protected with pet_lock */ /** * Ldlm pool part. Save last calculated SLV and Limit. @@ -1188,6 +1028,7 @@ enum obd_cleanup_stage { #define KEY_CACHE_SET "cache_set" #define KEY_CACHE_LRU_SHRINK "cache_lru_shrink" +#define KEY_CHANGELOG_INDEX "changelog_index" struct lu_context; @@ -1205,6 +1046,7 @@ struct lu_context; #define IT_LAYOUT (1 << 10) #define IT_QUOTA_DQACQ (1 << 11) #define IT_QUOTA_CONN (1 << 12) +#define IT_SETXATTR (1 << 13) static inline int it_to_lock_mode(struct lookup_intent *it) { @@ -1214,6 +1056,10 @@ static inline int it_to_lock_mode(struct lookup_intent *it) else if (it->it_op & (IT_READDIR | IT_GETATTR | IT_OPEN | IT_LOOKUP | IT_LAYOUT)) return LCK_CR; + else if (it->it_op & IT_GETXATTR) + return LCK_PR; + else if (it->it_op & IT_SETXATTR) + return LCK_PW; LASSERTF(0, "Invalid it_op: %d\n", it->it_op); return -EINVAL; @@ -1243,26 +1089,41 @@ struct md_op_data { #ifdef __KERNEL__ unsigned int op_attr_flags; #endif - __u64 op_valid; - loff_t op_attr_blocks; + __u64 op_valid; + loff_t op_attr_blocks; + + /* Size-on-MDS epoch and flags. */ + __u64 op_ioepoch; + __u32 op_flags; + + /* Capa fields */ + struct obd_capa *op_capa1; + struct obd_capa *op_capa2; + + /* Various operation flags. */ + enum mds_op_bias op_bias; - /* Size-on-MDS epoch and flags. */ - __u64 op_ioepoch; - __u32 op_flags; + /* Operation type */ + __u32 op_opc; - /* Capa fields */ - struct obd_capa *op_capa1; - struct obd_capa *op_capa2; + /* Used by readdir */ + __u64 op_offset; - /* Various operation flags. */ - __u32 op_bias; + /* Used by readdir */ + __u32 op_npages; - /* Operation type */ - __u32 op_opc; + /* used to transfer info between the stacks of MD client + * see enum op_cli_flags */ + __u32 op_cli_flags; - /* Used by readdir */ - __u32 op_npages; - __u64 op_offset; + /* File object data version for HSM release, on client */ + __u64 op_data_version; + struct lustre_handle op_lease_handle; +}; + +enum op_cli_flags { + CLI_SET_MEA = 1 << 0, + CLI_RM_ENTRY = 1 << 1, }; struct md_enqueue_info; @@ -1271,12 +1132,6 @@ typedef int (* md_enqueue_cb_t)(struct ptlrpc_request *req, struct md_enqueue_info *minfo, int rc); -/* seq client type */ -enum lu_cli_type { - LUSTRE_SEQ_METADATA = 1, - LUSTRE_SEQ_DATA -}; - struct md_enqueue_info { struct md_op_data mi_data; struct lookup_intent mi_it; @@ -1288,9 +1143,9 @@ struct md_enqueue_info { }; struct obd_ops { - cfs_module_t *o_owner; - int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len, - void *karg, void *uarg); + struct module *o_owner; + int (*o_iocontrol)(unsigned int cmd, struct obd_export *exp, int len, + void *karg, void *uarg); int (*o_get_info)(const struct lu_env *env, struct obd_export *, __u32 keylen, void *key, __u32 *vallen, void *val, struct lov_stripe_md *lsm); @@ -1500,91 +1355,67 @@ struct md_open_data { struct lookup_intent; struct md_ops { - int (*m_getstatus)(struct obd_export *, struct lu_fid *, - struct obd_capa **); - int (*m_change_cbdata)(struct obd_export *, const struct lu_fid *, - ldlm_iterator_t, void *); - int (*m_find_cbdata)(struct obd_export *, const struct lu_fid *, - ldlm_iterator_t, void *); - int (*m_close)(struct obd_export *, struct md_op_data *, - struct md_open_data *, struct ptlrpc_request **); - int (*m_create)(struct obd_export *, struct md_op_data *, - const void *, int, int, __u32, __u32, cfs_cap_t, - __u64, struct ptlrpc_request **); - int (*m_done_writing)(struct obd_export *, struct md_op_data *, - struct md_open_data *); - int (*m_enqueue)(struct obd_export *, struct ldlm_enqueue_info *, - struct lookup_intent *, struct md_op_data *, - struct lustre_handle *, void *, int, + /* Every operation from MD_STATS_FIRST_OP up to and including + * MD_STATS_LAST_OP will be counted by EXP_MD_OP_INCREMENT() + * and will appear in /proc/fs/lustre/{lmv,mdc}/.../md_stats. + * Operations after MD_STATS_LAST_OP are excluded from stats. + * There are a few reasons for doing this: we prune the 17 + * counters which will be of minimal use in understanding + * metadata utilization, we save memory by allocating 15 + * instead of 32 counters, we save cycles by not counting. + * + * MD_STATS_FIRST_OP must be the first member of md_ops. + */ +#define MD_STATS_FIRST_OP m_close + int (*m_close)(struct obd_export *, struct md_op_data *, + struct md_open_data *, struct ptlrpc_request **); + + int (*m_create)(struct obd_export *, struct md_op_data *, + const void *, int, int, __u32, __u32, cfs_cap_t, + __u64, struct ptlrpc_request **); + + int (*m_enqueue)(struct obd_export *, struct ldlm_enqueue_info *, + struct lookup_intent *, struct md_op_data *, + struct lustre_handle *, void *, int, struct ptlrpc_request **, __u64); - int (*m_getattr)(struct obd_export *, struct md_op_data *, - struct ptlrpc_request **); - int (*m_getattr_name)(struct obd_export *, struct md_op_data *, - struct ptlrpc_request **); - int (*m_intent_lock)(struct obd_export *, struct md_op_data *, - void *, int, struct lookup_intent *, int, - struct ptlrpc_request **, + + int (*m_getattr)(struct obd_export *, struct md_op_data *, + struct ptlrpc_request **); + + int (*m_intent_lock)(struct obd_export *, struct md_op_data *, + void *, int, struct lookup_intent *, int, + struct ptlrpc_request **, ldlm_blocking_callback, __u64); - int (*m_link)(struct obd_export *, struct md_op_data *, - struct ptlrpc_request **); - int (*m_rename)(struct obd_export *, struct md_op_data *, - const char *, int, const char *, int, - struct ptlrpc_request **); - int (*m_is_subdir)(struct obd_export *, const struct lu_fid *, - const struct lu_fid *, - struct ptlrpc_request **); - int (*m_setattr)(struct obd_export *, struct md_op_data *, void *, - int , void *, int, struct ptlrpc_request **, - struct md_open_data **mod); - int (*m_sync)(struct obd_export *, const struct lu_fid *, - struct obd_capa *, struct ptlrpc_request **); - int (*m_readpage)(struct obd_export *, struct md_op_data *, - struct page **, struct ptlrpc_request **); - - int (*m_unlink)(struct obd_export *, struct md_op_data *, - struct ptlrpc_request **); - - int (*m_setxattr)(struct obd_export *, const struct lu_fid *, - struct obd_capa *, obd_valid, const char *, - const char *, int, int, int, __u32, - struct ptlrpc_request **); - - int (*m_getxattr)(struct obd_export *, const struct lu_fid *, - struct obd_capa *, obd_valid, const char *, - const char *, int, int, int, - struct ptlrpc_request **); - - int (*m_init_ea_size)(struct obd_export *, int, int, int); - - int (*m_get_lustre_md)(struct obd_export *, struct ptlrpc_request *, - struct obd_export *, struct obd_export *, - struct lustre_md *); - - int (*m_free_lustre_md)(struct obd_export *, struct lustre_md *); - - int (*m_set_open_replay_data)(struct obd_export *, - struct obd_client_handle *, - struct ptlrpc_request *); - int (*m_clear_open_replay_data)(struct obd_export *, - struct obd_client_handle *); - int (*m_set_lock_data)(struct obd_export *, __u64 *, void *, __u64 *); - ldlm_mode_t (*m_lock_match)(struct obd_export *, __u64, - const struct lu_fid *, ldlm_type_t, - ldlm_policy_data_t *, ldlm_mode_t, - struct lustre_handle *); + int (*m_link)(struct obd_export *, struct md_op_data *, + struct ptlrpc_request **); - int (*m_cancel_unused)(struct obd_export *, const struct lu_fid *, - ldlm_policy_data_t *, ldlm_mode_t, - ldlm_cancel_flags_t flags, void *opaque); - int (*m_renew_capa)(struct obd_export *, struct obd_capa *oc, - renew_capa_cb_t cb); - int (*m_unpack_capa)(struct obd_export *, struct ptlrpc_request *, - const struct req_msg_field *, struct obd_capa **); + int (*m_rename)(struct obd_export *, struct md_op_data *, + const char *, int, const char *, int, + struct ptlrpc_request **); + + int (*m_setattr)(struct obd_export *, struct md_op_data *, void *, + int , void *, int, struct ptlrpc_request **, + struct md_open_data **mod); - int (*m_get_remote_perm)(struct obd_export *, const struct lu_fid *, - struct obd_capa *, __u32, - struct ptlrpc_request **); + int (*m_fsync)(struct obd_export *, const struct lu_fid *, + struct obd_capa *, struct ptlrpc_request **); + + int (*m_readpage)(struct obd_export *, struct md_op_data *, + struct page **, struct ptlrpc_request **); + + int (*m_unlink)(struct obd_export *, struct md_op_data *, + struct ptlrpc_request **); + + int (*m_setxattr)(struct obd_export *, const struct lu_fid *, + struct obd_capa *, obd_valid, const char *, + const char *, int, int, int, __u32, + struct ptlrpc_request **); + + int (*m_getxattr)(struct obd_export *, const struct lu_fid *, + struct obd_capa *, obd_valid, const char *, + const char *, int, int, int, + struct ptlrpc_request **); int (*m_intent_getattr_async)(struct obd_export *, struct md_enqueue_info *, @@ -1592,12 +1423,61 @@ struct md_ops { int (*m_revalidate_lock)(struct obd_export *, struct lookup_intent *, struct lu_fid *, __u64 *bits); +#define MD_STATS_LAST_OP m_revalidate_lock - /* - * NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to - * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a - * wrapper function in include/linux/obd_class.h. - */ + int (*m_getstatus)(struct obd_export *, struct lu_fid *, + struct obd_capa **); + + int (*m_null_inode)(struct obd_export *, const struct lu_fid *); + + int (*m_find_cbdata)(struct obd_export *, const struct lu_fid *, + ldlm_iterator_t, void *); + + int (*m_done_writing)(struct obd_export *, struct md_op_data *, + struct md_open_data *); + + int (*m_getattr_name)(struct obd_export *, struct md_op_data *, + struct ptlrpc_request **); + + int (*m_is_subdir)(struct obd_export *, const struct lu_fid *, + const struct lu_fid *, + struct ptlrpc_request **); + + int (*m_init_ea_size)(struct obd_export *, int, int, int); + + int (*m_get_lustre_md)(struct obd_export *, struct ptlrpc_request *, + struct obd_export *, struct obd_export *, + struct lustre_md *); + + int (*m_free_lustre_md)(struct obd_export *, struct lustre_md *); + + int (*m_set_open_replay_data)(struct obd_export *, + struct obd_client_handle *, + struct ptlrpc_request *); + + int (*m_clear_open_replay_data)(struct obd_export *, + struct obd_client_handle *); + + int (*m_set_lock_data)(struct obd_export *, __u64 *, void *, __u64 *); + + ldlm_mode_t (*m_lock_match)(struct obd_export *, __u64, + const struct lu_fid *, ldlm_type_t, + ldlm_policy_data_t *, ldlm_mode_t, + struct lustre_handle *); + + int (*m_cancel_unused)(struct obd_export *, const struct lu_fid *, + ldlm_policy_data_t *, ldlm_mode_t, + ldlm_cancel_flags_t flags, void *opaque); + + int (*m_renew_capa)(struct obd_export *, struct obd_capa *oc, + renew_capa_cb_t cb); + + int (*m_unpack_capa)(struct obd_export *, struct ptlrpc_request *, + const struct req_msg_field *, struct obd_capa **); + + int (*m_get_remote_perm)(struct obd_export *, const struct lu_fid *, + struct obd_capa *, __u32, + struct ptlrpc_request **); }; struct lsm_operations { @@ -1649,13 +1529,13 @@ static inline struct md_open_data *obd_mod_alloc(void) } #define obd_mod_get(mod) cfs_atomic_inc(&(mod)->mod_refcount) -#define obd_mod_put(mod) \ -({ \ - if (cfs_atomic_dec_and_test(&(mod)->mod_refcount)) { \ - if ((mod)->mod_open_req) \ - ptlrpc_req_finished((mod)->mod_open_req); \ - OBD_FREE_PTR(mod); \ - } \ +#define obd_mod_put(mod) \ +({ \ + if (cfs_atomic_dec_and_test(&(mod)->mod_refcount)) { \ + if ((mod)->mod_open_req) \ + ptlrpc_req_finished((mod)->mod_open_req); \ + OBD_FREE_PTR(mod); \ + } \ }) void obdo_from_inode(struct obdo *dst, struct inode *src, obd_flag valid); @@ -1722,4 +1602,10 @@ bad_format: return false; } +static inline int cli_brw_size(struct obd_device *obd) +{ + LASSERT(obd != NULL); + return obd->u.cli.cl_max_pages_per_rpc << PAGE_CACHE_SHIFT; +} + #endif /* __OBD_H */