From ca0deaa6943849eed198b13f5187db67bd15dedd Mon Sep 17 00:00:00 2001 From: yury Date: Fri, 21 Apr 2006 06:59:00 +0000 Subject: [PATCH] - adopting LMV to 1_4 APIs; - many chnages in LMV to adopt it to new fids, etc. --- lustre/Makefile.in | 2 +- lustre/autoMakefile.am | 2 +- lustre/autoconf/lustre-core.m4 | 2 + lustre/cmm/cmm_device.c | 2 +- lustre/include/linux/lustre_cfg.h | 2 + lustre/include/linux/lustre_idl.h | 271 ++++++++----- lustre/include/linux/lustre_mdc.h | 103 +---- lustre/include/linux/obd.h | 103 ++++- lustre/include/linux/obd_class.h | 477 +++++++++++++++++++--- lustre/ldiskfs/quotafmt_test.c | 2 +- lustre/liblustre/dir.c | 14 +- lustre/liblustre/file.c | 11 +- lustre/liblustre/llite_lib.h | 10 +- lustre/liblustre/namei.c | 29 +- lustre/liblustre/rw.c | 12 +- lustre/liblustre/super.c | 130 +++--- lustre/llite/dcache.c | 12 +- lustre/llite/dir.c | 36 +- lustre/llite/file.c | 48 ++- lustre/llite/llite_close.c | 2 +- lustre/llite/llite_internal.h | 6 +- lustre/llite/llite_lib.c | 83 ++-- lustre/llite/llite_nfs.c | 4 +- lustre/llite/namei.c | 55 +-- lustre/llite/symlink.c | 4 +- lustre/llite/xattr.c | 8 +- lustre/lmv/Makefile.in | 2 +- lustre/lmv/autoMakefile.am | 2 +- lustre/lmv/lmv_fld.c | 2 +- lustre/lmv/lmv_intent.c | 270 +++++++------ lustre/lmv/lmv_internal.h | 71 ++-- lustre/lmv/lmv_obd.c | 643 +++++++++++++----------------- lustre/lmv/{lmv_objmgr.c => lmv_object.c} | 85 ++-- lustre/lov/lov_obd.c | 2 +- lustre/mdc/mdc_internal.h | 120 ++++++ lustre/mdc/mdc_locks.c | 25 +- lustre/mdc/mdc_request.c | 161 ++++---- lustre/mdd/mdd_handler.c | 2 +- lustre/mds/handler.c | 6 +- lustre/mdt/mdt_handler.c | 5 +- lustre/mgc/mgc_request.c | 3 +- lustre/mgs/mgs_handler.c | 2 +- lustre/obdclass/Makefile.in | 2 +- lustre/obdclass/autoMakefile.am | 2 +- lustre/obdclass/class_obd.c | 4 + lustre/obdclass/genops.c | 39 +- lustre/obdclass/llog_obd.c | 4 +- lustre/obdclass/llog_test.c | 2 +- lustre/obdclass/lprocfs_status.c | 77 ++++ lustre/obdclass/mea.c | 91 +++++ lustre/obdecho/echo.c | 2 +- lustre/obdecho/echo_client.c | 2 +- lustre/obdfilter/filter.c | 4 +- lustre/osc/osc_request.c | 4 +- lustre/osd/osd_handler.c | 2 +- lustre/ost/ost_handler.c | 2 +- lustre/quota/quotacheck_test.c | 2 +- lustre/quota/quotactl_test.c | 2 +- 58 files changed, 1923 insertions(+), 1149 deletions(-) rename lustre/lmv/{lmv_objmgr.c => lmv_object.c} (84%) create mode 100644 lustre/obdclass/mea.c diff --git a/lustre/Makefile.in b/lustre/Makefile.in index bddd8f3..f7058c2 100644 --- a/lustre/Makefile.in +++ b/lustre/Makefile.in @@ -10,7 +10,7 @@ subdir-m += obdecho subdir-m += mgc @SERVER_TRUE@subdir-m += mds obdfilter ost mgs mdt cmm mdd osd -@CLIENT_TRUE@subdir-m += mdc llite fld +@CLIENT_TRUE@subdir-m += mdc lmv llite fld @QUOTA_TRUE@subdir-m += quota @INCLUDE_RULES@ diff --git a/lustre/autoMakefile.am b/lustre/autoMakefile.am index 1d54946..272cb89d 100644 --- a/lustre/autoMakefile.am +++ b/lustre/autoMakefile.am @@ -10,7 +10,7 @@ ALWAYS_SUBDIRS := include fid lvfs obdclass ldlm ptlrpc osc lov obdecho \ SERVER_SUBDIRS := ldiskfs obdfilter ost mds mgs mdt cmm mdd osd -CLIENT_SUBDIRS := mdc llite fld +CLIENT_SUBDIRS := mdc lmv llite fld QUOTA_SUBDIRS := quota diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index ad599f7..a1fe35d 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -687,6 +687,8 @@ lustre/lvfs/Makefile lustre/lvfs/autoMakefile lustre/mdc/Makefile lustre/mdc/autoMakefile +lustre/lmv/Makefile +lustre/lmv/autoMakefile lustre/mds/Makefile lustre/mds/autoMakefile lustre/mdt/Makefile diff --git a/lustre/cmm/cmm_device.c b/lustre/cmm/cmm_device.c index 6a148e2..3096a7e 100644 --- a/lustre/cmm/cmm_device.c +++ b/lustre/cmm/cmm_device.c @@ -186,7 +186,7 @@ static int __init cmm_mod_init(void) printk(KERN_INFO "Lustre: Clustered Metadata Manager; info@clusterfs.com\n"); lprocfs_init_vars(cmm, &lvars); - return class_register_type(&cmm_obd_device_ops, lvars.module_vars, + return class_register_type(&cmm_obd_device_ops, NULL, lvars.module_vars, LUSTRE_CMM0_NAME, &cmm_device_type); } diff --git a/lustre/include/linux/lustre_cfg.h b/lustre/include/linux/lustre_cfg.h index 073ac8f..0302cc6 100644 --- a/lustre/include/linux/lustre_cfg.h +++ b/lustre/include/linux/lustre_cfg.h @@ -58,6 +58,8 @@ enum lcfg_command_type { LCFG_LOV_ADD_INA = 0x00ce013, LCFG_ADD_MDC = 0x00cf014, LCFG_DEL_MDC = 0x00cf015, + LCFG_LMV_ADD_OBD = 0x00cf016, + LCFG_LMV_DEL_OBD = 0x00cf017, }; struct lustre_cfg_bufs { diff --git a/lustre/include/linux/lustre_idl.h b/lustre/include/linux/lustre_idl.h index cbdbfa6..1731772 100644 --- a/lustre/include/linux/lustre_idl.h +++ b/lustre/include/linux/lustre_idl.h @@ -42,6 +42,9 @@ #ifdef __KERNEL__ # include # include /* to check for FMODE_EXEC, dev_t, lest we redefine */ +# ifdef CONFIG_FS_POSIX_ACL +# include +# endif #else #ifdef __CYGWIN__ # include @@ -123,6 +126,103 @@ #define LUSTRE_LOG_VERSION 0x00050000 #define LUSTRE_MGS_VERSION 0x00060000 +struct lu_fid { + __u64 f_seq; /* holds fid sequence. Lustre should support 2 ^ 64 + * objects, thus even if one sequence has one object we + * reach this value. */ + __u32 f_oid; /* fid number within its sequence. */ + __u32 f_ver; /* holds fid version. */ +}; + +/* + * fid constants + */ +enum { + LUSTRE_ROOT_FID_SEQ = 1ULL, /* XXX: should go into mkfs. */ + LUSTRE_ROOT_FID_OID = 2UL, /* XXX: should go into mkfs. */ + + /* maximal objects in sequence */ + LUSTRE_FID_SEQ_WIDTH = 10000, + + /* initial fid id value */ + LUSTRE_FID_INIT_OID = 1UL, + + /* shift of version component */ + LUSTRE_FID_VER_SHIFT = (sizeof(((struct lu_fid *)0)->f_ver) * 8) +}; + +/* get object sequence */ +static inline __u64 fid_seq(const struct lu_fid *fid) +{ + return fid->f_seq; +} + +/* get object id */ +static inline __u32 fid_oid(const struct lu_fid *fid) +{ + return fid->f_oid; +} + +/* get object version */ +static inline __u32 fid_ver(const struct lu_fid *fid) +{ + return fid->f_ver; +} + +/* get complex object number (oid + version) */ +static inline __u64 fid_num(const struct lu_fid *fid) +{ + __u64 f_ver = fid_ver(fid); + f_ver = f_ver << LUSTRE_FID_VER_SHIFT; + return f_ver | fid_oid(fid); +} + +static inline int fid_is_sane(const struct lu_fid *fid) +{ + return fid != NULL && fid_seq(fid) != 0 && fid_oid(fid) != 0; +} + +#define DFID3 "["LPU64"/%u:%u]" + +#define PFID3(fid) \ + fid_seq(fid), \ + fid_oid(fid), \ + fid_ver(fid) + +extern void lustre_swab_lu_fid (struct lu_fid *fid); + +static inline int lu_fid_eq(const struct lu_fid *f0, + const struct lu_fid *f1) +{ + /* check that there is no alignment padding */ + CLASSERT(sizeof *f0 == + sizeof f0->f_seq + sizeof f0->f_oid + sizeof f0->f_ver); + return memcmp(f0, f1, sizeof *f0) == 0; +} + +static inline void fid_cpu_to_le(struct lu_fid *fid) +{ + fid->f_seq = cpu_to_le64(fid_seq(fid)); + fid->f_oid = cpu_to_le32(fid_oid(fid)); + fid->f_ver = cpu_to_le32(fid_ver(fid)); +} + +static inline void fid_le_to_cpu(struct lu_fid *fid) +{ + fid->f_seq = le64_to_cpu(fid_seq(fid)); + fid->f_oid = le32_to_cpu(fid_oid(fid)); + fid->f_ver = le32_to_cpu(fid_ver(fid)); +} + +#define MEA_MAGIC_LAST_CHAR 0xb2221ca1 +#define MEA_MAGIC_ALL_CHARS 0xb222a11c + +struct lmv_stripe_md { + __u32 mea_magic; + __u32 mea_count; + __u32 mea_master; + struct lu_fid mea_ids[0]; +}; struct lustre_handle { __u64 cookie; @@ -237,6 +337,8 @@ static inline void lustre_msg_set_op_flags(struct lustre_msg *msg, int flags) #define OBD_CONNECT_TRANSNO 0x800ULL /* replay is sending initial transno */ #define OBD_CONNECT_IBITS 0x1000ULL /* support for inodebits locks */ #define OBD_CONNECT_JOIN 0x2000ULL /* files can be concatenated */ +#define OBD_CONNECT_REAL 0x4000ULL /* show MD stack that real connect is + * performed */ #define OBD_CONNECT_EMPTY 0x80000000ULL /* fake: these are empty connect flags*/ /* also update obd_connect_names[] for lprocfs_rd_connect_flags() */ @@ -359,6 +461,29 @@ struct obdo { extern void lustre_swab_obdo (struct obdo *o); +struct md_op_data { + struct lu_fid fid1; + struct lu_fid fid2; + __u64 mod_time; + const char *name; + int namelen; + __u32 create_mode; + struct lmv_stripe_md *mea1; + struct lmv_stripe_md *mea2; + __u32 suppgids[2]; + + /* part of obdo fields for md stack */ + obd_valid valid; + obd_size size; + obd_blocks blocks; + obd_flag flags; + obd_time mtime; + obd_time atime; + obd_time ctime; +}; + +#define MDS_MODE_DONT_LOCK (1 << 30) +#define MDS_MODE_REPLAY (1 << 31) #define LOV_MAGIC_V1 0x0BD10BD0 #define LOV_MAGIC LOV_MAGIC_V1 @@ -388,40 +513,40 @@ struct lov_mds_md_v1 { /* LOV EA mds/wire data (little-endian) */ struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */ }; -#define OBD_MD_FLID (0x00000001ULL) /* object ID */ -#define OBD_MD_FLATIME (0x00000002ULL) /* access time */ -#define OBD_MD_FLMTIME (0x00000004ULL) /* data modification time */ -#define OBD_MD_FLCTIME (0x00000008ULL) /* change time */ -#define OBD_MD_FLSIZE (0x00000010ULL) /* size */ -#define OBD_MD_FLBLOCKS (0x00000020ULL) /* allocated blocks count */ -#define OBD_MD_FLBLKSZ (0x00000040ULL) /* block size */ -#define OBD_MD_FLMODE (0x00000080ULL) /* access bits (mode & ~S_IFMT) */ -#define OBD_MD_FLTYPE (0x00000100ULL) /* object type (mode & S_IFMT) */ -#define OBD_MD_FLUID (0x00000200ULL) /* user ID */ -#define OBD_MD_FLGID (0x00000400ULL) /* group ID */ -#define OBD_MD_FLFLAGS (0x00000800ULL) /* flags word */ -#define OBD_MD_FLNLINK (0x00002000ULL) /* link count */ -#define OBD_MD_FLGENER (0x00004000ULL) /* generation number */ -#define OBD_MD_FLINLINE (0x00008000ULL) /* inline data */ -#define OBD_MD_FLRDEV (0x00010000ULL) /* device number */ -#define OBD_MD_FLEASIZE (0x00020000ULL) /* extended attribute data */ -#define OBD_MD_LINKNAME (0x00040000ULL) /* symbolic link target */ -#define OBD_MD_FLHANDLE (0x00080000ULL) /* file handle */ -#define OBD_MD_FLCKSUM (0x00100000ULL) /* bulk data checksum */ -#define OBD_MD_FLQOS (0x00200000ULL) /* quality of service stats */ -#define OBD_MD_FLOSCOPQ (0x00400000ULL) /* osc opaque data */ -#define OBD_MD_FLCOOKIE (0x00800000ULL) /* log cancellation cookie */ -#define OBD_MD_FLGROUP (0x01000000ULL) /* group */ -#define OBD_MD_FLFID (0x02000000ULL) /* ->ost write inline fid */ -#define OBD_MD_FLEPOCH (0x04000000ULL) /* ->ost write easize is epoch */ -#define OBD_MD_FLGRANT (0x08000000ULL) /* ost preallocation space grant */ -#define OBD_MD_FLDIREA (0x10000000ULL) /* dir's extended attribute data */ -#define OBD_MD_FLUSRQUOTA (0x20000000ULL) /* over quota flags sent from ost */ -#define OBD_MD_FLGRPQUOTA (0x40000000ULL) /* over quota flags sent from ost */ -#define OBD_MD_FLMODEASIZE (0x80000000ULL) /* EA size will be changed */ - +#define OBD_MD_FLID (0x0000000000000001ULL) /* object ID */ +#define OBD_MD_FLATIME (0x0000000000000002ULL) /* access time */ +#define OBD_MD_FLMTIME (0x0000000000000004ULL) /* data modification time */ +#define OBD_MD_FLCTIME (0x0000000000000008ULL) /* change time */ +#define OBD_MD_FLSIZE (0x0000000000000010ULL) /* size */ +#define OBD_MD_FLBLOCKS (0x0000000000000020ULL) /* allocated blocks count */ +#define OBD_MD_FLBLKSZ (0x0000000000000040ULL) /* block size */ +#define OBD_MD_FLMODE (0x0000000000000080ULL) /* access bits (mode & ~S_IFMT) */ +#define OBD_MD_FLTYPE (0x0000000000000100ULL) /* object type (mode & S_IFMT) */ +#define OBD_MD_FLUID (0x0000000000000200ULL) /* user ID */ +#define OBD_MD_FLGID (0x0000000000000400ULL) /* group ID */ +#define OBD_MD_FLFLAGS (0x0000000000000800ULL) /* flags word */ +#define OBD_MD_FLNLINK (0x0000000000002000ULL) /* link count */ +#define OBD_MD_FLGENER (0x0000000000004000ULL) /* generation number */ +#define OBD_MD_FLINLINE (0x0000000000008000ULL) /* inline data */ +#define OBD_MD_FLRDEV (0x0000000000010000ULL) /* device number */ +#define OBD_MD_FLEASIZE (0x0000000000020000ULL) /* extended attribute data */ +#define OBD_MD_LINKNAME (0x0000000000040000ULL) /* symbolic link target */ +#define OBD_MD_FLHANDLE (0x0000000000080000ULL) /* file handle */ +#define OBD_MD_FLCKSUM (0x0000000000100000ULL) /* bulk data checksum */ +#define OBD_MD_FLQOS (0x0000000000200000ULL) /* quality of service stats */ +#define OBD_MD_FLOSCOPQ (0x0000000000400000ULL) /* osc opaque data */ +#define OBD_MD_FLCOOKIE (0x0000000000800000ULL) /* log cancellation cookie */ +#define OBD_MD_FLGROUP (0x0000000001000000ULL) /* group */ +#define OBD_MD_FLFID (0x0000000002000000ULL) /* ->ost write inline fid */ +#define OBD_MD_FLEPOCH (0x0000000004000000ULL) /* ->ost write easize is epoch */ +#define OBD_MD_FLGRANT (0x0000000008000000ULL) /* ost preallocation space grant */ +#define OBD_MD_FLDIREA (0x0000000010000000ULL) /* dir's extended attribute data */ +#define OBD_MD_FLUSRQUOTA (0x0000000020000000ULL) /* over quota flags sent from ost */ +#define OBD_MD_FLGRPQUOTA (0x0000000040000000ULL) /* over quota flags sent from ost */ +#define OBD_MD_FLMODEASIZE (0x0000000080000000ULL) /* EA size will be changed */ #define OBD_MD_MDS (0x0000000100000000ULL) /* where an inode lives on */ #define OBD_MD_REINT (0x0000000200000000ULL) /* reintegrate oa */ +#define OBD_MD_MEA (0x0000000400000000ULL) /* CMD EA */ #define OBD_MD_FLXATTR (0x0000001000000000ULL) /* xattr */ #define OBD_MD_FLXATTRLS (0x0000002000000000ULL) /* xattr list */ @@ -609,69 +734,6 @@ typedef enum { #define LUSTRE_CONFIG_METASEQ "metaseq" #define LUSTRE_CONFIG_TRANSNO "transno" -struct lu_fid { - __u64 f_seq; /* holds fid sequence. Lustre should support 2 ^ 64 - * objects, thus even if one sequence has one object we - * reach this value. */ - __u32 f_oid; /* fid number within its sequence. */ - __u32 f_ver; /* holds fid version. */ -}; - -/* - * fid constants - */ -enum { - LUSTRE_ROOT_FID_SEQ = 1ULL, /* XXX: should go into mkfs. */ - LUSTRE_ROOT_FID_OID = 2UL, /* XXX: should go into mkfs. */ - - /* maximal objects in sequence */ - LUSTRE_FID_SEQ_WIDTH = 10000, - - /* initial fid id value */ - LUSTRE_FID_INIT_OID = 1UL, - - /* shift of version component */ - LUSTRE_FID_VER_SHIFT = (sizeof(((struct lu_fid *)0)->f_ver) * 8) -}; - -/* get object sequence */ -static inline __u64 fid_seq(const struct lu_fid *fid) -{ - return fid->f_seq; -} - -/* get object id */ -static inline __u32 fid_oid(const struct lu_fid *fid) -{ - return fid->f_oid; -} - -/* get object version */ -static inline __u32 fid_ver(const struct lu_fid *fid) -{ - return fid->f_ver; -} - -/* get complex object number (oid + version) */ -static inline __u64 fid_num(const struct lu_fid *fid) -{ - __u64 f_ver = fid_ver(fid); - f_ver = f_ver << LUSTRE_FID_VER_SHIFT; - return f_ver | fid_oid(fid); -} - -static inline int fid_is_sane(const struct lu_fid *fid) -{ - return fid != NULL && fid_seq(fid) != 0 && fid_oid(fid) != 0; -} - -#define DFID3 "["LPU64"/%u:%u]" - -#define PFID3(fid) \ - fid_seq(fid), \ - fid_oid(fid), \ - fid_ver(fid) - /* temporary stuff for compatibility */ struct ll_fid { __u64 id; /* holds object id */ @@ -683,16 +745,6 @@ struct ll_fid { extern void lustre_swab_ll_fid (struct ll_fid *fid); -extern void lustre_swab_lu_fid (struct lu_fid *fid); - -static inline int lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1) -{ - /* check that there is no alignment padding */ - CLASSERT(sizeof *f0 == - sizeof f0->f_seq + sizeof f0->f_oid + sizeof f0->f_ver); - return memcmp(f0, f1, sizeof *f0) == 0; -} - /* This structure is used for both request and reply. * * If we eventually have separate connect data for different types, which we @@ -785,6 +837,15 @@ struct mds_body { extern void lustre_swab_mds_body (struct mds_body *b); extern void lustre_swab_mdt_body (struct mdt_body *b); +struct lustre_md { + struct mdt_body *body; + struct lov_stripe_md *lsm; + struct lmv_stripe_md *mea; +#ifdef CONFIG_FS_POSIX_ACL + struct posix_acl *posix_acl; +#endif +}; + #define Q_QUOTACHECK 0x800100 #define Q_INITQUOTA 0x800101 /* init slave limits */ #define Q_GETOINFO 0x800102 /* get obd quota info */ diff --git a/lustre/include/linux/lustre_mdc.h b/lustre/include/linux/lustre_mdc.h index fbac1d3..b2787c0 100644 --- a/lustre/include/linux/lustre_mdc.h +++ b/lustre/include/linux/lustre_mdc.h @@ -30,112 +30,13 @@ struct obd_export; struct ptlrpc_request; struct obd_device; -struct lustre_md { - struct mdt_body *body; - struct lov_stripe_md *lsm; -#ifdef CONFIG_FS_POSIX_ACL - struct posix_acl *posix_acl; -#endif -}; - -struct md_op_data { - struct lu_fid fid1; - struct lu_fid fid2; - __u64 mod_time; - const char *name; - int namelen; - __u32 create_mode; - __u32 suppgids[2]; - - obd_valid valid; - obd_size size; - obd_blocks blocks; - obd_flag flags; - obd_time mtime; - obd_time atime; - obd_time ctime; -}; - /* mdc/mdc_locks.c */ int it_disposition(struct lookup_intent *it, int flag); void it_set_disposition(struct lookup_intent *it, int flag); int it_open_error(int phase, struct lookup_intent *it); -void mdc_set_lock_data(__u64 *lockh, void *data); -int mdc_change_cbdata(struct obd_export *exp, struct lu_fid *fid, - ldlm_iterator_t it, void *data); -int mdc_intent_lock(struct obd_export *exp, - struct md_op_data *, - void *lmm, int lmmsize, - struct lookup_intent *, int, - struct ptlrpc_request **reqp, - ldlm_blocking_callback cb_blocking, int extra_lock_flags); -int mdc_enqueue(struct obd_export *exp, - int lock_type, - struct lookup_intent *it, - int lock_mode, - struct md_op_data *op_data, - struct lustre_handle *lockh, - void *lmm, - int lmmlen, - ldlm_completion_callback cb_completion, - ldlm_blocking_callback cb_blocking, - void *cb_data, int extra_lock_flags); /* mdc/mdc_request.c */ -int mdc_init_ea_size(struct obd_export *mdc_exp, struct obd_export *lov_exp); - -int mdc_req2lustre_md(struct ptlrpc_request *req, int offset, - struct obd_export *exp, struct lustre_md *md); -void mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md); - -int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid); -int mdc_getattr(struct obd_export *exp, struct lu_fid *fid, - obd_valid valid, unsigned int ea_size, - struct ptlrpc_request **request); -int mdc_getattr_name(struct obd_export *exp, struct lu_fid *fid, - const char *filename, int namelen, unsigned long valid, - unsigned int ea_size, struct ptlrpc_request **request); -int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, - struct iattr *iattr, void *ea, int ealen, void *ea2, int ea2len, - struct ptlrpc_request **request); -int mdc_setxattr(struct obd_export *exp, struct lu_fid *fid, - obd_valid valid, const char *xattr_name, - const char *input, int input_size, - int output_size, int flags, - struct ptlrpc_request **request); -int mdc_getxattr(struct obd_export *exp, struct lu_fid *fid, - obd_valid valid, const char *xattr_name, - const char *input, int input_size, - int output_size, struct ptlrpc_request **request); -int mdc_open(struct obd_export *exp, obd_id ino, int type, int flags, - struct lov_mds_md *lmm, int lmm_size, struct lustre_handle *fh, - struct ptlrpc_request **); -struct obd_client_handle; -void mdc_set_open_replay_data(struct obd_client_handle *och, - struct ptlrpc_request *open_req); -void mdc_clear_open_replay_data(struct obd_client_handle *och); -int mdc_close(struct obd_export *, struct md_op_data *, struct obd_client_handle *, - struct ptlrpc_request **); -int mdc_readpage(struct obd_export *exp, struct lu_fid *mdc_fid, __u64 offset, - struct page *, struct ptlrpc_request **); -int mdc_create(struct obd_export *exp, struct md_op_data *op_data, - const void *data, int datalen, int mode, __u32 uid, __u32 gid, - __u32 cap_effective, __u64 rdev,struct ptlrpc_request **request); -int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, - struct ptlrpc_request **request); -int mdc_link(struct obd_export *exp, struct md_op_data *op_data, - struct ptlrpc_request **); -int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, - const char *old, int oldlen, const char *new, int newlen, - struct ptlrpc_request **request); -int mdc_sync(struct obd_export *exp, struct lu_fid *fid, - struct ptlrpc_request **); - -int mdc_fld(struct obd_export *exp, struct md_fld *mf, __u32 fld_op); - -int mdc_create_client(struct obd_uuid uuid, struct ptlrpc_client *cl); - -int mdc_llog_process(struct obd_export *, char *logname, llog_cb_t, void *data); -int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data); +int mdc_fld(struct obd_export *exp, struct md_fld *mf, + __u32 fld_op); #endif diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index 6572d56..aedb75f 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -142,7 +142,8 @@ void lov_stripe_unlock(struct lov_stripe_md *md); struct obd_type { struct list_head typ_chain; - struct obd_ops *typ_ops; + struct obd_ops *typ_dt_ops; + struct md_ops *typ_md_ops; struct proc_dir_entry *typ_procroot; char *typ_name; int typ_refcnt; @@ -475,6 +476,30 @@ struct lov_obd { struct lov_tgt_desc *tgts; }; +struct lmv_tgt_desc { + struct obd_uuid uuid; + struct obd_export *ltd_exp; + int active; /* is this target up for requests */ +}; + +struct lmv_obd { + int refcount; + spinlock_t lmv_lock; + struct lmv_desc desc; + struct lmv_tgt_desc *tgts; + struct obd_uuid cluuid; + struct obd_export *exp; + + int tgts_size; + int connected; + int max_easize; + int max_def_easize; + int max_cookiesize; + int server_timeout; + struct semaphore init_sem; + struct obd_connect_data conn_data; +}; + struct niobuf_local { __u64 offset; __u32 len; @@ -498,6 +523,7 @@ struct niobuf_local { #define LUSTRE_FLD0_NAME "fld0" #define LUSTRE_MDC_NAME "mdc" +#define LUSTRE_LMV_NAME "lmv" /* FIXME just the names need to be changed */ #define LUSTRE_OSS_NAME "ost" /*FIXME oss*/ @@ -688,11 +714,17 @@ struct obd_device { struct echo_client_obd echo_client; struct echo_obd echo; struct lov_obd lov; + struct lmv_obd lmv; struct mgs_obd mgs; } 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; + struct proc_dir_entry *obd_svc_procroot; struct lprocfs_stats *obd_svc_stats; }; @@ -889,6 +921,75 @@ struct obd_ops { */ }; +struct md_ops { + int (*m_getstatus)(struct obd_export *, struct lu_fid *); + int (*m_change_cbdata)(struct obd_export *, struct lu_fid *, + ldlm_iterator_t, void *); + int (*m_close)(struct obd_export *, struct md_op_data *, + struct obd_client_handle *, struct ptlrpc_request **); + int (*m_create)(struct obd_export *, struct md_op_data *, + const void *, int, int, __u32, __u32, __u32, + __u64, struct ptlrpc_request **); + int (*m_done_writing)(struct obd_export *, struct md_op_data *); + int (*m_enqueue)(struct obd_export *, int, struct lookup_intent *, + int, struct md_op_data *, struct lustre_handle *, + void *, int, ldlm_completion_callback, + ldlm_blocking_callback, void *, int); + int (*m_getattr)(struct obd_export *, struct lu_fid *, + obd_valid, int, struct ptlrpc_request **); + int (*m_getattr_name)(struct obd_export *, struct lu_fid *, + const char *, int, obd_valid, + int, 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, int); + 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_setattr)(struct obd_export *, struct md_op_data *, + struct iattr *, void *, int , void *, int, + struct ptlrpc_request **); + int (*m_sync)(struct obd_export *, struct lu_fid *, + struct ptlrpc_request **); + int (*m_readpage)(struct obd_export *, struct lu_fid *, + __u64, struct page *, struct ptlrpc_request **); + int (*m_unlink)(struct obd_export *, struct md_op_data *, + struct ptlrpc_request **); + + int (*m_setxattr)(struct obd_export *, struct lu_fid *, + obd_valid, const char *, const char *, + int, int, int, struct ptlrpc_request **); + + int (*m_getxattr)(struct obd_export *, struct lu_fid *, + 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 *, + int, 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 *); + + int (*m_delete)(struct obd_export *, struct lu_fid *); + + /* + * 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. + */ +}; + struct lsm_operations { void (*lsm_free)(struct lov_stripe_md *); int (*lsm_destroy)(struct lov_stripe_md *, struct obdo *oa, diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index c5a1273..da0e647 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -57,8 +57,9 @@ struct lu_device_type; /* genops.c */ struct obd_export *class_conn2export(struct lustre_handle *); -int class_register_type(struct obd_ops *ops, struct lprocfs_vars *, - const char *nm, struct lu_device_type *ldt); +int class_register_type(struct obd_ops *, struct md_ops *, + struct lprocfs_vars *, const char *nm, + struct lu_device_type *ldt); int class_unregister_type(const char *nm); struct obd_device *class_newdev(struct obd_type *type, char *name); @@ -193,7 +194,8 @@ void obdo_to_ioobj(struct obdo *oa, struct obd_ioobj *ioobj); #define OBT(dev) (dev)->obd_type -#define OBP(dev, op) (dev)->obd_type->typ_ops->o_ ## op +#define OBP(dev, op) (dev)->obd_type->typ_dt_ops->o_ ## op +#define MDP(dev, op) (dev)->obd_type->typ_md_ops->m_ ## op #define CTXTP(ctxt, op) (ctxt)->loc_logops->lop_##op /* Ensure obd_setup: used for cleanup which must be called @@ -232,22 +234,67 @@ do { \ LASSERT(coffset < obd->obd_stats->ls_num); \ lprocfs_counter_incr(obd->obd_stats, coffset); \ } + +#define MD_COUNTER_OFFSET(op) \ + ((offsetof(struct md_ops, m_ ## op) - \ + offsetof(struct md_ops, m_getstatus)) \ + / sizeof(((struct md_ops *)(0))->m_getstatus)) + +#define MD_COUNTER_INCREMENT(obd, op) \ + if ((obd)->md_stats != NULL) { \ + unsigned int coffset; \ + coffset = (unsigned int)(obd)->md_cntr_base + \ + MD_COUNTER_OFFSET(op); \ + LASSERT(coffset < (obd)->md_stats->ls_num); \ + lprocfs_counter_incr((obd)->md_stats, coffset); \ + } + #else #define OBD_COUNTER_OFFSET(op) #define OBD_COUNTER_INCREMENT(obd, op) +#define MD_COUNTER_INCREMENT(obd, op) #endif -#define OBD_CHECK_OP(obd, op, err) \ +#define OBD_CHECK_MD_OP(obd, op, err) \ do { \ - if (!OBT(obd) || !OBP((obd), op)) {\ + if (!OBT(obd) || !MDP((obd), op)) { \ + if (err) \ + CERROR("md_" #op ": dev %s/%d no operation\n", \ + obd->obd_name, obd->obd_minor); \ + RETURN(err); \ + } \ +} while (0) + +#define EXP_CHECK_MD_OP(exp, op) \ +do { \ + if ((exp) == NULL) { \ + CERROR("obd_" #op ": NULL export\n"); \ + RETURN(-ENODEV); \ + } \ + if ((exp)->exp_obd == NULL || !OBT((exp)->exp_obd)) { \ + CERROR("obd_" #op ": cleaned up obd\n"); \ + RETURN(-EOPNOTSUPP); \ + } \ + if (!OBT((exp)->exp_obd) || !MDP((exp)->exp_obd, op)) { \ + CERROR("obd_" #op ": dev %s/%d no operation\n", \ + (exp)->exp_obd->obd_name, \ + (exp)->exp_obd->obd_minor); \ + RETURN(-EOPNOTSUPP); \ + } \ +} while (0) + + +#define OBD_CHECK_DT_OP(obd, op, err) \ +do { \ + if (!OBT(obd) || !OBP((obd), op)) { \ if (err) \ CERROR("obd_" #op ": dev %d no operation\n", \ - obd->obd_minor); \ + obd->obd_minor); \ RETURN(err); \ } \ } while (0) -#define EXP_CHECK_OP(exp, op) \ +#define EXP_CHECK_DT_OP(exp, op) \ do { \ if ((exp) == NULL) { \ CERROR("obd_" #op ": NULL export\n"); \ @@ -280,7 +327,7 @@ static inline int obd_get_info(struct obd_export *exp, __u32 keylen, int rc; ENTRY; - EXP_CHECK_OP(exp, get_info); + EXP_CHECK_DT_OP(exp, get_info); OBD_COUNTER_INCREMENT(exp->exp_obd, get_info); rc = OBP(exp->exp_obd, get_info)(exp, keylen, key, vallen, val); @@ -293,7 +340,7 @@ static inline int obd_set_info(struct obd_export *exp, obd_count keylen, int rc; ENTRY; - EXP_CHECK_OP(exp, set_info); + EXP_CHECK_DT_OP(exp, set_info); OBD_COUNTER_INCREMENT(exp->exp_obd, set_info); rc = OBP(exp->exp_obd, set_info)(exp, keylen, key, vallen, val); @@ -318,7 +365,7 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) } else rc = PTR_ERR(d); } else { - OBD_CHECK_OP(obd, setup, -EOPNOTSUPP); + OBD_CHECK_DT_OP(obd, setup, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, setup); rc = OBP(obd, setup)(obd, cfg); } @@ -331,7 +378,7 @@ static inline int obd_precleanup(struct obd_device *obd, int rc; ENTRY; - OBD_CHECK_OP(obd, precleanup, 0); + OBD_CHECK_DT_OP(obd, precleanup, 0); OBD_COUNTER_INCREMENT(obd, precleanup); rc = OBP(obd, precleanup)(obd, cleanup_stage); @@ -354,7 +401,7 @@ static inline int obd_cleanup(struct obd_device *obd) obd->obd_lu_dev = NULL; rc = 0; } else { - OBD_CHECK_OP(obd, cleanup, 0); + OBD_CHECK_DT_OP(obd, cleanup, 0); rc = OBP(obd, cleanup)(obd); } OBD_COUNTER_INCREMENT(obd, cleanup); @@ -370,13 +417,15 @@ obd_process_config(struct obd_device *obd, int datalen, void *data) ENTRY; OBD_CHECK_DEV(obd); + OBD_CHECK_DT_OP(obd, process_config, -EOPNOTSUPP); + OBD_COUNTER_INCREMENT(obd, process_config); ldt = obd->obd_type->typ_lu; d = obd->obd_lu_dev; if (ldt != NULL && d != NULL) { rc = d->ld_ops->ldo_process_config(d, (struct lustre_cfg *)data); } else { - OBD_CHECK_OP(obd, process_config, -EOPNOTSUPP); + OBD_CHECK_DT_OP(obd, process_config, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, process_config); rc = OBP(obd, process_config)(obd, datalen, data); } @@ -397,7 +446,7 @@ static inline int obd_packmd(struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, packmd); + EXP_CHECK_DT_OP(exp, packmd); OBD_COUNTER_INCREMENT(exp->exp_obd, packmd); rc = OBP(exp->exp_obd, packmd)(exp, disk_tgt, mem_src); @@ -442,7 +491,7 @@ static inline int obd_unpackmd(struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, unpackmd); + EXP_CHECK_DT_OP(exp, unpackmd); OBD_COUNTER_INCREMENT(exp->exp_obd, unpackmd); rc = OBP(exp->exp_obd, unpackmd)(exp, mem_tgt, disk_src, disk_len); @@ -473,7 +522,7 @@ static inline int obd_checkmd(struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, checkmd); + EXP_CHECK_DT_OP(exp, checkmd); OBD_COUNTER_INCREMENT(exp->exp_obd, checkmd); rc = OBP(exp->exp_obd, checkmd)(exp, md_exp, mem_tgt); @@ -487,7 +536,7 @@ static inline int obd_create(struct obd_export *exp, struct obdo *obdo, int rc; ENTRY; - EXP_CHECK_OP(exp, create); + EXP_CHECK_DT_OP(exp, create); OBD_COUNTER_INCREMENT(exp->exp_obd, create); rc = OBP(exp->exp_obd, create)(exp, obdo, ea, oti); @@ -502,7 +551,7 @@ static inline int obd_destroy(struct obd_export *exp, struct obdo *obdo, int rc; ENTRY; - EXP_CHECK_OP(exp, destroy); + EXP_CHECK_DT_OP(exp, destroy); OBD_COUNTER_INCREMENT(exp->exp_obd, destroy); rc = OBP(exp->exp_obd, destroy)(exp, obdo, ea, oti, md_exp); @@ -515,7 +564,7 @@ static inline int obd_getattr(struct obd_export *exp, struct obdo *obdo, int rc; ENTRY; - EXP_CHECK_OP(exp, getattr); + EXP_CHECK_DT_OP(exp, getattr); OBD_COUNTER_INCREMENT(exp->exp_obd, getattr); rc = OBP(exp->exp_obd, getattr)(exp, obdo, ea); @@ -529,7 +578,7 @@ static inline int obd_getattr_async(struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, getattr); + EXP_CHECK_DT_OP(exp, getattr); OBD_COUNTER_INCREMENT(exp->exp_obd, getattr); rc = OBP(exp->exp_obd, getattr_async)(exp, obdo, ea, set); @@ -543,7 +592,7 @@ static inline int obd_setattr(struct obd_export *exp, struct obdo *obdo, int rc; ENTRY; - EXP_CHECK_OP(exp, setattr); + EXP_CHECK_DT_OP(exp, setattr); OBD_COUNTER_INCREMENT(exp->exp_obd, setattr); rc = OBP(exp->exp_obd, setattr)(exp, obdo, ea, oti); @@ -558,7 +607,7 @@ static inline int obd_setattr_async(struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, setattr_async); + EXP_CHECK_DT_OP(exp, setattr_async); OBD_COUNTER_INCREMENT(exp->exp_obd, setattr_async); rc = OBP(exp->exp_obd, setattr_async)(exp, obdo, ea, oti); @@ -573,7 +622,7 @@ static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, ENTRY; OBD_CHECK_DEV_ACTIVE(obd); - OBD_CHECK_OP(obd, add_conn, -EOPNOTSUPP); + OBD_CHECK_DT_OP(obd, add_conn, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, add_conn); rc = OBP(obd, add_conn)(imp, uuid, priority); @@ -587,7 +636,7 @@ static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) ENTRY; OBD_CHECK_DEV_ACTIVE(obd); - OBD_CHECK_OP(obd, del_conn, -EOPNOTSUPP); + OBD_CHECK_DT_OP(obd, del_conn, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, del_conn); rc = OBP(obd, del_conn)(imp, uuid); @@ -603,7 +652,7 @@ static inline int obd_connect(struct lustre_handle *conn,struct obd_device *obd, ENTRY; OBD_CHECK_DEV_ACTIVE(obd); - OBD_CHECK_OP(obd, connect, -EOPNOTSUPP); + OBD_CHECK_DT_OP(obd, connect, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, connect); rc = OBP(obd, connect)(conn, obd, cluuid, d); @@ -623,7 +672,7 @@ static inline int obd_reconnect(struct obd_export *exp, ENTRY; OBD_CHECK_DEV_ACTIVE(obd); - OBD_CHECK_OP(obd, reconnect, 0); + OBD_CHECK_DT_OP(obd, reconnect, 0); OBD_COUNTER_INCREMENT(obd, reconnect); rc = OBP(obd, reconnect)(exp, obd, cluuid, d); @@ -638,7 +687,7 @@ static inline int obd_disconnect(struct obd_export *exp) int rc; ENTRY; - EXP_CHECK_OP(exp, disconnect); + EXP_CHECK_DT_OP(exp, disconnect); OBD_COUNTER_INCREMENT(exp->exp_obd, disconnect); rc = OBP(exp->exp_obd, disconnect)(exp); @@ -702,7 +751,7 @@ static inline int obd_statfs(struct obd_device *obd, struct obd_statfs *osfs, if (obd == NULL) RETURN(-EINVAL); - OBD_CHECK_OP(obd, statfs, -EOPNOTSUPP); + OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(obd, statfs); CDEBUG(D_SUPER, "osfs %lu, max_age %lu\n", obd->obd_osfs_age, max_age); @@ -730,7 +779,7 @@ static inline int obd_sync(struct obd_export *exp, struct obdo *oa, int rc; ENTRY; - OBD_CHECK_OP(exp->exp_obd, sync, -EOPNOTSUPP); + OBD_CHECK_DT_OP(exp->exp_obd, sync, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(exp->exp_obd, sync); rc = OBP(exp->exp_obd, sync)(exp, oa, ea, start, end); @@ -744,7 +793,7 @@ static inline int obd_punch(struct obd_export *exp, struct obdo *oa, int rc; ENTRY; - EXP_CHECK_OP(exp, punch); + EXP_CHECK_DT_OP(exp, punch); OBD_COUNTER_INCREMENT(exp->exp_obd, punch); rc = OBP(exp->exp_obd, punch)(exp, oa, ea, start, end, oti); @@ -758,7 +807,7 @@ static inline int obd_brw(int cmd, struct obd_export *exp, struct obdo *oa, int rc; ENTRY; - EXP_CHECK_OP(exp, brw); + EXP_CHECK_DT_OP(exp, brw); OBD_COUNTER_INCREMENT(exp->exp_obd, brw); if (!(cmd & (OBD_BRW_RWMASK | OBD_BRW_CHECK))) { @@ -780,7 +829,7 @@ static inline int obd_brw_async(int cmd, struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, brw_async); + EXP_CHECK_DT_OP(exp, brw_async); OBD_COUNTER_INCREMENT(exp->exp_obd, brw_async); if (!(cmd & OBD_BRW_RWMASK)) { @@ -803,7 +852,7 @@ static inline int obd_prep_async_page(struct obd_export *exp, int ret; ENTRY; - OBD_CHECK_OP(exp->exp_obd, prep_async_page, -EOPNOTSUPP); + OBD_CHECK_DT_OP(exp->exp_obd, prep_async_page, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(exp->exp_obd, prep_async_page); ret = OBP(exp->exp_obd, prep_async_page)(exp, lsm, loi, page, offset, @@ -820,7 +869,7 @@ static inline int obd_queue_async_io(struct obd_export *exp, int rc; ENTRY; - OBD_CHECK_OP(exp->exp_obd, queue_async_io, -EOPNOTSUPP); + OBD_CHECK_DT_OP(exp->exp_obd, queue_async_io, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(exp->exp_obd, queue_async_io); LASSERT(cmd & OBD_BRW_RWMASK); @@ -837,7 +886,7 @@ static inline int obd_set_async_flags(struct obd_export *exp, int rc; ENTRY; - OBD_CHECK_OP(exp->exp_obd, set_async_flags, -EOPNOTSUPP); + OBD_CHECK_DT_OP(exp->exp_obd, set_async_flags, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(exp->exp_obd, set_async_flags); rc = OBP(exp->exp_obd, set_async_flags)(exp, lsm, loi, cookie, @@ -856,7 +905,7 @@ static inline int obd_queue_group_io(struct obd_export *exp, int rc; ENTRY; - OBD_CHECK_OP(exp->exp_obd, queue_group_io, -EOPNOTSUPP); + OBD_CHECK_DT_OP(exp->exp_obd, queue_group_io, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(exp->exp_obd, queue_group_io); LASSERT(cmd & OBD_BRW_RWMASK); @@ -874,7 +923,7 @@ static inline int obd_trigger_group_io(struct obd_export *exp, int rc; ENTRY; - OBD_CHECK_OP(exp->exp_obd, trigger_group_io, -EOPNOTSUPP); + OBD_CHECK_DT_OP(exp->exp_obd, trigger_group_io, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(exp->exp_obd, trigger_group_io); rc = OBP(exp->exp_obd, trigger_group_io)(exp, lsm, loi, oig); @@ -888,7 +937,7 @@ static inline int obd_teardown_async_page(struct obd_export *exp, int rc; ENTRY; - OBD_CHECK_OP(exp->exp_obd, teardown_async_page, -EOPNOTSUPP); + OBD_CHECK_DT_OP(exp->exp_obd, teardown_async_page, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(exp->exp_obd, teardown_async_page); rc = OBP(exp->exp_obd, teardown_async_page)(exp, lsm, loi, cookie); @@ -904,7 +953,7 @@ static inline int obd_preprw(int cmd, struct obd_export *exp, struct obdo *oa, int rc; ENTRY; - OBD_CHECK_OP(exp->exp_obd, preprw, -EOPNOTSUPP); + OBD_CHECK_DT_OP(exp->exp_obd, preprw, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(exp->exp_obd, preprw); rc = OBP(exp->exp_obd, preprw)(cmd, exp, oa, objcount, obj, niocount, @@ -919,7 +968,7 @@ static inline int obd_commitrw(int cmd, struct obd_export *exp, struct obdo *oa, { ENTRY; - OBD_CHECK_OP(exp->exp_obd, commitrw, -EOPNOTSUPP); + OBD_CHECK_DT_OP(exp->exp_obd, commitrw, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(exp->exp_obd, commitrw); rc = OBP(exp->exp_obd, commitrw)(cmd, exp, oa, objcount, obj, niocount, @@ -934,7 +983,7 @@ static inline int obd_merge_lvb(struct obd_export *exp, int rc; ENTRY; - OBD_CHECK_OP(exp->exp_obd, merge_lvb, -EOPNOTSUPP); + OBD_CHECK_DT_OP(exp->exp_obd, merge_lvb, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(exp->exp_obd, merge_lvb); rc = OBP(exp->exp_obd, merge_lvb)(exp, lsm, lvb, kms_only); @@ -948,7 +997,7 @@ static inline int obd_adjust_kms(struct obd_export *exp, int rc; ENTRY; - OBD_CHECK_OP(exp->exp_obd, adjust_kms, -EOPNOTSUPP); + OBD_CHECK_DT_OP(exp->exp_obd, adjust_kms, -EOPNOTSUPP); OBD_COUNTER_INCREMENT(exp->exp_obd, adjust_kms); rc = OBP(exp->exp_obd, adjust_kms)(exp, lsm, size, shrink); @@ -961,7 +1010,7 @@ static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, iocontrol); + EXP_CHECK_DT_OP(exp, iocontrol); OBD_COUNTER_INCREMENT(exp->exp_obd, iocontrol); rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg); @@ -977,7 +1026,7 @@ static inline int obd_enqueue(struct obd_export *exp, struct lov_stripe_md *ea, int rc; ENTRY; - EXP_CHECK_OP(exp, enqueue); + EXP_CHECK_DT_OP(exp, enqueue); OBD_COUNTER_INCREMENT(exp->exp_obd, enqueue); rc = OBP(exp->exp_obd, enqueue)(exp, ea, type, policy, mode, flags, @@ -993,7 +1042,7 @@ static inline int obd_match(struct obd_export *exp, struct lov_stripe_md *ea, int rc; ENTRY; - EXP_CHECK_OP(exp, match); + EXP_CHECK_DT_OP(exp, match); OBD_COUNTER_INCREMENT(exp->exp_obd, match); rc = OBP(exp->exp_obd, match)(exp, ea, type, policy, mode, flags, data, @@ -1008,7 +1057,7 @@ static inline int obd_change_cbdata(struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, change_cbdata); + EXP_CHECK_DT_OP(exp, change_cbdata); OBD_COUNTER_INCREMENT(exp->exp_obd, change_cbdata); rc = OBP(exp->exp_obd, change_cbdata)(exp, lsm, it, data); @@ -1022,7 +1071,7 @@ static inline int obd_cancel(struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, cancel); + EXP_CHECK_DT_OP(exp, cancel); OBD_COUNTER_INCREMENT(exp->exp_obd, cancel); rc = OBP(exp->exp_obd, cancel)(exp, ea, mode, lockh); @@ -1036,7 +1085,7 @@ static inline int obd_cancel_unused(struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, cancel_unused); + EXP_CHECK_DT_OP(exp, cancel_unused); OBD_COUNTER_INCREMENT(exp->exp_obd, cancel_unused); rc = OBP(exp->exp_obd, cancel_unused)(exp, ea, flags, opaque); @@ -1049,7 +1098,7 @@ static inline int obd_join_lru(struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, join_lru); + EXP_CHECK_DT_OP(exp, join_lru); OBD_COUNTER_INCREMENT(exp->exp_obd, join_lru); rc = OBP(exp->exp_obd, join_lru)(exp, ea, join); @@ -1063,7 +1112,7 @@ static inline int obd_san_preprw(int cmd, struct obd_export *exp, { int rc; - EXP_CHECK_OP(exp, preprw); + EXP_CHECK_DT_OP(exp, preprw); OBD_COUNTER_INCREMENT(exp->exp_obd, preprw); rc = OBP(exp->exp_obd, san_preprw)(cmd, exp, oa, objcount, obj, @@ -1077,7 +1126,7 @@ static inline int obd_pin(struct obd_export *exp, struct lu_fid *fid, { int rc; - EXP_CHECK_OP(exp, pin); + EXP_CHECK_DT_OP(exp, pin); OBD_COUNTER_INCREMENT(exp->exp_obd, pin); rc = OBP(exp->exp_obd, pin)(exp, fid, handle, flag); @@ -1089,7 +1138,7 @@ static inline int obd_unpin(struct obd_export *exp, { int rc; - EXP_CHECK_OP(exp, unpin); + EXP_CHECK_DT_OP(exp, unpin); OBD_COUNTER_INCREMENT(exp->exp_obd, unpin); rc = OBP(exp->exp_obd, unpin)(exp, handle, flag); @@ -1169,7 +1218,7 @@ static inline int obd_quotacheck(struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, quotacheck); + EXP_CHECK_DT_OP(exp, quotacheck); OBD_COUNTER_INCREMENT(exp->exp_obd, quotacheck); rc = OBP(exp->exp_obd, quotacheck)(exp, oqctl); @@ -1182,7 +1231,7 @@ static inline int obd_quotactl(struct obd_export *exp, int rc; ENTRY; - EXP_CHECK_OP(exp, quotactl); + EXP_CHECK_DT_OP(exp, quotactl); OBD_COUNTER_INCREMENT(exp->exp_obd, quotactl); rc = OBP(exp->exp_obd, quotactl)(exp, oqctl); @@ -1226,8 +1275,310 @@ static inline int obd_register_observer(struct obd_device *obd, RETURN(0); } -/* OBD Metadata Support */ +/* metadata helpers */ +static inline int md_getstatus(struct obd_export *exp, struct lu_fid *fid) +{ + int rc; + ENTRY; + + EXP_CHECK_MD_OP(exp, getstatus); + MD_COUNTER_INCREMENT(exp->exp_obd, getstatus); + rc = MDP(exp->exp_obd, getstatus)(exp, fid); + RETURN(rc); +} + +static inline int md_delete(struct obd_export *exp, + struct lu_fid *fid) +{ + int rc; + ENTRY; + + if (MDP(exp->exp_obd, delete) == NULL) + RETURN(0); + + MD_COUNTER_INCREMENT(exp->exp_obd, delete); + rc = MDP(exp->exp_obd, delete)(exp, fid); + RETURN(rc); +} + +static inline int md_getattr(struct obd_export *exp, struct lu_fid *fid, + obd_valid valid, int ea_size, + struct ptlrpc_request **request) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, getattr); + MD_COUNTER_INCREMENT(exp->exp_obd, getattr); + rc = MDP(exp->exp_obd, getattr)(exp, fid, valid, + ea_size, request); + RETURN(rc); +} + +static inline int md_change_cbdata(struct obd_export *exp, struct lu_fid *fid, + ldlm_iterator_t it, void *data) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, change_cbdata); + MD_COUNTER_INCREMENT(exp->exp_obd, change_cbdata); + rc = MDP(exp->exp_obd, change_cbdata)(exp, fid, it, data); + RETURN(rc); +} + +static inline int md_close(struct obd_export *exp, + struct md_op_data *op_data, + struct obd_client_handle *och, + struct ptlrpc_request **request) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, close); + MD_COUNTER_INCREMENT(exp->exp_obd, close); + rc = MDP(exp->exp_obd, close)(exp, op_data, och, request); + RETURN(rc); +} + +static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, + const void *data, int datalen, int mode, + __u32 uid, __u32 gid, __u32 cap_effective, __u64 rdev, + struct ptlrpc_request **request) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, create); + MD_COUNTER_INCREMENT(exp->exp_obd, create); + rc = MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode, + uid, gid, cap_effective, rdev, request); + RETURN(rc); +} + +static inline int md_done_writing(struct obd_export *exp, + struct md_op_data *op_data) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, done_writing); + MD_COUNTER_INCREMENT(exp->exp_obd, done_writing); + rc = MDP(exp->exp_obd, done_writing)(exp, op_data); + RETURN(rc); +} + +static inline int md_enqueue(struct obd_export *exp, int lock_type, + struct lookup_intent *it, int lock_mode, + struct md_op_data *op_data, + struct lustre_handle *lockh, + void *lmm, int lmmsize, + ldlm_completion_callback cb_completion, + ldlm_blocking_callback cb_blocking, + void *cb_data, int extra_lock_flags) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, enqueue); + MD_COUNTER_INCREMENT(exp->exp_obd, enqueue); + rc = MDP(exp->exp_obd, enqueue)(exp, lock_type, it, lock_mode, + op_data, lockh, lmm, lmmsize, + cb_completion, cb_blocking, + cb_data, extra_lock_flags); + RETURN(rc); +} + +static inline int md_getattr_name(struct obd_export *exp, struct lu_fid *fid, + const char *filename, int namelen, + obd_valid valid, int ea_size, + struct ptlrpc_request **request) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, getattr_name); + MD_COUNTER_INCREMENT(exp->exp_obd, getattr_name); + rc = MDP(exp->exp_obd, getattr_name)(exp, fid, filename, namelen, + valid, ea_size, request); + RETURN(rc); +} +static inline int md_intent_lock(struct obd_export *exp, + struct md_op_data *op_data, + void *lmm, int lmmsize, + struct lookup_intent *it, + int flags, struct ptlrpc_request **reqp, + ldlm_blocking_callback cb_blocking, + int extra_lock_flags) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, intent_lock); + MD_COUNTER_INCREMENT(exp->exp_obd, intent_lock); + rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, lmm, lmmsize, + it, flags, reqp, cb_blocking, + extra_lock_flags); + RETURN(rc); +} + +static inline int md_link(struct obd_export *exp, + struct md_op_data *op_data, + struct ptlrpc_request **request) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, link); + MD_COUNTER_INCREMENT(exp->exp_obd, link); + rc = MDP(exp->exp_obd, link)(exp, op_data, request); + RETURN(rc); +} + +static inline int md_rename(struct obd_export *exp, + struct md_op_data *op_data, + const char *old, int oldlen, + const char *new, int newlen, + struct ptlrpc_request **request) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, rename); + MD_COUNTER_INCREMENT(exp->exp_obd, rename); + rc = MDP(exp->exp_obd, rename)(exp, op_data, old, oldlen, new, + newlen, request); + RETURN(rc); +} + +static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, + struct iattr *iattr, void *ea, int ealen, + void *ea2, int ea2len, struct ptlrpc_request **request) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, setattr); + MD_COUNTER_INCREMENT(exp->exp_obd, setattr); + rc = MDP(exp->exp_obd, setattr)(exp, op_data, iattr, ea, ealen, + ea2, ea2len, request); + RETURN(rc); +} + +static inline int md_sync(struct obd_export *exp, struct lu_fid *fid, + struct ptlrpc_request **request) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, sync); + MD_COUNTER_INCREMENT(exp->exp_obd, sync); + rc = MDP(exp->exp_obd, sync)(exp, fid, request); + RETURN(rc); +} + +static inline int md_readpage(struct obd_export *exp, struct lu_fid *fid, + __u64 offset, struct page *page, + struct ptlrpc_request **request) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, readpage); + MD_COUNTER_INCREMENT(exp->exp_obd, readpage); + rc = MDP(exp->exp_obd, readpage)(exp, fid, offset, page, request); + RETURN(rc); +} + +static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, + struct ptlrpc_request **request) +{ + int rc; + ENTRY; + EXP_CHECK_MD_OP(exp, unlink); + MD_COUNTER_INCREMENT(exp->exp_obd, unlink); + rc = MDP(exp->exp_obd, unlink)(exp, op_data, request); + RETURN(rc); +} + +static inline int md_get_lustre_md(struct obd_export *exp, + struct ptlrpc_request *req, + int offset, struct obd_export *dt_exp, + struct lustre_md *md) +{ + ENTRY; + EXP_CHECK_MD_OP(exp, get_lustre_md); + MD_COUNTER_INCREMENT(exp->exp_obd, get_lustre_md); + RETURN(MDP(exp->exp_obd, get_lustre_md)(exp, req, offset, + dt_exp, md)); +} + +static inline int md_free_lustre_md(struct obd_export *exp, + struct lustre_md *md) +{ + ENTRY; + EXP_CHECK_MD_OP(exp, free_lustre_md); + MD_COUNTER_INCREMENT(exp->exp_obd, free_lustre_md); + RETURN(MDP(exp->exp_obd, free_lustre_md)(exp, md)); +} + +static inline int md_setxattr(struct obd_export *exp, struct lu_fid *fid, + obd_valid valid, const char *name, + const char *input, int input_size, + int output_size, int flags, + struct ptlrpc_request **request) +{ + ENTRY; + EXP_CHECK_MD_OP(exp, setxattr); + MD_COUNTER_INCREMENT(exp->exp_obd, setxattr); + RETURN(MDP(exp->exp_obd, setxattr)(exp, fid, valid, name, input, + input_size, output_size, flags, + request)); +} + +static inline int md_getxattr(struct obd_export *exp, struct lu_fid *fid, + obd_valid valid, const char *name, + const char *input, int input_size, + int output_size, int flags, + struct ptlrpc_request **request) +{ + ENTRY; + EXP_CHECK_MD_OP(exp, getxattr); + MD_COUNTER_INCREMENT(exp->exp_obd, getxattr); + RETURN(MDP(exp->exp_obd, getxattr)(exp, fid, valid, name, input, + input_size, output_size, flags, + request)); +} + +static inline int md_set_open_replay_data(struct obd_export *exp, + struct obd_client_handle *och, + struct ptlrpc_request *open_req) +{ + ENTRY; + EXP_CHECK_MD_OP(exp, set_open_replay_data); + MD_COUNTER_INCREMENT(exp->exp_obd, set_open_replay_data); + RETURN(MDP(exp->exp_obd, set_open_replay_data)(exp, och, open_req)); +} + +static inline int md_clear_open_replay_data(struct obd_export *exp, + struct obd_client_handle *och) +{ + ENTRY; + EXP_CHECK_MD_OP(exp, clear_open_replay_data); + MD_COUNTER_INCREMENT(exp->exp_obd, clear_open_replay_data); + RETURN(MDP(exp->exp_obd, clear_open_replay_data)(exp, och)); +} + +static inline int md_set_lock_data(struct obd_export *exp, + __u64 *lockh, void *data) +{ + ENTRY; + EXP_CHECK_MD_OP(exp, set_lock_data); + MD_COUNTER_INCREMENT(exp->exp_obd, set_lock_data); + RETURN(MDP(exp->exp_obd, set_lock_data)(exp, lockh, data)); +} + +static inline int md_init_ea_size(struct obd_export *exp, + int easize, int def_asize, + int cookiesize) +{ + ENTRY; + EXP_CHECK_MD_OP(exp, init_ea_size); + MD_COUNTER_INCREMENT(exp->exp_obd, init_ea_size); + RETURN(MDP(exp->exp_obd, init_ea_size)(exp, easize, + def_asize, + cookiesize)); +} + +/* OBD Metadata Support */ extern int obd_init_caches(void); extern void obd_cleanup_caches(void); @@ -1247,6 +1598,18 @@ static inline void obdo_free(struct obdo *oa) OBD_SLAB_FREE(oa, obdo_cachep, sizeof(*oa)); } +static inline void obdo2fid(struct obdo *oa, + struct lu_fid *fid) +{ + /* something here */ +} + +static inline void fid2obdo(struct lu_fid *fid, + struct obdo *oa) +{ + /* something here */ +} + #if !defined(__KERNEL__) || (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) #define to_kdev_t(dev) dev #define kdev_t_to_nr(dev) dev @@ -1274,4 +1637,8 @@ int class_del_uuid (const char *uuid); void class_init_uuidlist(void); void class_exit_uuidlist(void); +/* mea.c */ +int mea_name2idx(struct lmv_stripe_md *mea, char *name, int namelen); +int raw_name2idx(int hashtype, int count, const char *name, int namelen); + #endif /* __LINUX_OBD_CLASS_H */ diff --git a/lustre/ldiskfs/quotafmt_test.c b/lustre/ldiskfs/quotafmt_test.c index ae6e939..0e2f5f3 100644 --- a/lustre/ldiskfs/quotafmt_test.c +++ b/lustre/ldiskfs/quotafmt_test.c @@ -486,7 +486,7 @@ static int __init quotfmt_test_init(void) struct lprocfs_static_vars lvars; lprocfs_init_vars(quotfmt_test, &lvars); - return class_register_type("fmt_obd_ops, lvars.module_vars, + return class_register_type("fmt_obd_ops, NULL, lvars.module_vars, "quotfmt_test", NULL); } diff --git a/lustre/liblustre/dir.c b/lustre/liblustre/dir.c index 873f1f1..e944fe5 100644 --- a/lustre/liblustre/dir.c +++ b/lustre/liblustre/dir.c @@ -74,7 +74,7 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page) struct mdt_body *body; struct lookup_intent it = { .it_op = IT_READDIR }; struct md_op_data op_data = { { 0 } }; - struct obd_device *obddev = class_exp2obd(sbi->ll_mdc_exp); + struct obd_device *obddev = class_exp2obd(sbi->ll_md_exp); struct ldlm_res_id res_id = { .name = {fid_seq(&lli->lli_fid), fid_num(&lli->lli_fid)} }; ldlm_policy_data_t policy = { .l_inodebits = { MDS_INODELOCK_UPDATE } }; @@ -85,10 +85,10 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page) if (!rc) { llu_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0); - rc = mdc_enqueue(sbi->ll_mdc_exp, LDLM_IBITS, &it, LCK_CR, - &op_data, &lockh, NULL, 0, - ldlm_completion_ast, llu_mdc_blocking_ast, - inode, LDLM_FL_CANCEL_ON_BLOCK); + rc = md_enqueue(sbi->ll_md_exp, LDLM_IBITS, &it, LCK_CR, + &op_data, &lockh, NULL, 0, + ldlm_completion_ast, llu_mdc_blocking_ast, + inode, LDLM_FL_CANCEL_ON_BLOCK); request = (struct ptlrpc_request *)it.d.lustre.it_data; if (request) ptlrpc_req_finished(request); @@ -100,8 +100,8 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page) ldlm_lock_dump_handle(D_OTHER, &lockh); offset = page->index << PAGE_SHIFT; - rc = mdc_readpage(sbi->ll_mdc_exp, &lli->lli_fid, - offset, page, &request); + rc = md_readpage(sbi->ll_md_exp, &lli->lli_fid, + offset, page, &request); if (!rc) { body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body)); LASSERT (body != NULL); /* checked by mdc_readpage() */ diff --git a/lustre/liblustre/file.c b/lustre/liblustre/file.c index e34a02a..3047dee 100644 --- a/lustre/liblustre/file.c +++ b/lustre/liblustre/file.c @@ -147,7 +147,8 @@ static int llu_local_open(struct llu_inode_info *lli, struct lookup_intent *it) fd->fd_mds_och.och_magic = OBD_CLIENT_HANDLE_MAGIC; lli->lli_file_data = fd; - mdc_set_open_replay_data(&fd->fd_mds_och, it->d.lustre.it_data); + md_set_open_replay_data(lli->lli_sbi->ll_md_exp, + &fd->fd_mds_och, it->d.lustre.it_data); RETURN(0); } @@ -295,7 +296,7 @@ int llu_objects_destroy(struct ptlrpc_request *request, struct inode *dir) return rc; } -int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode) +int llu_mdc_close(struct obd_export *md_exp, struct inode *inode) { struct llu_inode_info *lli = llu_i2info(inode); struct ll_file_data *fd = lli->lli_file_data; @@ -335,7 +336,7 @@ int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode) op_data.flags = MDS_BFLAG_UNCOMMITTED_WRITES; op_data.valid |= OBD_MD_FLFLAGS; } - rc = mdc_close(mdc_exp, &op_data, och, &req); + rc = md_close(md_exp, &op_data, och, &req); if (rc == EAGAIN) { /* We are the last writer, so the MDS has instructed us to get * the file size and any write cookies, then close again. */ @@ -351,7 +352,7 @@ int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode) (long long)st->st_ino, rc); } - mdc_clear_open_replay_data(och); + md_clear_open_replay_data(md_exp, och); ptlrpc_req_finished(req); och->och_fh.cookie = DEAD_HANDLE_MAGIC; lli->lli_file_data = NULL; @@ -382,7 +383,7 @@ static int llu_file_release(struct inode *inode) if (!fd) /* no process opened the file after an mcreate */ RETURN(0); - rc2 = llu_mdc_close(sbi->ll_mdc_exp, inode); + rc2 = llu_mdc_close(sbi->ll_md_exp, inode); if (rc2 && !rc) rc = rc2; diff --git a/lustre/liblustre/llite_lib.h b/lustre/liblustre/llite_lib.h index 83a6408..874e6ce 100644 --- a/lustre/liblustre/llite_lib.h +++ b/lustre/liblustre/llite_lib.h @@ -25,8 +25,8 @@ struct ll_file_data { struct llu_sb_info { struct obd_uuid ll_sb_uuid; - struct obd_export *ll_mdc_exp; - struct obd_export *ll_osc_exp; + struct obd_export *ll_md_exp; + struct obd_export *ll_dt_exp; struct lu_fid ll_root_fid; int ll_flags; struct lustre_client_ocd ll_lco; @@ -97,12 +97,12 @@ static inline struct llu_sb_info *llu_i2sbi(struct inode *inode) static inline struct obd_export *llu_i2obdexp(struct inode *inode) { - return llu_i2info(inode)->lli_sbi->ll_osc_exp; + return llu_i2info(inode)->lli_sbi->ll_dt_exp; } static inline struct obd_export *llu_i2mdcexp(struct inode *inode) { - return llu_i2info(inode)->lli_sbi->ll_mdc_exp; + return llu_i2info(inode)->lli_sbi->ll_md_exp; } static inline int llu_is_root_inode(struct inode *inode) @@ -203,7 +203,7 @@ void llu_prepare_mdc_op_data(struct md_op_data *op_data, int mode); int llu_create(struct inode *dir, struct pnode_base *pnode, int mode); int llu_iop_open(struct pnode *pnode, int flags, mode_t mode); -int llu_mdc_close(struct obd_export *mdc_exp, struct inode *inode); +int llu_mdc_close(struct obd_export *md_exp, struct inode *inode); int llu_iop_close(struct inode *inode); _SYSIO_OFF_T llu_iop_pos(struct inode *ino, _SYSIO_OFF_T off); int llu_vmtruncate(struct inode * inode, loff_t offset, obd_flag obd_flags); diff --git a/lustre/liblustre/namei.c b/lustre/liblustre/namei.c index a2a784e..65d2e46 100644 --- a/lustre/liblustre/namei.c +++ b/lustre/liblustre/namei.c @@ -104,16 +104,19 @@ void unhook_stale_inode(struct pnode *pno) void llu_lookup_finish_locks(struct lookup_intent *it, struct pnode *pnode) { + struct llu_sb_info *sbi; struct inode *inode; LASSERT(it); LASSERT(pnode); inode = pnode->p_base->pb_ino; + sbi = llu_i2sbi(inode); if (it->d.lustre.it_lock_mode && inode != NULL) { CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%llu/%lu)\n", inode, (long long)llu_i2stat(inode)->st_ino, llu_i2info(inode)->lli_st_generation); - mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode); + md_set_lock_data(sbi->ll_md_exp, + &it->d.lustre.it_lock_handle, inode); } /* drop lookup/getattr locks */ @@ -131,8 +134,8 @@ int llu_mdc_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc, void *data, int flag) { - int rc; struct lustre_handle lockh; + int rc; ENTRY; @@ -208,7 +211,8 @@ static int pnode_revalidate_finish(struct ptlrpc_request *req, if (it_disposition(it, DISP_LOOKUP_NEG)) RETURN(-ENOENT); - rc = mdc_req2lustre_md(req, offset, llu_i2sbi(inode)->ll_osc_exp, &md); + rc = md_get_lustre_md(llu_i2sbi(inode)->ll_md_exp, req, + offset, llu_i2sbi(inode)->ll_dt_exp, &md); if (rc) RETURN(rc); @@ -269,9 +273,9 @@ static int llu_pb_revalidate(struct pnode *pnode, int flags, llu_prepare_mdc_op_data(&op_data, pnode->p_parent->p_base->pb_ino, pb->pb_ino, pb->pb_name.name,pb->pb_name.len,0); - rc = mdc_intent_lock(exp, &op_data, NULL, 0, it, flags, - &req, llu_mdc_blocking_ast, - LDLM_FL_CANCEL_ON_BLOCK); + rc = md_intent_lock(exp, &op_data, NULL, 0, it, flags, + &req, llu_mdc_blocking_ast, + LDLM_FL_CANCEL_ON_BLOCK); /* If req is NULL, then mdc_intent_lock only tried to do a lock match; * if all was well, it will return 1 if it found locks, 0 otherwise. */ if (req == NULL && rc >= 0) @@ -351,7 +355,8 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, if (it_disposition(it, DISP_OPEN_CREATE)) ptlrpc_req_finished(request); - rc = mdc_req2lustre_md(request, offset, sbi->ll_osc_exp, &md); + rc = md_get_lustre_md(sbi->ll_md_exp, request, offset, + sbi->ll_dt_exp, &md); if (rc) RETURN(rc); @@ -359,11 +364,11 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, if (!inode || IS_ERR(inode)) { /* free the lsm if we allocated one above */ if (md.lsm != NULL) - obd_free_memmd(sbi->ll_osc_exp, &md.lsm); + obd_free_memmd(sbi->ll_dt_exp, &md.lsm); RETURN(inode ? PTR_ERR(inode) : -ENOMEM); } else if (md.lsm != NULL && llu_i2info(inode)->lli_smd != md.lsm) { - obd_free_memmd(sbi->ll_osc_exp, &md.lsm); + obd_free_memmd(sbi->ll_dt_exp, &md.lsm); } lli = llu_i2info(inode); @@ -447,9 +452,9 @@ static int llu_lookup_it(struct inode *parent, struct pnode *pnode, pnode->p_base->pb_name.name, pnode->p_base->pb_name.len, flags); - rc = mdc_intent_lock(llu_i2mdcexp(parent), &op_data, NULL, 0, it, - flags, &req, llu_mdc_blocking_ast, - LDLM_FL_CANCEL_ON_BLOCK); + rc = md_intent_lock(llu_i2mdcexp(parent), &op_data, NULL, 0, it, + flags, &req, llu_mdc_blocking_ast, + LDLM_FL_CANCEL_ON_BLOCK); if (rc < 0) GOTO(out, rc); diff --git a/lustre/liblustre/rw.c b/lustre/liblustre/rw.c index 244271b..57ac68a 100644 --- a/lustre/liblustre/rw.c +++ b/lustre/liblustre/rw.c @@ -232,7 +232,7 @@ int llu_glimpse_size(struct inode *inode) CDEBUG(D_DLMTRACE, "Glimpsing inode %llu\n", (long long)st->st_ino); - rc = obd_enqueue(sbi->ll_osc_exp, lli->lli_smd, LDLM_EXTENT, &policy, + rc = obd_enqueue(sbi->ll_dt_exp, lli->lli_smd, LDLM_EXTENT, &policy, LCK_PR, &flags, llu_extent_lock_callback, ldlm_completion_ast, llu_glimpse_callback, inode, sizeof(struct ost_lvb), lustre_swab_ost_lvb, &lockh); @@ -242,7 +242,7 @@ int llu_glimpse_size(struct inode *inode) } inode_init_lvb(inode, &lvb); - obd_merge_lvb(sbi->ll_osc_exp, lli->lli_smd, &lvb, 0); + obd_merge_lvb(sbi->ll_dt_exp, lli->lli_smd, &lvb, 0); st->st_size = lvb.lvb_size; st->st_blocks = lvb.lvb_blocks; st->st_mtime = lvb.lvb_mtime; @@ -252,7 +252,7 @@ int llu_glimpse_size(struct inode *inode) CDEBUG(D_DLMTRACE, "glimpse: size: %llu, blocks: %llu\n", (long long)st->st_size, (long long)st->st_blocks); - obd_cancel(sbi->ll_osc_exp, lli->lli_smd, LCK_PR, &lockh); + obd_cancel(sbi->ll_dt_exp, lli->lli_smd, LCK_PR, &lockh); RETURN(rc); } @@ -280,7 +280,7 @@ int llu_extent_lock(struct ll_file_data *fd, struct inode *inode, (long long)st->st_ino, policy->l_extent.start, policy->l_extent.end); - rc = obd_enqueue(sbi->ll_osc_exp, lsm, LDLM_EXTENT, policy, mode, + rc = obd_enqueue(sbi->ll_dt_exp, lsm, LDLM_EXTENT, policy, mode, &ast_flags, llu_extent_lock_callback, ldlm_completion_ast, llu_glimpse_callback, inode, sizeof(struct ost_lvb), lustre_swab_ost_lvb, lockh); @@ -288,7 +288,7 @@ int llu_extent_lock(struct ll_file_data *fd, struct inode *inode, rc = -EIO; inode_init_lvb(inode, &lvb); - obd_merge_lvb(sbi->ll_osc_exp, lsm, &lvb, 1); + obd_merge_lvb(sbi->ll_dt_exp, lsm, &lvb, 1); if (policy->l_extent.start == 0 && policy->l_extent.end == OBD_OBJECT_EOF) st->st_size = lvb.lvb_size; @@ -317,7 +317,7 @@ int llu_extent_unlock(struct ll_file_data *fd, struct inode *inode, (sbi->ll_flags & LL_SBI_NOLCK) || mode == LCK_NL) RETURN(0); - rc = obd_cancel(sbi->ll_osc_exp, lsm, mode, lockh); + rc = obd_cancel(sbi->ll_dt_exp, lsm, mode, lockh); RETURN(rc); } diff --git a/lustre/liblustre/super.c b/lustre/liblustre/super.c index e2b39b9..34a039a 100644 --- a/lustre/liblustre/super.c +++ b/lustre/liblustre/super.c @@ -91,13 +91,13 @@ static int ll_permission(struct inode *inode, int mask) static void llu_fsop_gone(struct filesys *fs) { struct llu_sb_info *sbi = (struct llu_sb_info *) fs->fs_private; - struct obd_device *obd = class_exp2obd(sbi->ll_mdc_exp); + struct obd_device *obd = class_exp2obd(sbi->ll_md_exp); int next = 0; ENTRY; list_del(&sbi->ll_conn_chain); - obd_disconnect(sbi->ll_osc_exp); - obd_disconnect(sbi->ll_mdc_exp); + obd_disconnect(sbi->ll_dt_exp); + obd_disconnect(sbi->ll_md_exp); while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)) != NULL){ struct lustre_cfg_bufs bufs; @@ -391,7 +391,7 @@ static int llu_have_md_lock(struct inode *inode, __u64 lockpart) LASSERT(inode); - obddev = sbi->ll_mdc_exp->exp_obd; + obddev = sbi->ll_md_exp->exp_obd; res_id.name[0] = fid_seq(&lli->lli_fid); res_id.name[1] = fid_num(&lli->lli_fid); @@ -433,17 +433,18 @@ static int llu_inode_revalidate(struct inode *inode) /* Why don't we update all valid MDS fields here, if we're * doing an RPC anyways? -phil */ if (S_ISREG(llu_i2stat(inode)->st_mode)) { - ealen = obd_size_diskmd(sbi->ll_osc_exp, NULL); + ealen = obd_size_diskmd(sbi->ll_dt_exp, NULL); valid |= OBD_MD_FLEASIZE; } - rc = mdc_getattr(sbi->ll_mdc_exp, ll_inode2fid(inode), - valid, ealen, &req); + rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), + valid, ealen, &req); if (rc) { CERROR("failure %d inode %llu\n", rc, (long long)llu_i2stat(inode)->st_ino); RETURN(-abs(rc)); } - rc = mdc_req2lustre_md(req, 0, sbi->ll_osc_exp, &md); + rc = md_get_lustre_md(sbi->ll_md_exp, req, 0, + sbi->ll_dt_exp, &md); /* XXX Too paranoid? */ if (((md.body->valid ^ valid) & OBD_MD_FLEASIZE) && @@ -462,7 +463,7 @@ static int llu_inode_revalidate(struct inode *inode) llu_update_inode(inode, md.body, md.lsm); if (md.lsm != NULL && llu_i2info(inode)->lli_smd != md.lsm) - obd_free_memmd(sbi->ll_osc_exp, &md.lsm); + obd_free_memmd(sbi->ll_dt_exp, &md.lsm); if (md.body->valid & OBD_MD_FLSIZE) set_bit(LLI_F_HAVE_MDS_SIZE_LOCK, @@ -537,15 +538,15 @@ void llu_clear_inode(struct inode *inode) inode); clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(lli->lli_flags)); - mdc_change_cbdata(sbi->ll_mdc_exp, ll_inode2fid(inode), - null_if_equal, inode); + md_change_cbdata(sbi->ll_md_exp, ll_inode2fid(inode), + null_if_equal, inode); if (lli->lli_smd) - obd_change_cbdata(sbi->ll_osc_exp, lli->lli_smd, + obd_change_cbdata(sbi->ll_dt_exp, lli->lli_smd, null_if_equal, inode); if (lli->lli_smd) { - obd_free_memmd(sbi->ll_osc_exp, &lli->lli_smd); + obd_free_memmd(sbi->ll_dt_exp, &lli->lli_smd); lli->lli_smd = NULL; } @@ -668,8 +669,8 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr) struct lustre_md md; llu_prepare_mdc_op_data(&op_data, inode, NULL, NULL, 0, 0); - rc = mdc_setattr(sbi->ll_mdc_exp, &op_data, - attr, NULL, 0, NULL, 0, &request); + rc = md_setattr(sbi->ll_md_exp, &op_data, + attr, NULL, 0, NULL, 0, &request); if (rc) { ptlrpc_req_finished(request); @@ -678,7 +679,8 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr) RETURN(rc); } - rc = mdc_req2lustre_md(request, 0, sbi->ll_osc_exp, &md); + rc = md_get_lustre_md(sbi->ll_md_exp, request, 0, + sbi->ll_dt_exp, &md); if (rc) { ptlrpc_req_finished(request); RETURN(rc); @@ -733,7 +735,7 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr) obd_flag obd_flags; /* check that there are no matching locks */ - LASSERT(obd_match(sbi->ll_osc_exp, lsm, LDLM_EXTENT, &policy, + LASSERT(obd_match(sbi->ll_dt_exp, lsm, LDLM_EXTENT, &policy, LCK_PW, &flags, inode, &match_lockh) <= 0); /* XXX when we fix the AST intents to pass the discard-range @@ -778,7 +780,7 @@ int llu_setattr_raw(struct inode *inode, struct iattr *attr) oa.o_valid = OBD_MD_FLID; obdo_from_inode(&oa, inode, OBD_MD_FLTYPE | OBD_MD_FLATIME | OBD_MD_FLMTIME | OBD_MD_FLCTIME); - rc = obd_setattr(sbi->ll_osc_exp, &oa, lsm, NULL); + rc = obd_setattr(sbi->ll_dt_exp, &oa, lsm, NULL); if (rc) CERROR("obd_setattr fails: rc=%d\n", rc); } @@ -862,10 +864,10 @@ static int llu_iop_symlink_raw(struct pnode *pno, const char *tgt) RETURN(err); } llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); - err = mdc_create(sbi->ll_mdc_exp, &op_data, - tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO, - current->fsuid, current->fsgid, current->cap_effective, - 0, &request); + err = md_create(sbi->ll_md_exp, &op_data, + tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO, + current->fsuid, current->fsgid, current->cap_effective, + 0, &request); ptlrpc_req_finished(request); liblustre_wait_event(0); RETURN(err); @@ -890,8 +892,8 @@ static int llu_readlink_internal(struct inode *inode, RETURN(0); } - rc = mdc_getattr(sbi->ll_mdc_exp, ll_inode2fid(inode), - OBD_MD_LINKNAME, symlen, request); + rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), + OBD_MD_LINKNAME, symlen, request); if (rc) { CERROR("inode %llu: rc = %d\n", (long long)st->st_ino, rc); RETURN(rc); @@ -995,9 +997,9 @@ static int llu_iop_mknod_raw(struct pnode *pno, pno->p_base->pb_name.name, pno->p_base->pb_name.len, 0); - err = mdc_create(sbi->ll_mdc_exp, &op_data, NULL, 0, mode, - current->fsuid, current->fsgid, - current->cap_effective, dev, &request); + err = md_create(sbi->ll_md_exp, &op_data, NULL, 0, mode, + current->fsuid, current->fsgid, + current->cap_effective, dev, &request); ptlrpc_req_finished(request); break; case S_IFDIR: @@ -1026,7 +1028,7 @@ static int llu_iop_link_raw(struct pnode *old, struct pnode *new) liblustre_wait_event(0); llu_prepare_mdc_op_data(&op_data, src, dir, name, namelen, 0); - rc = mdc_link(llu_i2sbi(src)->ll_mdc_exp, &op_data, &request); + rc = md_link(llu_i2sbi(src)->ll_md_exp, &op_data, &request); ptlrpc_req_finished(request); liblustre_wait_event(0); @@ -1052,7 +1054,7 @@ static int llu_iop_unlink_raw(struct pnode *pno) liblustre_wait_event(0); llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); - rc = mdc_unlink(llu_i2sbi(dir)->ll_mdc_exp, &op_data, &request); + rc = md_unlink(llu_i2sbi(dir)->ll_md_exp, &op_data, &request); if (!rc) rc = llu_objects_destroy(request, dir); ptlrpc_req_finished(request); @@ -1079,9 +1081,9 @@ static int llu_iop_rename_raw(struct pnode *old, struct pnode *new) liblustre_wait_event(0); llu_prepare_mdc_op_data(&op_data, src, tgt, NULL, 0, 0); - rc = mdc_rename(llu_i2sbi(src)->ll_mdc_exp, &op_data, - oldname, oldnamelen, newname, newnamelen, - &request); + rc = md_rename(llu_i2sbi(src)->ll_md_exp, &op_data, + oldname, oldnamelen, newname, newnamelen, + &request); if (!rc) { rc = llu_objects_destroy(request, src); } @@ -1101,7 +1103,7 @@ static int llu_statfs_internal(struct llu_sb_info *sbi, int rc; ENTRY; - rc = obd_statfs(class_exp2obd(sbi->ll_mdc_exp), osfs, max_age); + rc = obd_statfs(class_exp2obd(sbi->ll_md_exp), osfs, max_age); if (rc) { CERROR("mdc_statfs fails: rc = %d\n", rc); RETURN(rc); @@ -1110,7 +1112,7 @@ static int llu_statfs_internal(struct llu_sb_info *sbi, CDEBUG(D_SUPER, "MDC blocks "LPU64"/"LPU64" objects "LPU64"/"LPU64"\n", osfs->os_bavail, osfs->os_blocks, osfs->os_ffree,osfs->os_files); - rc = obd_statfs(class_exp2obd(sbi->ll_osc_exp), &obd_osfs, max_age); + rc = obd_statfs(class_exp2obd(sbi->ll_dt_exp), &obd_osfs, max_age); if (rc) { CERROR("obd_statfs fails: rc = %d\n", rc); RETURN(rc); @@ -1231,9 +1233,9 @@ static int llu_iop_mkdir_raw(struct pnode *pno, mode_t mode) RETURN(err); } llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, 0); - err = mdc_create(llu_i2sbi(dir)->ll_mdc_exp, &op_data, NULL, 0, mode, - current->fsuid, current->fsgid, current->cap_effective, - 0, &request); + err = md_create(llu_i2sbi(dir)->ll_md_exp, &op_data, NULL, 0, mode, + current->fsuid, current->fsgid, current->cap_effective, + 0, &request); ptlrpc_req_finished(request); liblustre_wait_event(0); RETURN(err); @@ -1256,7 +1258,7 @@ static int llu_iop_rmdir_raw(struct pnode *pno) llu_i2info(dir)->lli_st_generation, dir); llu_prepare_mdc_op_data(&op_data, dir, NULL, name, len, S_IFDIR); - rc = mdc_unlink(llu_i2sbi(dir)->ll_mdc_exp, &op_data, &request); + rc = md_unlink(llu_i2sbi(dir)->ll_md_exp, &op_data, &request); ptlrpc_req_finished(request); liblustre_wait_event(0); @@ -1653,8 +1655,6 @@ struct inode *llu_iget(struct filesys *fs, struct lustre_md *md) inode = _sysio_i_find(fs, &fileid); if (inode) { - struct llu_inode_info *lli = llu_i2info(inode); - if (inode->i_zombie/* || lli->lli_st_generation != md->body->generation*/) { I_RELE(inode); @@ -1673,6 +1673,37 @@ struct inode *llu_iget(struct filesys *fs, struct lustre_md *md) } static int +llu_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp) +{ + struct lov_stripe_md lsm = { .lsm_magic = LOV_MAGIC }; + __u32 valsize = sizeof(struct lov_desc); + int rc, easize, def_easize, cookiesize; + struct lov_desc desc; + __u32 stripes; + ENTRY; + + rc = obd_get_info(dt_exp, strlen(KEY_LOVDESC) + 1, KEY_LOVDESC, + &valsize, &desc); + if (rc) + RETURN(rc); + + stripes = min(desc.ld_tgt_count, (__u32)LOV_MAX_STRIPE_COUNT); + lsm.lsm_stripe_count = stripes; + easize = obd_size_diskmd(dt_exp, &lsm); + + lsm.lsm_stripe_count = desc.ld_default_stripe_count; + def_easize = obd_size_diskmd(dt_exp, &lsm); + + cookiesize = stripes * sizeof(struct llog_cookie); + + CDEBUG(D_HA, "updating max_mdsize/max_cookiesize: %d/%d\n", + easize, cookiesize); + + rc = md_init_ea_size(md_exp, easize, def_easize, cookiesize); + RETURN(rc); +} + +static int llu_fsswop_mount(const char *source, unsigned flags, const void *data __IS_UNUSED, @@ -1780,7 +1811,7 @@ llu_fsswop_mount(const char *source, CERROR("cannot connect to %s: rc = %d\n", mdc, err); GOTO(out_free, err); } - sbi->ll_mdc_exp = class_conn2export(&mdc_conn); + sbi->ll_md_exp = class_conn2export(&mdc_conn); err = obd_statfs(obd, &osfs, 100000000); if (err) @@ -1816,12 +1847,12 @@ llu_fsswop_mount(const char *source, CERROR("cannot connect to %s: rc = %d\n", osc, err); GOTO(out_mdc, err); } - sbi->ll_osc_exp = class_conn2export(&osc_conn); + sbi->ll_dt_exp = class_conn2export(&osc_conn); sbi->ll_lco.lco_flags = ocd.ocd_connect_flags; - mdc_init_ea_size(sbi->ll_mdc_exp, sbi->ll_osc_exp); + llu_init_ea_size(sbi->ll_md_exp, sbi->ll_dt_exp); - err = mdc_getstatus(sbi->ll_mdc_exp, &rootfid); + err = md_getstatus(sbi->ll_md_exp, &rootfid); if (err) { CERROR("cannot mds_connect: rc = %d\n", err); GOTO(out_osc, err); @@ -1830,14 +1861,15 @@ llu_fsswop_mount(const char *source, sbi->ll_root_fid = rootfid; /* fetch attr of root inode */ - err = mdc_getattr(sbi->ll_mdc_exp, &rootfid, - OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS, 0, &request); + err = md_getattr(sbi->ll_md_exp, &rootfid, + OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS, 0, &request); if (err) { CERROR("mdc_getattr failed for root: rc = %d\n", err); GOTO(out_osc, err); } - err = mdc_req2lustre_md(request, 0, sbi->ll_osc_exp, &md); + err = md_get_lustre_md(sbi->ll_md_exp, request, 0, + sbi->ll_dt_exp, &md); if (err) { CERROR("failed to understand root inode md: rc = %d\n",err); GOTO(out_request, err); @@ -1878,9 +1910,9 @@ out_inode: out_request: ptlrpc_req_finished(request); out_osc: - obd_disconnect(sbi->ll_osc_exp); + obd_disconnect(sbi->ll_dt_exp); out_mdc: - obd_disconnect(sbi->ll_mdc_exp); + obd_disconnect(sbi->ll_md_exp); out_free: if (osc) OBD_FREE(osc, strlen(osc) + 1); diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index e2bd7eb..6de6ce9 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -231,21 +231,25 @@ static int revalidate_it_finish(struct ptlrpc_request *request, int offset, RETURN(-ENOENT); sbi = ll_i2sbi(de->d_inode); - rc = ll_prep_inode(sbi->ll_dt_exp, &de->d_inode, request, offset, NULL); + rc = ll_prep_inode(&de->d_inode, request, offset, NULL); RETURN(rc); } void ll_lookup_finish_locks(struct lookup_intent *it, struct dentry *dentry) { + struct ll_sb_info *sbi; + LASSERT(it != NULL); LASSERT(dentry != NULL); + sbi = ll_i2sbi(dentry->d_inode); + if (it->d.lustre.it_lock_mode && dentry->d_inode != NULL) { struct inode *inode = dentry->d_inode; CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n", inode, inode->i_ino, inode->i_generation); - mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode); + md_set_lock_data(sbi->ll_md_exp, &it->d.lustre.it_lock_handle, inode); } /* drop lookup or getattr locks immediately */ @@ -314,8 +318,8 @@ int ll_revalidate_it(struct dentry *de, int lookup_flags, ll_prepare_md_op_data(&op_data, parent, NULL, de->d_name.name, de->d_name.len, 0); - rc = mdc_intent_lock(exp, &op_data, NULL, 0, it, lookup_flags, - &req, ll_mdc_blocking_ast, 0); + rc = md_intent_lock(exp, &op_data, NULL, 0, it, lookup_flags, + &req, ll_mdc_blocking_ast, 0); /* If req is NULL, then mdc_intent_lock only tried to do a lock match; * if all was well, it will return 1 if it found locks, 0 otherwise. */ if (req == NULL && rc >= 0) diff --git a/lustre/llite/dir.c b/lustre/llite/dir.c index 9366700..8c31a85 100644 --- a/lustre/llite/dir.c +++ b/lustre/llite/dir.c @@ -69,12 +69,12 @@ static int ll_dir_readpage(struct file *file, struct page *page) CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%u(%p) off "LPU64"\n", inode->i_ino, inode->i_generation, inode, offset); - rc = mdc_readpage(ll_i2sbi(inode)->ll_md_exp, ll_inode2fid(inode), - offset, page, &request); + rc = md_readpage(ll_i2sbi(inode)->ll_md_exp, ll_inode2fid(inode), + offset, page, &request); if (!rc) { body = lustre_msg_buf(request->rq_repmsg, 0, sizeof (*body)); - LASSERT (body != NULL); /* checked by mdc_readpage() */ - LASSERT_REPSWABBED (request, 0); /* swabbed by mdc_readpage() */ + LASSERT (body != NULL); /* checked by md_readpage() */ + LASSERT_REPSWABBED (request, 0); /* swabbed by md_readpage() */ inode->i_size = body->size; SetPageUptodate(page); @@ -220,10 +220,10 @@ static struct page *ll_get_dir_page(struct inode *dir, unsigned long n) ll_prepare_md_op_data(&op_data, dir, NULL, NULL, 0, 0); - rc = mdc_enqueue(ll_i2sbi(dir)->ll_md_exp, LDLM_IBITS, &it, - LCK_CR, &op_data, &lockh, NULL, 0, - ldlm_completion_ast, ll_mdc_blocking_ast, dir, - 0); + rc = md_enqueue(ll_i2sbi(dir)->ll_md_exp, LDLM_IBITS, &it, + LCK_CR, &op_data, &lockh, NULL, 0, + ldlm_completion_ast, ll_mdc_blocking_ast, dir, + 0); request = (struct ptlrpc_request *)it.d.lustre.it_data; if (request) @@ -423,9 +423,9 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, GOTO(out, rc = -EINVAL); } - rc = mdc_getattr_name(sbi->ll_md_exp, ll_inode2fid(inode), - filename, namelen, OBD_MD_FLID, 0, - &request); + rc = md_getattr_name(sbi->ll_md_exp, ll_inode2fid(inode), + filename, namelen, OBD_MD_FLID, 0, + &request); if (rc < 0) { CDEBUG(D_INFO, "mdc_getattr_name: %d\n", rc); GOTO(out, rc); @@ -467,8 +467,8 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, lustre_swab_lov_user_md(&lum); /* swabbing is done in lov_setstripe() on server side */ - rc = mdc_setattr(sbi->ll_md_exp, &op_data, - &attr, &lum, sizeof(lum), NULL, 0, &request); + rc = md_setattr(sbi->ll_md_exp, &op_data, + &attr, &lum, sizeof(lum), NULL, 0, &request); if (rc) { ptlrpc_req_finished(request); if (rc != -EPERM && rc != -EACCES) @@ -490,8 +490,8 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, if (rc) RETURN(rc); - rc = mdc_getattr(sbi->ll_md_exp, ll_inode2fid(inode), - OBD_MD_FLDIREA, lmmsize, &request); + rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), + OBD_MD_FLDIREA, lmmsize, &request); if (rc < 0) { CDEBUG(D_INFO, "mdc_getattr failed: rc = %d\n", rc); RETURN(rc); @@ -547,9 +547,9 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, if (rc) RETURN(rc); - rc = mdc_getattr_name(sbi->ll_md_exp, ll_inode2fid(inode), - filename, strlen(filename) + 1, - OBD_MD_FLEASIZE, lmmsize, &request); + rc = md_getattr_name(sbi->ll_md_exp, ll_inode2fid(inode), + filename, strlen(filename) + 1, + OBD_MD_FLEASIZE, lmmsize, &request); if (rc < 0) { CDEBUG(D_INFO, "mdc_getattr_name failed on %s: rc %d\n", filename, rc); diff --git a/lustre/llite/file.c b/lustre/llite/file.c index e79761e..4493700 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -47,8 +47,8 @@ static void ll_file_data_put(struct ll_file_data *fd) OBD_SLAB_FREE(fd, ll_file_data_slab, sizeof *fd); } -int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode, - struct file *file) +int ll_mdc_close(struct obd_export *md_exp, struct inode *inode, + struct file *file) { struct ll_file_data *fd = LUSTRE_FPRIVATE(file); struct ptlrpc_request *req = NULL; @@ -84,7 +84,7 @@ int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode, op_data.valid |= OBD_MD_FLFLAGS; } - rc = mdc_close(mdc_exp, &op_data, och, &req); + rc = md_close(md_exp, &op_data, och, &req); if (rc == EAGAIN) { /* We are the last writer, so the MDS has instructed us to get * the file size and any write cookies, then close again. */ @@ -101,7 +101,7 @@ int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode, inode->i_ino, rc); } - mdc_clear_open_replay_data(och); + md_clear_open_replay_data(md_exp, och); ptlrpc_req_finished(req); och->och_fh.cookie = DEAD_HANDLE_MAGIC; LUSTRE_FPRIVATE(file) = NULL; @@ -162,9 +162,9 @@ static int ll_intent_file_open(struct file *file, void *lmm, ll_prepare_md_op_data(&op_data, parent->d_inode, NULL, name, len, O_RDWR); - rc = mdc_enqueue(sbi->ll_md_exp, LDLM_IBITS, itp, LCK_PW, &op_data, - &lockh, lmm, lmmsize, ldlm_completion_ast, - ll_mdc_blocking_ast, NULL, 0); + rc = md_enqueue(sbi->ll_md_exp, LDLM_IBITS, itp, LCK_PW, &op_data, + &lockh, lmm, lmmsize, ldlm_completion_ast, + ll_mdc_blocking_ast, NULL, 0); if (rc < 0) CERROR("lock enqueue: err: %d\n", rc); RETURN(rc); @@ -174,7 +174,9 @@ int ll_local_open(struct file *file, struct lookup_intent *it, struct ll_file_data *fd) { struct ptlrpc_request *req = it->d.lustre.it_data; - struct ll_inode_info *lli = ll_i2info(file->f_dentry->d_inode); + struct inode *inode = file->f_dentry->d_inode; + struct ll_inode_info *lli = ll_i2info(inode); + struct ll_sb_info *sbi = ll_i2sbi(inode); struct mdt_body *body; ENTRY; @@ -189,11 +191,12 @@ int ll_local_open(struct file *file, struct lookup_intent *it, memcpy(&fd->fd_mds_och.och_fh, &body->handle, sizeof(body->handle)); fd->fd_mds_och.och_magic = OBD_CLIENT_HANDLE_MAGIC; LUSTRE_FPRIVATE(file) = fd; - ll_readahead_init(file->f_dentry->d_inode, &fd->fd_ras); + ll_readahead_init(inode, &fd->fd_ras); lli->lli_io_epoch = body->io_epoch; - mdc_set_open_replay_data(&fd->fd_mds_och, it->d.lustre.it_data); + md_set_open_replay_data(sbi->ll_md_exp, &fd->fd_mds_och, + it->d.lustre.it_data); RETURN(0); } @@ -205,7 +208,7 @@ int ll_local_open(struct file *file, struct lookup_intent *it, * stripe MD to the MDS, or try to destroy the objects if that fails. * * If we already have the stripe MD locally then we don't request it in - * mdc_open(), by passing a lmm_size = 0. + * md_open(), by passing a lmm_size = 0. * * It is up to the application to ensure no other processes open this file * in the O_LOV_DELAY_CREATE case, or the default striping pattern will be @@ -248,7 +251,7 @@ int ll_file_open(struct inode *inode, struct file *file) lprocfs_counter_incr(ll_i2sbi(inode)->ll_stats, LPROC_LL_OPEN); rc = it_open_error(DISP_OPEN_OPEN, it); - /* mdc_intent_lock() didn't get a request ref if there was an open + /* md_intent_lock() didn't get a request ref if there was an open * error, so don't do cleanup on the request here (bug 3430) */ if (rc) { ll_file_data_put(fd); @@ -1153,7 +1156,8 @@ static int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, { struct ll_inode_info *lli = ll_i2info(inode); struct file *f = NULL; - struct obd_export *exp = ll_i2dtexp(inode); + struct obd_export *dt_exp = ll_i2dtexp(inode); + struct obd_export *md_exp = ll_i2mdexp(inode); struct lov_stripe_md *lsm; struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags}; struct ptlrpc_request *req = NULL; @@ -1193,7 +1197,7 @@ static int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, if (rc < 0) GOTO(out, rc); - rc = mdc_req2lustre_md(req, 1, exp, &md); + rc = md_get_lustre_md(md_exp, req, 1, dt_exp, &md); if (rc) GOTO(out, rc); ll_update_inode(f->f_dentry->d_inode, &md); @@ -1406,9 +1410,9 @@ static int join_file(struct inode *head_inode, struct file *head_filp, tail_dentry->d_name.name, tail_dentry->d_name.len, 0); - rc = mdc_enqueue(ll_i2mdexp(head_inode), LDLM_IBITS, &oit, LCK_PW, - op_data, &lockh, &tsize, 0, ldlm_completion_ast, - ll_mdc_blocking_ast, &hsize, 0); + rc = md_enqueue(ll_i2mdexp(head_inode), LDLM_IBITS, &oit, LCK_PW, + op_data, &lockh, &tsize, 0, ldlm_completion_ast, + ll_mdc_blocking_ast, &hsize, 0); if (rc < 0) GOTO(out, rc); @@ -1691,8 +1695,8 @@ int ll_fsync(struct file *file, struct dentry *dentry, int data) rc = err; } - err = mdc_sync(ll_i2sbi(inode)->ll_md_exp, - ll_inode2fid(inode), &req); + err = md_sync(ll_i2sbi(inode)->ll_md_exp, + ll_inode2fid(inode), &req); if (!rc) rc = err; if (!err) @@ -1863,13 +1867,13 @@ int ll_inode_revalidate_it(struct dentry *dentry, struct lookup_intent *it) RETURN(rc); valid |= OBD_MD_FLEASIZE | OBD_MD_FLMODEASIZE; } - rc = mdc_getattr(sbi->ll_md_exp, ll_inode2fid(inode), - valid, ealen, &req); + rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), + valid, ealen, &req); if (rc) { CERROR("failure %d inode %lu\n", rc, inode->i_ino); RETURN(-abs(rc)); } - rc = ll_prep_inode(sbi->ll_dt_exp, &inode, req, 0, NULL); + rc = ll_prep_inode(&inode, req, 0, NULL); if (rc) { ptlrpc_req_finished(req); RETURN(rc); diff --git a/lustre/llite/llite_close.c b/lustre/llite/llite_close.c index 500ec88..69c98b2 100644 --- a/lustre/llite/llite_close.c +++ b/lustre/llite/llite_close.c @@ -168,7 +168,7 @@ static void ll_close_done_writing(struct inode *inode) op_data.blocks = inode->i_blocks; op_data.valid = OBD_MD_FLID | OBD_MD_FLSIZE | OBD_MD_FLBLOCKS; - rc = mdc_done_writing(ll_i2sbi(inode)->ll_md_exp, &op_data); + rc = md_done_writing(ll_i2sbi(inode)->ll_md_exp, &op_data); out: } #endif diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index c102d7c..0f28202 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -383,7 +383,7 @@ int ll_lsm_getattr(struct obd_export *, struct lov_stripe_md *, struct obdo *); int ll_glimpse_size(struct inode *inode, int ast_flags); int ll_local_open(struct file *file, struct lookup_intent *it, struct ll_file_data *fd); -int ll_mdc_close(struct obd_export *mdc_exp, struct inode *inode, +int ll_mdc_close(struct obd_export *md_exp, struct inode *inode, struct file *file); #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) int ll_getattr(struct vfsmount *mnt, struct dentry *de, @@ -427,8 +427,8 @@ int ll_iocontrol(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); void ll_umount_begin(struct super_block *sb); int ll_remount_fs(struct super_block *sb, int *flags, char *data); -int ll_prep_inode(struct obd_export *exp, struct inode **inode, - struct ptlrpc_request *req, int offset, struct super_block *); +int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, + int offset, struct super_block *); void lustre_dump_dentry(struct dentry *, int recur); void lustre_dump_inode(struct inode *); struct ll_async_page *llite_pglist_next_llap(struct ll_sb_info *sbi, diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index e02c6e6..b935a65 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -105,6 +105,40 @@ static struct dentry_operations ll_d_root_ops = { .d_compare = ll_dcompare, }; +/* Initialize the default and maximum LOV EA and cookie sizes. This allows + * us to make MDS RPCs with large enough reply buffers to hold the + * maximum-sized (= maximum striped) EA and cookie without having to + * calculate this (via a call into the LOV + OSCs) each time we make an RPC. */ +static int ll_init_ea_size(struct obd_export *md_exp, struct obd_export *dt_exp) +{ + struct lov_stripe_md lsm = { .lsm_magic = LOV_MAGIC }; + __u32 valsize = sizeof(struct lov_desc); + int rc, easize, def_easize, cookiesize; + struct lov_desc desc; + __u32 stripes; + ENTRY; + + rc = obd_get_info(dt_exp, strlen(KEY_LOVDESC) + 1, KEY_LOVDESC, + &valsize, &desc); + if (rc) + RETURN(rc); + + stripes = min(desc.ld_tgt_count, (__u32)LOV_MAX_STRIPE_COUNT); + lsm.lsm_stripe_count = stripes; + easize = obd_size_diskmd(dt_exp, &lsm); + + lsm.lsm_stripe_count = desc.ld_default_stripe_count; + def_easize = obd_size_diskmd(dt_exp, &lsm); + + cookiesize = stripes * sizeof(struct llog_cookie); + + CDEBUG(D_HA, "updating max_mdsize/max_cookiesize: %d/%d\n", + easize, cookiesize); + + rc = md_init_ea_size(md_exp, easize, def_easize, cookiesize); + RETURN(rc); +} + int client_common_fill_super(struct super_block *sb, char *mdc, char *osc) { struct inode *root = 0; @@ -163,6 +197,9 @@ int client_common_fill_super(struct super_block *sb, char *mdc, char *osc) data->ocd_connect_flags |= OBD_CONNECT_VERSION; data->ocd_version = LUSTRE_VERSION_CODE; + /* real client */ + data->ocd_connect_flags |= OBD_CONNECT_REAL; + err = obd_connect(&mdc_conn, obd, &sbi->ll_sb_uuid, data); if (err == -EBUSY) { CERROR("An MDT (mdc %s) is performing recovery, of which this" @@ -251,7 +288,7 @@ int client_common_fill_super(struct super_block *sb, char *mdc, char *osc) sbi->ll_lco.lco_flags = data->ocd_connect_flags; spin_unlock(&sbi->ll_lco.lco_lock); - mdc_init_ea_size(sbi->ll_md_exp, sbi->ll_dt_exp); + ll_init_ea_size(sbi->ll_md_exp, sbi->ll_dt_exp); err = obd_prep_async_page(sbi->ll_dt_exp, NULL, NULL, NULL, 0, NULL, NULL, NULL); @@ -272,7 +309,7 @@ int client_common_fill_super(struct super_block *sb, char *mdc, char *osc) GOTO(out_osc, -ENOMEM); } - err = mdc_getstatus(sbi->ll_md_exp, &rootfid); + err = md_getstatus(sbi->ll_md_exp, &rootfid); if (err) { CERROR("cannot mds_connect: rc = %d\n", err); GOTO(out_osc, err); @@ -292,16 +329,16 @@ int client_common_fill_super(struct super_block *sb, char *mdc, char *osc) /* make root inode * XXX: move this to after cbd setup? */ - err = mdc_getattr(sbi->ll_md_exp, &rootfid, - OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS | - (sbi->ll_flags & LL_SBI_ACL ? OBD_MD_FLACL : 0), - 0, &request); + err = md_getattr(sbi->ll_md_exp, &rootfid, + OBD_MD_FLGETATTR | OBD_MD_FLBLOCKS | + (sbi->ll_flags & LL_SBI_ACL ? OBD_MD_FLACL : 0), + 0, &request); if (err) { CERROR("mdc_getattr failed for root: rc = %d\n", err); GOTO(out_osc, err); } - err = mdc_req2lustre_md(request, 0, sbi->ll_dt_exp, &md); + err = md_get_lustre_md(sbi->ll_md_exp, request, 0, sbi->ll_dt_exp, &md); if (err) { CERROR("failed to understand root inode md: rc = %d\n", err); ptlrpc_req_finished (request); @@ -313,7 +350,7 @@ int client_common_fill_super(struct super_block *sb, char *mdc, char *osc) ptlrpc_req_finished(request); if (root == NULL || is_bad_inode(root)) { - mdc_free_lustre_md(sbi->ll_dt_exp, &md); + md_free_lustre_md(sbi->ll_dt_exp, &md); CERROR("lustre_lite: bad iget4 for root\n"); GOTO(out_root, err = -EBADF); } @@ -805,8 +842,8 @@ void ll_clear_inode(struct inode *inode) inode->i_generation, inode); clear_bit(LLI_F_HAVE_MDS_SIZE_LOCK, &(ll_i2info(inode)->lli_flags)); - mdc_change_cbdata(sbi->ll_md_exp, ll_inode2fid(inode), - null_if_equal, inode); + md_change_cbdata(sbi->ll_md_exp, ll_inode2fid(inode), + null_if_equal, inode); if (lli->lli_smd) { obd_change_cbdata(sbi->ll_dt_exp, lli->lli_smd, @@ -915,8 +952,8 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) struct lustre_md md; ll_prepare_md_op_data(&op_data, inode, NULL, NULL, 0, 0); - rc = mdc_setattr(sbi->ll_md_exp, &op_data, - attr, NULL, 0, NULL, 0, &request); + rc = md_setattr(sbi->ll_md_exp, &op_data, + attr, NULL, 0, NULL, 0, &request); if (rc) { ptlrpc_req_finished(request); @@ -925,7 +962,7 @@ int ll_setattr_raw(struct inode *inode, struct iattr *attr) RETURN(rc); } - rc = mdc_req2lustre_md(request, 0, sbi->ll_dt_exp, &md); + rc = md_get_lustre_md(sbi->ll_md_exp, request, 0, sbi->ll_dt_exp, &md); if (rc) { ptlrpc_req_finished(request); RETURN(rc); @@ -1361,8 +1398,8 @@ int ll_iocontrol(struct inode *inode, struct file *file, case EXT3_IOC_GETFLAGS: { struct mdt_body *body; - rc = mdc_getattr(sbi->ll_md_exp, ll_inode2fid(inode), - OBD_MD_FLFLAGS, 0, &req); + rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), + OBD_MD_FLFLAGS, 0, &req); if (rc) { CERROR("failure %d inode %lu\n", rc, inode->i_ino); RETURN(-abs(rc)); @@ -1400,8 +1437,8 @@ int ll_iocontrol(struct inode *inode, struct file *file, attr.ia_attr_flags = flags; attr.ia_valid |= ATTR_ATTR_FLAG; - rc = mdc_setattr(sbi->ll_md_exp, &op_data, - &attr, NULL, 0, NULL, 0, &req); + rc = md_setattr(sbi->ll_md_exp, &op_data, + &attr, NULL, 0, NULL, 0, &req); if (rc || lsm == NULL) { ptlrpc_req_finished(req); obdo_free(oa); @@ -1514,9 +1551,8 @@ int ll_remount_fs(struct super_block *sb, int *flags, char *data) return 0; } -int ll_prep_inode(struct obd_export *exp, struct inode **inode, - struct ptlrpc_request *req, int offset, - struct super_block *sb) +int ll_prep_inode(struct inode **inode, struct ptlrpc_request *req, + int offset, struct super_block *sb) { struct ll_sb_info *sbi = NULL; struct lustre_md md; @@ -1527,7 +1563,8 @@ int ll_prep_inode(struct obd_export *exp, struct inode **inode, sbi = sb ? ll_s2sbi(sb) : ll_i2sbi(*inode); prune_deathrow(sbi, 1); - rc = mdc_req2lustre_md(req, offset, exp, &md); + rc = md_get_lustre_md(sbi->ll_md_exp, req, offset, + sbi->ll_dt_exp, &md); if (rc) RETURN(rc); @@ -1543,7 +1580,7 @@ int ll_prep_inode(struct obd_export *exp, struct inode **inode, *inode = ll_iget(sb, ll_fid_build_ino(sbi, &md.body->fid1), &md); if (*inode == NULL || is_bad_inode(*inode)) { - mdc_free_lustre_md(exp, &md); + md_free_lustre_md(sbi->ll_dt_exp, &md); rc = -ENOMEM; CERROR("new_inode -fatal: rc %d\n", rc); GOTO(out, rc); @@ -1551,7 +1588,7 @@ int ll_prep_inode(struct obd_export *exp, struct inode **inode, ll_i2info(*inode)->lli_fid = md.body->fid1; } - rc = obd_checkmd(exp, ll_i2mdexp(*inode), + rc = obd_checkmd(sbi->ll_dt_exp, sbi->ll_md_exp, ll_i2info(*inode)->lli_smd); out: RETURN(rc); diff --git a/lustre/llite/llite_nfs.c b/lustre/llite/llite_nfs.c index cf12f5e..d458ebf02 100644 --- a/lustre/llite/llite_nfs.c +++ b/lustre/llite/llite_nfs.c @@ -79,14 +79,14 @@ static struct inode *search_inode_for_lustre(struct super_block *sb, valid |= OBD_MD_FLEASIZE; } - rc = mdc_getattr(sbi->ll_md_exp, fid, valid, eadatalen, &req); + rc = md_getattr(sbi->ll_md_exp, fid, valid, eadatalen, &req); if (rc) { CERROR("can't get object attrs, fid "DFID3", rc %d\n", PFID3(fid), rc); return ERR_PTR(rc); } - rc = ll_prep_inode(sbi->ll_dt_exp, &inode, req, 0, sb); + rc = ll_prep_inode(&inode, req, 0, sb); if (rc) { ptlrpc_req_finished(req); return ERR_PTR(rc); diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index dc691bb..edec18f 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -336,14 +336,15 @@ static int lookup_it_finish(struct ptlrpc_request *request, int offset, if (!it_disposition(it, DISP_LOOKUP_NEG)) { ENTRY; - rc = ll_prep_inode(sbi->ll_dt_exp, &inode, request, offset, + rc = ll_prep_inode(&inode, request, offset, (*de)->d_sb); if (rc) RETURN(rc); CDEBUG(D_DLMTRACE, "setting l_data to inode %p (%lu/%u)\n", inode, inode->i_ino, inode->i_generation); - mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode); + md_set_lock_data(sbi->ll_md_exp, + &it->d.lustre.it_lock_handle, inode); /* We used to query real size from OSTs here, but actually this is not needed. For stat() calls size would be updated @@ -408,8 +409,8 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry, it->it_create_mode &= ~current->fs->umask; - rc = mdc_intent_lock(ll_i2mdexp(parent), &op_data, NULL, 0, it, - lookup_flags, &req, ll_mdc_blocking_ast, 0); + rc = md_intent_lock(ll_i2mdexp(parent), &op_data, NULL, 0, it, + lookup_flags, &req, ll_mdc_blocking_ast, 0); if (rc < 0) GOTO(out, retval = ERR_PTR(rc)); @@ -463,7 +464,7 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, LASSERT(it && it->d.lustre.it_disposition); request = it->d.lustre.it_data; - rc = ll_prep_inode(sbi->ll_dt_exp, &inode, request, 1, dir->i_sb); + rc = ll_prep_inode(&inode, request, 1, dir->i_sb); if (rc) GOTO(out, inode = ERR_PTR(rc)); @@ -474,7 +475,8 @@ static struct inode *ll_create_node(struct inode *dir, const char *name, * stuff it in the lock. */ CDEBUG(D_DLMTRACE, "setting l_ast_data to inode %p (%lu/%u)\n", inode, inode->i_ino, inode->i_generation); - mdc_set_lock_data(&it->d.lustre.it_lock_handle, inode); + md_set_lock_data(sbi->ll_md_exp, + &it->d.lustre.it_lock_handle, inode); EXIT; out: ptlrpc_req_finished(request); @@ -571,9 +573,9 @@ static int ll_mknod_raw(struct nameidata *nd, int mode, dev_t rdev) ll_prepare_md_op_data(&op_data, dir, NULL, nd->last.name, nd->last.len, 0); - err = mdc_create(sbi->ll_md_exp, &op_data, NULL, 0, mode, - current->fsuid, current->fsgid, - current->cap_effective, rdev, &request); + err = md_create(sbi->ll_md_exp, &op_data, NULL, 0, mode, + current->fsuid, current->fsgid, + current->cap_effective, rdev, &request); if (err == 0) ll_update_times(request, 0, dir); ptlrpc_req_finished(request); @@ -621,16 +623,15 @@ static int ll_mknod(struct inode *dir, struct dentry *dchild, int mode, ll_prepare_md_op_data(&op_data, dir, NULL, dchild->d_name.name, dchild->d_name.len, 0); - err = mdc_create(sbi->ll_md_exp, &op_data, NULL, 0, mode, - current->fsuid, current->fsgid, - current->cap_effective, rdev, &request); + err = md_create(sbi->ll_md_exp, &op_data, NULL, 0, mode, + current->fsuid, current->fsgid, + current->cap_effective, rdev, &request); if (err) GOTO(out_err, err); ll_update_times(request, 0, dir); - err = ll_prep_inode(sbi->ll_dt_exp, &inode, request, 0, - dchild->d_sb); + err = ll_prep_inode(&inode, request, 0, dchild->d_sb); if (err) GOTO(out_err, err); break; @@ -670,10 +671,10 @@ static int ll_symlink_raw(struct nameidata *nd, const char *tgt) ll_prepare_md_op_data(&op_data, dir, NULL, nd->last.name, nd->last.len, 0); - err = mdc_create(sbi->ll_md_exp, &op_data, - tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO, - current->fsuid, current->fsgid, current->cap_effective, - 0, &request); + err = md_create(sbi->ll_md_exp, &op_data, + tgt, strlen(tgt) + 1, S_IFLNK | S_IRWXUGO, + current->fsuid, current->fsgid, current->cap_effective, + 0, &request); if (err == 0) ll_update_times(request, 0, dir); @@ -699,7 +700,7 @@ static int ll_link_raw(struct nameidata *srcnd, struct nameidata *tgtnd) ll_prepare_md_op_data(&op_data, src, dir, tgtnd->last.name, tgtnd->last.len, 0); - err = mdc_link(sbi->ll_md_exp, &op_data, &request); + err = md_link(sbi->ll_md_exp, &op_data, &request); if (err == 0) ll_update_times(request, 0, dir); @@ -732,9 +733,9 @@ static int ll_mkdir_raw(struct nameidata *nd, int mode) ll_prepare_md_op_data(&op_data, dir, NULL, nd->last.name, nd->last.len, 0); - err = mdc_create(sbi->ll_md_exp, &op_data, NULL, 0, mode, - current->fsuid, current->fsgid, current->cap_effective, - 0, &request); + err = md_create(sbi->ll_md_exp, &op_data, NULL, 0, mode, + current->fsuid, current->fsgid, current->cap_effective, + 0, &request); if (err == 0) ll_update_times(request, 0, dir); @@ -766,7 +767,7 @@ static int ll_rmdir_raw(struct nameidata *nd) ll_prepare_md_op_data(&op_data, dir, NULL, nd->last.name, nd->last.len, S_IFDIR); - rc = mdc_unlink(ll_i2sbi(dir)->ll_md_exp, &op_data, &request); + rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, &op_data, &request); if (rc == 0) ll_update_times(request, 0, dir); ptlrpc_req_finished(request); @@ -860,7 +861,7 @@ static int ll_unlink_raw(struct nameidata *nd) ll_prepare_md_op_data(&op_data, dir, NULL, nd->last.name, nd->last.len, 0); - rc = mdc_unlink(ll_i2sbi(dir)->ll_md_exp, &op_data, &request); + rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, &op_data, &request); if (rc) GOTO(out, rc); @@ -888,9 +889,9 @@ static int ll_rename_raw(struct nameidata *srcnd, struct nameidata *tgtnd) ll_prepare_md_op_data(&op_data, src, tgt, NULL, 0, 0); - err = mdc_rename(sbi->ll_md_exp, &op_data, - srcnd->last.name, srcnd->last.len, - tgtnd->last.name, tgtnd->last.len, &request); + err = md_rename(sbi->ll_md_exp, &op_data, + srcnd->last.name, srcnd->last.len, + tgtnd->last.name, tgtnd->last.len, &request); if (!err) { ll_update_times(request, 0, src); ll_update_times(request, 0, tgt); diff --git a/lustre/llite/symlink.c b/lustre/llite/symlink.c index a142f4c..2d713bc 100644 --- a/lustre/llite/symlink.c +++ b/lustre/llite/symlink.c @@ -46,8 +46,8 @@ static int ll_readlink_internal(struct inode *inode, RETURN(0); } - rc = mdc_getattr(sbi->ll_md_exp, ll_inode2fid(inode), - OBD_MD_LINKNAME, symlen, request); + rc = md_getattr(sbi->ll_md_exp, ll_inode2fid(inode), + OBD_MD_LINKNAME, symlen, request); if (rc) { if (rc != -ENOENT) CERROR("inode %lu: rc = %d\n", inode->i_ino, rc); diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c index 7bc744b..2e0e1f3 100644 --- a/lustre/llite/xattr.c +++ b/lustre/llite/xattr.c @@ -104,8 +104,8 @@ int ll_setxattr_common(struct inode *inode, const char *name, if (rc) RETURN(rc); - rc = mdc_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, - name, value, size, 0, flags, &req); + rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, + name, value, size, 0, flags, &req); if (rc) { if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) { LCONSOLE_INFO("Disabling user_xattr feature because " @@ -179,8 +179,8 @@ int ll_getxattr_common(struct inode *inode, const char *name, RETURN(rc); do_getxattr: - rc = mdc_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, - name, NULL, 0, size, &req); + rc = md_getxattr(sbi->ll_md_exp, ll_inode2fid(inode), valid, + name, NULL, 0, size, 0, &req); if (rc) { if (rc == -EOPNOTSUPP && xattr_type == XATTR_USER_T) { LCONSOLE_INFO("Disabling user_xattr feature because " diff --git a/lustre/lmv/Makefile.in b/lustre/lmv/Makefile.in index 9e7fb8a..2f77e68 100644 --- a/lustre/lmv/Makefile.in +++ b/lustre/lmv/Makefile.in @@ -1,4 +1,4 @@ MODULES := lmv -lmv-objs := lmv_obd.o lmv_intent.o lmv_fld.o lmv_objmgr.o lproc_lmv.o +lmv-objs := lmv_obd.o lmv_intent.o lmv_fld.o lmv_object.o lproc_lmv.o @INCLUDE_RULES@ diff --git a/lustre/lmv/autoMakefile.am b/lustre/lmv/autoMakefile.am index aafe1d5..6a9913c 100644 --- a/lustre/lmv/autoMakefile.am +++ b/lustre/lmv/autoMakefile.am @@ -5,7 +5,7 @@ if LIBLUSTRE noinst_LIBRARIES = liblmv.a -liblmv_a_SOURCES = lmv_obd.c lmv_intent.c lmv_objmgr.c lmv_fld.c +liblmv_a_SOURCES = lmv_obd.c lmv_intent.c lmv_object.c lmv_fld.c liblmv_a_CPPFLAGS = $(LLCPPFLAGS) liblmv_a_CFLAGS = $(LLCFLAGS) endif diff --git a/lustre/lmv/lmv_fld.c b/lustre/lmv/lmv_fld.c index 45ca74d..087b60e 100644 --- a/lustre/lmv/lmv_fld.c +++ b/lustre/lmv/lmv_fld.c @@ -48,5 +48,5 @@ int lmv_fld_lookup(struct obd_device *obd, struct lu_fid *fid) { ENTRY; - RETUR(-ENOTSUPP); + RETURN(-ENOTSUPP); } diff --git a/lustre/lmv/lmv_intent.c b/lustre/lmv/lmv_intent.c index 93152ae..a0f31dc 100644 --- a/lustre/lmv/lmv_intent.c +++ b/lustre/lmv/lmv_intent.c @@ -51,16 +51,18 @@ static inline void lmv_drop_intent_lock(struct lookup_intent *it) { - if (LUSTRE_IT(it)->it_lock_mode != 0) - ldlm_lock_decref((void *)&LUSTRE_IT(it)->it_lock_handle, - LUSTRE_IT(it)->it_lock_mode); + if (it->d.lustre.it_lock_mode != 0) + ldlm_lock_decref((void *)&it->d.lustre.it_lock_handle, + it->d.lustre.it_lock_mode); } int lmv_intent_remote(struct obd_export *exp, void *lmm, int lmmsize, struct lookup_intent *it, int flags, struct ptlrpc_request **reqp, - ldlm_blocking_callback cb_blocking) + ldlm_blocking_callback cb_blocking, + int extra_lock_flags) { + struct md_op_data op_data = { { 0 } }; struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct ptlrpc_request *req = NULL; @@ -80,7 +82,7 @@ int lmv_intent_remote(struct obd_export *exp, void *lmm, * oh, MDS reports that this is remote inode case i.e. we have to ask * for real attrs on another MDS. */ - if (it->it_op == IT_LOOKUP || it->it_op == IT_CHDIR) { + if (it->it_op == IT_LOOKUP/* || it->it_op == IT_CHDIR*/) { /* * unfortunately, we have to lie to MDC/MDS to retrieve * attributes llite needs. @@ -89,33 +91,32 @@ int lmv_intent_remote(struct obd_export *exp, void *lmm, } /* we got LOOKUP lock, but we really need attrs */ - pmode = LUSTRE_IT(it)->it_lock_mode; + pmode = it->d.lustre.it_lock_mode; if (pmode) { - memcpy(&plock, &LUSTRE_IT(it)->it_lock_handle, + memcpy(&plock, &it->d.lustre.it_lock_handle, sizeof(plock)); - LUSTRE_IT(it)->it_lock_mode = 0; - LUSTRE_IT(it)->it_data = 0; + it->d.lustre.it_lock_mode = 0; + it->d.lustre.it_data = 0; } - LASSERT((body->valid & OBD_MD_FID) != 0); + LASSERT(fid_num(&body->fid1) != 0); nid = body->fid1; - LUSTRE_IT(it)->it_disposition &= ~DISP_ENQ_COMPLETE; + it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE; + op_data.fid1 = nid; i = lmv_fld_lookup(obd, &nid); - rc = md_intent_lock(lmv->tgts[i].ltd_exp, &nid, - NULL, 0, lmm, lmmsize, NULL, it, flags, - &req, cb_blocking); + rc = md_intent_lock(lmv->tgts[i].ltd_exp, &op_data, + lmm, lmmsize, it, flags, &req, + cb_blocking, extra_lock_flags); - /* - * llite needs LOOKUP lock to track dentry revocation in order to + /*llite needs LOOKUP lock to track dentry revocation in order to * maintain dcache consistency. Thus drop UPDATE lock here and put - * LOOKUP in request. - */ + * LOOKUP in request. */ if (rc == 0) { lmv_drop_intent_lock(it); - memcpy(&LUSTRE_IT(it)->it_lock_handle, &plock, + memcpy(&it->d.lustre.it_lock_handle, &plock, sizeof(plock)); - LUSTRE_IT(it)->it_lock_mode = pmode; + it->d.lustre.it_lock_mode = pmode; } else if (pmode) { ldlm_lock_decref(&plock, pmode); } @@ -129,15 +130,17 @@ int lmv_intent_open(struct obd_export *exp, struct lu_fid *pid, const char *name, int len, void *lmm, int lmmsize, struct lu_fid *cid, struct lookup_intent *it, int flags, struct ptlrpc_request **reqp, - ldlm_blocking_callback cb_blocking) + ldlm_blocking_callback cb_blocking, + int extra_lock_flags) { + struct md_op_data op_data = { { 0 } }; struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct mdt_body *body = NULL; struct lu_fid rpid = *pid; int rc, mds, loop = 0; struct lmv_obj *obj; - struct mea *mea; + struct lmv_stripe_md *mea; ENTRY; /* IT_OPEN is intended to open (and create, possible) an object. Parent @@ -146,7 +149,7 @@ int lmv_intent_open(struct obd_export *exp, struct lu_fid *pid, repeat: LASSERT(++loop <= 2); mds = lmv_fld_lookup(obd, &rpid); - obj = lmv_grab_obj(obd, &rpid); + obj = lmv_obj_grab(obd, &rpid); if (obj) { /* directory is already splitted, so we have to forward * request to the right MDS */ @@ -156,12 +159,18 @@ repeat: CDEBUG(D_OTHER, "forward to MDS #%u ("DFID3")\n", mds, PFID3(&rpid)); rpid = obj->lo_objs[mds].li_fid; - lmv_put_obj(obj); + lmv_obj_put(obj); } + op_data.fid1 = rpid; + op_data.fid2 = *cid; + op_data.name = name; + op_data.namelen = len; + mds = lmv_fld_lookup(obd, &rpid); - rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &rpid, name, - len, lmm, lmmsize, cid, it, flags, reqp, cb_blocking); + rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &op_data, + lmm, lmmsize, it, flags, reqp, + cb_blocking, extra_lock_flags); if (rc == -ERESTART) { /* directory got splitted. time to update local object and * repeat the request with proper MDS */ @@ -177,7 +186,8 @@ repeat: /* okay, MDS has returned success. Probably name has been resolved in * remote inode */ - rc = lmv_intent_remote(exp, lmm, lmmsize, it, flags, reqp, cb_blocking); + rc = lmv_intent_remote(exp, lmm, lmmsize, it, flags, reqp, + cb_blocking, extra_lock_flags); if (rc != 0) { LASSERT(rc < 0); @@ -197,9 +207,9 @@ repeat: * nothing is found, do not access body->fid1 as it is zero and thus * pointless. */ - if ((LUSTRE_IT(it)->it_disposition & DISP_LOOKUP_NEG) && - !(LUSTRE_IT(it)->it_disposition & DISP_OPEN_CREATE) && - !(LUSTRE_IT(it)->it_disposition & DISP_OPEN_OPEN)) + if ((it->d.lustre.it_disposition & DISP_LOOKUP_NEG) && + !(it->d.lustre.it_disposition & DISP_OPEN_CREATE) && + !(it->d.lustre.it_disposition & DISP_OPEN_OPEN)) RETURN(0); /* caller may use attrs MDS returns on IT_OPEN lock request so, we have @@ -208,14 +218,14 @@ repeat: LASSERT(body != NULL); /* could not find object, FID is not present in response. */ - if (!(body->valid & OBD_MD_FID)) - RETURN(0); +/* if (!(body->valid & OBD_MD_FID)) + RETURN(0);*/ cid = &body->fid1; - obj = lmv_grab_obj(obd, cid); + obj = lmv_obj_grab(obd, cid); if (!obj && (mea = lmv_splitted_dir_body(*reqp, 1))) { /* wow! this is splitted dir, we'd like to handle it */ - obj = lmv_create_obj(exp, &body->fid1, mea); + obj = lmv_obj_create(exp, &body->fid1, mea); if (IS_ERR(obj)) RETURN(PTR_ERR(obj)); } @@ -226,14 +236,14 @@ repeat: PFID3(cid)); rc = lmv_revalidate_slaves(exp, reqp, cid, it, 1, - cb_blocking); + cb_blocking, extra_lock_flags); } else if (S_ISDIR(body->mode)) { CDEBUG(D_OTHER, "object "DFID3" has not lmv obj?\n", PFID3(cid)); } if (obj) - lmv_put_obj(obj); + lmv_obj_put(obj); RETURN(rc); } @@ -242,14 +252,16 @@ int lmv_intent_getattr(struct obd_export *exp, struct lu_fid *pid, const char *name, int len, void *lmm, int lmmsize, struct lu_fid *cid, struct lookup_intent *it, int flags, struct ptlrpc_request **reqp, - ldlm_blocking_callback cb_blocking) + ldlm_blocking_callback cb_blocking, + int extra_lock_flags) { + struct lmv_obj *obj = NULL, *obj2 = NULL; + struct md_op_data op_data = { { 0 } }; struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct mdt_body *body = NULL; struct lu_fid rpid = *pid; - struct lmv_obj *obj = NULL, *obj2 = NULL; - struct mea *mea; + struct lmv_stripe_md *mea; int rc = 0, mds; ENTRY; @@ -259,7 +271,7 @@ int lmv_intent_getattr(struct obd_export *exp, struct lu_fid *pid, CDEBUG(D_OTHER, "revalidate attrs for "DFID3"\n", PFID3(cid)); mds = lmv_fld_lookup(obd, cid); #if 0 - obj = lmv_grab_obj(obd, cid); + obj = lmv_obj_grab(obd, cid); if (obj) { /* in fact, we need not this with current intent_lock(), * but it may change some day */ @@ -267,30 +279,36 @@ int lmv_intent_getattr(struct obd_export *exp, struct lu_fid *pid, rpid = obj->lo_objs[mds].li_fid; mds = lmv_fld_lookup(obd, &rpid); } - lmv_put_obj(obj); + lmv_obj_put(obj); } #endif } else { CDEBUG(D_OTHER, "INTENT getattr for %*s on "DFID3"\n", len, name, PFID3(pid)); mds = lmv_fld_lookup(obd, pid); - obj = lmv_grab_obj(obd, pid); + obj = lmv_obj_grab(obd, pid); if (obj && len) { /* directory is already splitted. calculate mds */ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount, (char *)name, len); rpid = obj->lo_objs[mds].li_fid; mds = lmv_fld_lookup(obd, &rpid); - lmv_put_obj(obj); + lmv_obj_put(obj); CDEBUG(D_OTHER, "forward to MDS #%u (slave "DFID3")\n", mds, PFID3(&rpid)); } } + op_data.fid1 = rpid; + op_data.fid2 = *cid; + op_data.name = name; + op_data.namelen = len; + /* the same about fid returning. */ - rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &rpid, name, len, lmm, - lmmsize, cid, it, flags, reqp, cb_blocking); + rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &op_data, lmm, + lmmsize, it, flags, reqp, cb_blocking, + extra_lock_flags); if (rc < 0) RETURN(rc); @@ -307,7 +325,7 @@ int lmv_intent_getattr(struct obd_export *exp, struct lu_fid *pid, LASSERT(cid != 0); rc = lmv_revalidate_slaves(exp, reqp, cid, it, rc, - cb_blocking); + cb_blocking, extra_lock_flags); RETURN(rc); } @@ -317,7 +335,7 @@ int lmv_intent_getattr(struct obd_export *exp, struct lu_fid *pid, /* okay, MDS has returned success. probably name has been * resolved in remote inode */ rc = lmv_intent_remote(exp, lmm, lmmsize, it, flags, - reqp, cb_blocking); + reqp, cb_blocking, extra_lock_flags); if (rc < 0) RETURN(rc); @@ -325,25 +343,25 @@ int lmv_intent_getattr(struct obd_export *exp, struct lu_fid *pid, * nothing is found, do not access body->fid1 as it is zero and thus * pointless. */ - if (LUSTRE_IT(it)->it_disposition & DISP_LOOKUP_NEG) + if (it->d.lustre.it_disposition & DISP_LOOKUP_NEG) RETURN(0); body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body)); LASSERT(body != NULL); /* could not find object, FID is not present in response. */ - if (!(body->valid & OBD_MD_FID)) - RETURN(0); +/* if (!(body->valid & OBD_MD_FID)) + RETURN(0);*/ cid = &body->fid1; - obj2 = lmv_grab_obj(obd, cid); + obj2 = lmv_obj_grab(obd, cid); if (!obj2 && (mea = lmv_splitted_dir_body(*reqp, 1))) { /* wow! this is splitted dir, we'd like to handle it. */ body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body)); LASSERT(body != NULL); - obj2 = lmv_create_obj(exp, &body->fid1, mea); + obj2 = lmv_obj_create(exp, &body->fid1, mea); if (IS_ERR(obj2)) RETURN(PTR_ERR(obj2)); } @@ -354,8 +372,8 @@ int lmv_intent_getattr(struct obd_export *exp, struct lu_fid *pid, PFID3(cid), rc); rc = lmv_revalidate_slaves(exp, reqp, cid, it, 1, - cb_blocking); - lmv_put_obj(obj2); + cb_blocking, extra_lock_flags); + lmv_obj_put(obj2); } RETURN(rc); } @@ -363,9 +381,10 @@ int lmv_intent_getattr(struct obd_export *exp, struct lu_fid *pid, void lmv_update_body_from_obj(struct mdt_body *body, struct lmv_inode *obj) { /* update size */ - body->size += obj->lo_size; + body->size += obj->li_size; } +/* this is not used currently */ int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp) { struct obd_device *obd = exp->exp_obd; @@ -393,18 +412,19 @@ int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp) body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body)); LASSERT(body != NULL); - LASSERT((body->valid & OBD_MD_FID) != 0); +// LASSERT((body->valid & OBD_MD_FID) != 0); - obj = lmv_grab_obj(obd, &body->fid1); + obj = lmv_obj_grab(obd, &body->fid1); LASSERT(obj != NULL); CDEBUG(D_OTHER, "lookup slaves for "DFID3"\n", PFID3(&body->fid1)); - lmv_lock_obj(obj); + lmv_obj_lock(obj); for (i = 0; i < obj->lo_objcount; i++) { struct lu_fid fid = obj->lo_objs[i].li_fid; + struct md_op_data op_data = { { 0 } }; struct ptlrpc_request *req = NULL; struct lookup_intent it; int mds; @@ -418,16 +438,16 @@ int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp) /* is obj valid? */ memset(&it, 0, sizeof(it)); it.it_op = IT_GETATTR; - OBD_ALLOC(it.d.fs_data, sizeof(struct lustre_intent_data)); - if (!it.d.fs_data) - GOTO(cleanup, rc = -ENOMEM); - + + op_data.fid1 = fid; + op_data.fid2 = fid; + mds = lmv_fld_lookup(obd, &fid); - rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &fid, - NULL, 0, NULL, 0, &fid, &it, 0, &req, - lmv_dirobj_blocking_ast); + rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &op_data, + NULL, 0, &it, 0, &req, + lmv_dirobj_blocking_ast, 0); - lockh = (struct lustre_handle *)&LUSTRE_IT(&it)->it_lock_handle; + lockh = (struct lustre_handle *)&it.d.lustre.it_lock_handle; if (rc > 0 && req == NULL) { /* nice, this slave is valid */ LASSERT(req == NULL); @@ -436,14 +456,13 @@ int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp) } if (rc < 0) { - OBD_FREE(it.d.fs_data, sizeof(struct lustre_intent_data)); /* error during lookup */ GOTO(cleanup, rc); } lock = ldlm_handle2lock(lockh); LASSERT(lock); - lock->l_ast_data = lmv_get_obj(obj); + lock->l_ast_data = lmv_obj_get(obj); body2 = lustre_msg_buf(req->rq_repmsg, 1, sizeof(*body2)); LASSERT(body2); @@ -460,15 +479,14 @@ int lmv_lookup_slaves(struct obd_export *exp, struct ptlrpc_request **reqp) release_lock: lmv_update_body_from_obj(body, obj->lo_objs + i); - if (LUSTRE_IT(&it)->it_lock_mode) - ldlm_lock_decref(lockh, LUSTRE_IT(&it)->it_lock_mode); - OBD_FREE(it.d.fs_data, sizeof(struct lustre_intent_data)); + if (it.d.lustre.it_lock_mode) + ldlm_lock_decref(lockh, it.d.lustre.it_lock_mode); } EXIT; cleanup: - lmv_unlock_obj(obj); - lmv_put_obj(obj); + lmv_obj_unlock(obj); + lmv_obj_put(obj); return rc; } @@ -476,14 +494,16 @@ int lmv_intent_lookup(struct obd_export *exp, struct lu_fid *pid, const char *name, int len, void *lmm, int lmmsize, struct lu_fid *cid, struct lookup_intent *it, int flags, struct ptlrpc_request **reqp, - ldlm_blocking_callback cb_blocking) + ldlm_blocking_callback cb_blocking, + int extra_lock_flags) { + struct md_op_data op_data = { { 0 } }; struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct mdt_body *body = NULL; struct lu_fid rpid = *pid; struct lmv_obj *obj; - struct mea *mea; + struct lmv_stripe_md *mea; int rc, mds, loop = 0; ENTRY; @@ -499,12 +519,12 @@ int lmv_intent_lookup(struct obd_export *exp, struct lu_fid *pid, * choose right mds because namespace is per mds. */ rpid = *pid; - obj = lmv_grab_obj(obd, pid); + obj = lmv_obj_grab(obd, pid); if (obj) { mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount, (char *)name, len); rpid = obj->lo_objs[mds].li_fid; - lmv_put_obj(obj); + lmv_obj_put(obj); } mds = lmv_fld_lookup(obd, &rpid); @@ -520,7 +540,7 @@ repeat: * attributes, because returned values will be put in struct * inode */ - obj = lmv_grab_obj(obd, pid); + obj = lmv_obj_grab(obd, pid); if (obj) { if (len) { /* directory is already splitted. calculate mds */ @@ -529,12 +549,17 @@ repeat: rpid = obj->lo_objs[mds].li_fid; mds = lmv_fld_lookup(obd, &rpid); } - lmv_put_obj(obj); + lmv_obj_put(obj); } } - rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &rpid, name, - len, lmm, lmmsize, cid, it, flags, - reqp, cb_blocking); + + op_data.fid1 = rpid; + op_data.fid2 = *cid; + op_data.name = name; + op_data.namelen = len; + + rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &op_data, lmm, lmmsize, + it, flags, reqp, cb_blocking, extra_lock_flags); if (rc > 0) { LASSERT(cid != 0); RETURN(rc); @@ -562,10 +587,10 @@ repeat: CWARN("we haven't knew about directory splitting!\n"); LASSERT(obj == NULL); - obj = lmv_create_obj(exp, &rpid, NULL); + obj = lmv_obj_create(exp, &rpid, NULL); if (IS_ERR(obj)) RETURN(PTR_ERR(obj)); - lmv_put_obj(obj); + lmv_obj_put(obj); goto repeat; } @@ -574,38 +599,44 @@ repeat: /* okay, MDS has returned success. Probably name has been resolved in * remote inode. */ - rc = lmv_intent_remote(exp, lmm, lmmsize, it, flags, reqp, cb_blocking); + rc = lmv_intent_remote(exp, lmm, lmmsize, it, flags, reqp, + cb_blocking, extra_lock_flags); if (rc == 0 && (mea = lmv_splitted_dir_body(*reqp, 1))) { /* wow! this is splitted dir, we'd like to handle it */ body = lustre_msg_buf((*reqp)->rq_repmsg, 1, sizeof(*body)); LASSERT(body != NULL); - LASSERT((body->valid & OBD_MD_FID) != 0); +// LASSERT((body->valid & OBD_MD_FID) != 0); - obj = lmv_grab_obj(obd, &body->fid1); + obj = lmv_obj_grab(obd, &body->fid1); if (!obj) { - obj = lmv_create_obj(exp, &body->fid1, mea); + obj = lmv_obj_create(exp, &body->fid1, mea); if (IS_ERR(obj)) RETURN(PTR_ERR(obj)); } - lmv_put_obj(obj); + lmv_obj_put(obj); } RETURN(rc); } -int lmv_intent_lock(struct obd_export *exp, struct lu_fid *pid, - const char *name, int len, void *lmm, int lmmsize, - struct lu_fid *cid, struct lookup_intent *it, +int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data, + void *lmm, int lmmsize, struct lookup_intent *it, int flags, struct ptlrpc_request **reqp, - ldlm_blocking_callback cb_blocking) + ldlm_blocking_callback cb_blocking, + int extra_lock_flags) { struct obd_device *obd = exp->exp_obd; + const char *name = op_data->name; + int len = op_data->namelen; + struct lu_fid *pid, *cid; int rc, i = 0; ENTRY; LASSERT(it); - LASSERT(pid); + + pid = &op_data->fid1; + cid = &op_data->fid2; i = lmv_fld_lookup(obd, pid); CDEBUG(D_OTHER, "INTENT LOCK '%s' for '%*s' on "DFID3" -> %d\n", @@ -618,15 +649,15 @@ int lmv_intent_lock(struct obd_export *exp, struct lu_fid *pid, if (it->it_op == IT_LOOKUP) rc = lmv_intent_lookup(exp, pid, name, len, lmm, lmmsize, cid, it, flags, reqp, - cb_blocking); + cb_blocking, extra_lock_flags); else if (it->it_op & IT_OPEN) rc = lmv_intent_open(exp, pid, name, len, lmm, lmmsize, cid, it, flags, reqp, - cb_blocking); - else if (it->it_op == IT_GETATTR || it->it_op == IT_CHDIR) + cb_blocking, extra_lock_flags); + else if (it->it_op == IT_GETATTR/* || it->it_op == IT_CHDIR*/) rc = lmv_intent_getattr(exp, pid, name, len, lmm, lmmsize, cid, it, flags, reqp, - cb_blocking); + cb_blocking, extra_lock_flags); else LBUG(); RETURN(rc); @@ -634,7 +665,8 @@ int lmv_intent_lock(struct obd_export *exp, struct lu_fid *pid, int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, struct lu_fid *mid, struct lookup_intent *oit, - int master_valid, ldlm_blocking_callback cb_blocking) + int master_valid, ldlm_blocking_callback cb_blocking, + int extra_lock_flags) { struct obd_device *obd = exp->exp_obd; struct ptlrpc_request *mreq = *reqp; @@ -653,15 +685,16 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, * the fields. say, common fields (that are equal on all the subojects * need not to be update, another fields (i_size, for example) are * cached all the time */ - obj = lmv_grab_obj(obd, mid); + obj = lmv_obj_grab(obd, mid); LASSERT(obj != NULL); master_lock_mode = 0; - lmv_lock_obj(obj); + lmv_obj_lock(obj); for (i = 0; i < obj->lo_objcount; i++) { struct lu_fid fid = obj->lo_objs[i].li_fid; + struct md_op_data op_data = { { 0 } }; struct lustre_handle *lockh = NULL; struct ptlrpc_request *req = NULL; ldlm_blocking_callback cb; @@ -676,10 +709,6 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, cb = lmv_dirobj_blocking_ast; - OBD_ALLOC(it.d.fs_data, sizeof(struct lustre_intent_data)); - if (!it.d.fs_data) - GOTO(cleanup, rc = -ENOMEM); - if (lu_fid_eq(&fid, &obj->lo_fid)) { if (master_valid) { /* lmv_intent_getattr() already checked @@ -701,13 +730,14 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, cb = cb_blocking; } + op_data.fid1 = fid; + op_data.fid2 = fid; /* is obj valid? */ mds = lmv_fld_lookup(obd, &fid); - rc = md_intent_lock(lmv->tgts[mds].ltd_exp, - &fid, NULL, 0, NULL, 0, &fid, &it, 0, - &req, cb); - lockh = (struct lustre_handle *) &LUSTRE_IT(&it)->it_lock_handle; + rc = md_intent_lock(lmv->tgts[mds].ltd_exp, &op_data, + NULL, 0, &it, 0, &req, cb, extra_lock_flags); + lockh = (struct lustre_handle *) &it.d.lustre.it_lock_handle; if (rc > 0 && req == NULL) { /* nice, this slave is valid */ LASSERT(req == NULL); @@ -716,7 +746,6 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, } if (rc < 0) { - OBD_FREE(it.d.fs_data, sizeof(struct lustre_intent_data)); /* error during revalidation */ GOTO(cleanup, rc); } @@ -725,13 +754,13 @@ int lmv_revalidate_slaves(struct obd_export *exp, struct ptlrpc_request **reqp, /* save lock on master to be returned to the caller */ CDEBUG(D_OTHER, "no lock on master yet\n"); memcpy(&master_lockh, lockh, sizeof(master_lockh)); - master_lock_mode = LUSTRE_IT(&it)->it_lock_mode; - LUSTRE_IT(&it)->it_lock_mode = 0; + master_lock_mode = it.d.lustre.it_lock_mode; + it.d.lustre.it_lock_mode = 0; } else { /* this is slave. we want to control it */ lock = ldlm_handle2lock(lockh); LASSERT(lock); - lock->l_ast_data = lmv_get_obj(obj); + lock->l_ast_data = lmv_obj_get(obj); LDLM_LOCK_PUT(lock); } @@ -758,9 +787,8 @@ update: release_lock: size += obj->lo_objs[i].li_size; - if (LUSTRE_IT(&it)->it_lock_mode) - ldlm_lock_decref(lockh, LUSTRE_IT(&it)->it_lock_mode); - OBD_FREE(it.d.fs_data, sizeof(struct lustre_intent_data)); + if (it.d.lustre.it_lock_mode) + ldlm_lock_decref(lockh, it.d.lustre.it_lock_mode); } if (*reqp) { @@ -784,22 +812,22 @@ release_lock: // body->mds = lmv_fld_lookup(obd, &obj->lo_fid); } if (master_valid == 0) { - memcpy(&LUSTRE_IT(oit)->it_lock_handle, + memcpy(&oit->d.lustre.it_lock_handle, &master_lockh, sizeof(master_lockh)); - LUSTRE_IT(oit)->it_lock_mode = master_lock_mode; + oit->d.lustre.it_lock_mode = master_lock_mode; } rc = 0; } else { /* it seems all the attrs are fresh and we did no request */ CDEBUG(D_OTHER, "all the attrs were fresh\n"); if (master_valid == 0) - LUSTRE_IT(oit)->it_lock_mode = master_lock_mode; + oit->d.lustre.it_lock_mode = master_lock_mode; rc = 1; } EXIT; cleanup: - lmv_unlock_obj(obj); - lmv_put_obj(obj); + lmv_obj_unlock(obj); + lmv_obj_put(obj); return rc; } diff --git a/lustre/lmv/lmv_internal.h b/lustre/lmv/lmv_internal.h index 3689900..ec6a2a8 100644 --- a/lustre/lmv/lmv_internal.h +++ b/lustre/lmv/lmv_internal.h @@ -22,6 +22,8 @@ #ifndef _LMV_INTERNAL_H_ #define _LMV_INTERNAL_H_ +#include + #define LMV_MAX_TGT_COUNT 128 #define lmv_init_lock(lmv) down(&lmv->init_sem); @@ -32,7 +34,7 @@ #define MEA_SIZE_LMV(lmv) \ ((lmv)->desc.ld_tgt_count * \ - sizeof(struct lu_fid) + sizeof(struct mea)) + sizeof(struct lu_fid) + sizeof(struct lmv_stripe_md)) struct lmv_inode { struct lu_fid li_fid; /* id of dirobj */ @@ -55,78 +57,83 @@ struct lmv_obj { struct obd_device *lo_obd; /* pointer to LMV itself */ }; +int lmv_mgr_setup(struct obd_device *obd); +void lmv_mgr_cleanup(struct obd_device *obd); + static inline void -lmv_lock_obj(struct lmv_obj *obj) +lmv_obj_lock(struct lmv_obj *obj) { LASSERT(obj); down(&obj->lo_guard); } static inline void -lmv_unlock_obj(struct lmv_obj *obj) +lmv_obj_unlock(struct lmv_obj *obj) { LASSERT(obj); up(&obj->lo_guard); } -void lmv_add_obj(struct lmv_obj *obj); -void lmv_del_obj(struct lmv_obj *obj); - -void lmv_put_obj(struct lmv_obj *obj); -void lmv_free_obj(struct lmv_obj *obj); +void lmv_obj_add(struct lmv_obj *obj); +void lmv_obj_del(struct lmv_obj *obj); -int lmv_setup_mgr(struct obd_device *obd); -void lmv_cleanup_mgr(struct obd_device *obd); -int lmv_check_connect(struct obd_device *obd); +void lmv_obj_put(struct lmv_obj *obj); +void lmv_obj_free(struct lmv_obj *obj); -struct lmv_obj *lmv_get_obj(struct lmv_obj *obj); +struct lmv_obj *lmv_obj_get(struct lmv_obj *obj); -struct lmv_obj *lmv_grab_obj(struct obd_device *obd, +struct lmv_obj *lmv_obj_grab(struct obd_device *obd, struct lu_fid *fid); -struct lmv_obj *lmv_alloc_obj(struct obd_device *obd, +struct lmv_obj *lmv_obj_alloc(struct obd_device *obd, struct lu_fid *fid, - struct mea *mea); + struct lmv_stripe_md *mea); -struct lmv_obj *lmv_create_obj(struct obd_export *exp, +struct lmv_obj *lmv_obj_create(struct obd_export *exp, struct lu_fid *fid, - struct mea *mea); + struct lmv_stripe_md *mea); + +int lmv_obj_delete(struct obd_export *exp, struct lu_fid *fid); -int lmv_delete_obj(struct obd_export *exp, struct lu_fid *fid); +int lmv_check_connect(struct obd_device *obd); -int lmv_intent_lock(struct obd_export *, struct lu_fid *, - const char *, int, void *, int, - struct lu_fid *, struct lookup_intent *, int, - struct ptlrpc_request **, ldlm_blocking_callback); +int lmv_intent_lock(struct obd_export *exp, struct md_op_data *op_data, + void *lmm, int lmmsize, struct lookup_intent *it, + int flags, struct ptlrpc_request **reqp, + ldlm_blocking_callback cb_blocking, + int extra_lock_flags); int lmv_intent_lookup(struct obd_export *, struct lu_fid *, const char *, int, void *, int, struct lu_fid *, struct lookup_intent *, int, - struct ptlrpc_request **, ldlm_blocking_callback); + struct ptlrpc_request **, ldlm_blocking_callback, + int extra_lock_flags); -int lmv_intent_getattr(struct obd_export *, struct lu_fid *, - const char *, int, void *, int, - struct lu_fid *, struct lookup_intent *, int, - struct ptlrpc_request **, ldlm_blocking_callback); +int lmv_intent_getattr(struct obd_export *, struct lu_fid *, const char *, + int, void *, int, struct lu_fid *, struct lookup_intent *, + int, struct ptlrpc_request **, ldlm_blocking_callback, + int extra_lock_flags); int lmv_intent_open(struct obd_export *, struct lu_fid *, const char *, int, void *, int, struct lu_fid *, struct lookup_intent *, - int, struct ptlrpc_request **, ldlm_blocking_callback); + int, struct ptlrpc_request **, ldlm_blocking_callback, + int extra_lock_flags); int lmv_revalidate_slaves(struct obd_export *, struct ptlrpc_request **, struct lu_fid *, struct lookup_intent *, int, - ldlm_blocking_callback cb_blocking); + ldlm_blocking_callback cb_blocking, + int extra_lock_flags); int lmv_get_mea_and_update_object(struct obd_export *, struct lu_fid *); int lmv_dirobj_blocking_ast(struct ldlm_lock *, struct ldlm_lock_desc *, void *, int); -int lmv_fld_lookup(struct obd_device *obd, struct lu_fid *fid) +int lmv_fld_lookup(struct obd_device *obd, struct lu_fid *fid); -static inline struct mea * +static inline struct lmv_stripe_md * lmv_splitted_dir_body(struct ptlrpc_request *req, int offset) { struct mdt_body *body; - struct mea *mea; + struct lmv_stripe_md *mea; LASSERT(req); diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 73d6504..b8ee5c9 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -34,6 +34,7 @@ #include #else #include +#include #endif #include @@ -41,12 +42,8 @@ #include #include #include -//#include -//#include #include -//#include #include -//#include #include #include "lmv_internal.h" @@ -109,7 +106,7 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, CDEBUG(D_INFO, "Found OBD %s=%s device %d (%p) type %s at LMV idx %d\n", obd->obd_name, obd->obd_uuid.uuid, obd->obd_minor, obd, obd->obd_type->typ_name, i); - LASSERT(strcmp(obd->obd_type->typ_name, OBD_MDC_DEVICENAME) == 0); + LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0); if (tgt->active == activate) { CDEBUG(D_INFO, "OBD %p already %sactive!\n", obd, @@ -130,70 +127,42 @@ static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid, } static int lmv_notify(struct obd_device *obd, struct obd_device *watched, - int active, void *data) + enum obd_notify_event ev, void *data) { struct obd_uuid *uuid; int rc; ENTRY; - if (strcmp(watched->obd_type->typ_name, OBD_MDC_DEVICENAME)) { + if (strcmp(watched->obd_type->typ_name, LUSTRE_MDC_NAME)) { CERROR("unexpected notification of %s %s!\n", watched->obd_type->typ_name, watched->obd_name); RETURN(-EINVAL); } - uuid = &watched->u.cli.cl_import->imp_target_uuid; + uuid = &watched->u.cli.cl_target_uuid; /* Set MDC as active before notifying the observer, so the observer can - * use the MDC normally. - */ - rc = lmv_set_mdc_active(&obd->u.lmv, uuid, active); + * use the MDC normally. */ + rc = lmv_set_mdc_active(&obd->u.lmv, uuid, + ev == OBD_NOTIFY_ACTIVE); if (rc) { CERROR("%sactivation of %s failed: %d\n", - active ? "" : "de", uuid->uuid, rc); + ev == OBD_NOTIFY_ACTIVE ? "" : "de", + uuid->uuid, rc); RETURN(rc); } if (obd->obd_observer) - /* Pass the notification up the chain. */ - rc = obd_notify(obd->obd_observer, watched, active, data); + /* pass the notification up the chain. */ + rc = obd_notify(obd->obd_observer, watched, ev, data); RETURN(rc); } -static int lmv_attach(struct obd_device *dev, obd_count len, void *data) -{ - struct lprocfs_static_vars lvars; - int rc; - ENTRY; - - lprocfs_init_vars(lmv, &lvars); - rc = lprocfs_obd_attach(dev, lvars.obd_vars); -#ifdef __KERNEL__ - if (rc == 0) { - struct proc_dir_entry *entry; - - entry = create_proc_entry("target_obd_status", 0444, - dev->obd_proc_entry); - if (entry == NULL) - RETURN(-ENOMEM); - entry->proc_fops = &lmv_proc_target_fops; - entry->data = dev; - } -#endif - RETURN (rc); -} - -static int lmv_detach(struct obd_device *dev) -{ - return lprocfs_obd_detach(dev); -} - /* this is fake connect function. Its purpose is to initialize lmv and say * caller that everything is okay. Real connection will be performed later. */ static int lmv_connect(struct lustre_handle *conn, struct obd_device *obd, - struct obd_uuid *cluuid, struct obd_connect_data *data, - unsigned long flags) + struct obd_uuid *cluuid, struct obd_connect_data *data) { #ifdef __KERNEL__ struct proc_dir_entry *lmv_proc_dir; @@ -222,7 +191,6 @@ static int lmv_connect(struct lustre_handle *conn, struct obd_device *obd, lmv->exp = exp; lmv->connected = 0; lmv->cluuid = *cluuid; - lmv->connect_flags = flags; if (data) memcpy(&lmv->conn_data, data, sizeof(*data)); @@ -237,11 +205,10 @@ static int lmv_connect(struct lustre_handle *conn, struct obd_device *obd, #endif /* all real clients should perform actual connection right away, because - * it is possible, that LMV will not have opportunity to connect - * targets, as MDC stuff will be called directly, for instance while - * reading ../mdc/../kbytesfree procfs file, etc. - */ - if (flags & OBD_OPT_REAL_CLIENT) + * it is possible, that LMV will not have opportunity to connect targets + * and MDC stuff will be called directly, for instance while reading + * ../mdc/../kbytesfree procfs file, etc. */ + if (data->ocd_connect_flags & OBD_CONNECT_REAL) rc = lmv_check_connect(obd); #ifdef __KERNEL__ @@ -277,7 +244,7 @@ static void lmv_set_timeouts(struct obd_device *obd) } static int lmv_init_ea_size(struct obd_export *exp, int easize, - int cookiesize) + int def_easize, int cookiesize) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -288,6 +255,10 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, lmv->max_easize = easize; change = 1; } + if (lmv->max_def_easize < def_easize) { + lmv->max_def_easize = def_easize; + change = 1; + } if (lmv->max_cookiesize < cookiesize) { lmv->max_cookiesize = cookiesize; change = 1; @@ -304,7 +275,8 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize, continue; } - rc = obd_init_ea_size(lmv->tgts[i].ltd_exp, easize, cookiesize); + rc = md_init_ea_size(lmv->tgts[i].ltd_exp, easize, def_easize, + cookiesize); if (rc) { CERROR("obd_init_ea_size() failed on MDT target %d, " "error %d.\n", i, rc); @@ -338,7 +310,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) RETURN(0); } - mdc_obd = class_find_client_obd(&tgt->uuid, OBD_MDC_DEVICENAME, + mdc_obd = class_find_client_obd(&tgt->uuid, LUSTRE_MDC_NAME, &obd->obd_uuid); if (!mdc_obd) { CERROR("target %s not attached\n", tgt->uuid.uuid); @@ -355,8 +327,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) RETURN(-EINVAL); } - rc = obd_connect(&conn, mdc_obd, &lmv_mdc_uuid, &lmv->conn_data, - lmv->connect_flags); + rc = obd_connect(&conn, mdc_obd, &lmv_mdc_uuid, &lmv->conn_data); if (rc) { CERROR("target %s connect error %d\n", tgt->uuid.uuid, rc); RETURN(rc); @@ -366,7 +337,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) rc = obd_register_observer(mdc_obd, obd); if (rc) { - obd_disconnect(mdc_exp, 0); + obd_disconnect(mdc_exp); CERROR("target %s register_observer error %d\n", tgt->uuid.uuid, rc); RETURN(rc); @@ -374,10 +345,10 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) if (obd->obd_observer) { /* tell the mds_lmv about the new target */ - rc = obd_notify(obd->obd_observer, mdc_exp->exp_obd, 1, - (void *)(tgt - lmv->tgts)); + rc = obd_notify(obd->obd_observer, mdc_exp->exp_obd, + OBD_NOTIFY_ACTIVE, (void *)(tgt - lmv->tgts)); if (rc) { - obd_disconnect(mdc_exp, 0); + obd_disconnect(mdc_exp); RETURN(rc); } } @@ -386,8 +357,9 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) tgt->active = 1; lmv->desc.ld_active_tgt_count++; - obd_init_ea_size(tgt->ltd_exp, lmv->max_easize, - lmv->max_cookiesize); + md_init_ea_size(tgt->ltd_exp, lmv->max_easize, + lmv->max_def_easize, lmv->max_cookiesize); + CDEBUG(D_CONFIG, "connected to %s(%s) successfully (%d)\n", mdc_obd->obd_name, mdc_obd->obd_uuid.uuid, atomic_read(&obd->obd_refcount)); @@ -419,7 +391,7 @@ int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt) RETURN(0); } -int lmv_add_mdc(struct obd_device *obd, struct obd_uuid *tgt_uuid) +int lmv_add_target(struct obd_device *obd, struct obd_uuid *tgt_uuid) { struct lmv_obd *lmv = &obd->u.lmv; struct lmv_tgt_desc *tgt; @@ -440,7 +412,7 @@ int lmv_add_mdc(struct obd_device *obd, struct obd_uuid *tgt_uuid) if (lmv->desc.ld_tgt_count == 0) { struct obd_device *mdc_obd; - mdc_obd = class_find_client_obd(tgt_uuid, OBD_MDC_DEVICENAME, + mdc_obd = class_find_client_obd(tgt_uuid, LUSTRE_MDC_NAME, &obd->obd_uuid); if (!mdc_obd) { lmv_init_unlock(lmv); @@ -448,7 +420,7 @@ int lmv_add_mdc(struct obd_device *obd, struct obd_uuid *tgt_uuid) RETURN(-EINVAL); } - rc = obd_llog_init(obd, &obd->obd_llogs, mdc_obd, 0, NULL); + rc = obd_llog_init(obd, mdc_obd, 0, NULL); if (rc) { lmv_init_unlock(lmv); CERROR("lmv failed to setup llogging subsystems\n"); @@ -467,10 +439,10 @@ int lmv_add_mdc(struct obd_device *obd, struct obd_uuid *tgt_uuid) memset(tgt, 0, sizeof(*tgt)); spin_unlock(&lmv->lmv_lock); } else { - int easize = sizeof(struct mea) + + int easize = sizeof(struct lmv_stripe_md) + lmv->desc.ld_tgt_count * sizeof(struct lu_fid); - lmv_init_ea_size(obd->obd_self_export, easize, 0); + lmv_init_ea_size(obd->obd_self_export, easize, 0, 0); } } @@ -515,8 +487,8 @@ int lmv_check_connect(struct obd_device *obd) class_export_put(lmv->exp); lmv->connected = 1; easize = lmv->desc.ld_tgt_count * sizeof(struct lu_fid) + - sizeof(struct mea); - lmv_init_ea_size(obd->obd_self_export, easize, 0); + sizeof(struct lmv_stripe_md); + lmv_init_ea_size(obd->obd_self_export, easize, 0, 0); lmv_init_unlock(lmv); RETURN(0); @@ -527,7 +499,7 @@ int lmv_check_connect(struct obd_device *obd) tgt->active = 0; if (tgt->ltd_exp) { --lmv->desc.ld_active_tgt_count; - rc2 = obd_disconnect(tgt->ltd_exp, 0); + rc2 = obd_disconnect(tgt->ltd_exp); if (rc2) { CERROR("error: LMV target %s disconnect on " "MDC idx %d: error %d\n", @@ -535,12 +507,12 @@ int lmv_check_connect(struct obd_device *obd) } } } - class_disconnect(lmv->exp, 0); + class_disconnect(lmv->exp); lmv_init_unlock(lmv); RETURN(rc); } -static int lmv_disconnect(struct obd_export *exp, unsigned long flags) +static int lmv_disconnect(struct obd_export *exp) { struct obd_device *obd = class_exp2obd(exp); struct lmv_obd *lmv = &obd->u.lmv; @@ -593,7 +565,7 @@ static int lmv_disconnect(struct obd_export *exp, unsigned long flags) lmv->tgts[i].ltd_exp->exp_obd->obd_uuid.uuid); obd_register_observer(lmv->tgts[i].ltd_exp->exp_obd, NULL); - rc = obd_disconnect(lmv->tgts[i].ltd_exp, flags); + rc = obd_disconnect(lmv->tgts[i].ltd_exp); if (rc) { if (lmv->tgts[i].active) { CERROR("Target %s disconnect error %d\n", @@ -620,7 +592,7 @@ out_local: * lmv_check_connect(). */ if (!lmv->connected) class_export_put(exp); - rc = class_disconnect(exp, 0); + rc = class_disconnect(exp); if (lmv->refcount == 0) lmv->connected = 0; RETURN(rc); @@ -661,10 +633,10 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, RETURN(rc); } -static int lmv_setup(struct obd_device *obd, obd_count len, void *buf) +static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg) { struct lmv_obd *lmv = &obd->u.lmv; - struct lustre_cfg *lcfg = buf; + struct lprocfs_static_vars lvars; struct lmv_desc *desc; int rc = 0; ENTRY; @@ -693,12 +665,13 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf) lmv->desc.ld_tgt_count = 0; lmv->desc.ld_active_tgt_count = 0; lmv->max_cookiesize = 0; + lmv->max_def_easize = 0; lmv->max_easize = 0; spin_lock_init(&lmv->lmv_lock); sema_init(&lmv->init_sem, 1); - rc = lmv_setup_mgr(obd); + rc = lmv_mgr_setup(obd); if (rc) { CERROR("Can't setup LMV object manager, " "error %d.\n", rc); @@ -706,19 +679,35 @@ static int lmv_setup(struct obd_device *obd, obd_count len, void *buf) RETURN(rc); } - RETURN(rc); + lprocfs_init_vars(lmv, &lvars); + lprocfs_obd_setup(obd, lvars.obd_vars); +#ifdef LPROCFS + { + struct proc_dir_entry *entry; + + entry = create_proc_entry("target_obd_status", 0444, + obd->obd_proc_entry); + if (entry != NULL) { + entry->proc_fops = &lmv_proc_target_fops; + entry->data = obd; + } + } +#endif + RETURN(0); } -static int lmv_cleanup(struct obd_device *obd, int flags) +static int lmv_cleanup(struct obd_device *obd) { struct lmv_obd *lmv = &obd->u.lmv; ENTRY; - lmv_cleanup_mgr(obd); + lprocfs_obd_cleanup(obd); + lmv_mgr_cleanup(obd); OBD_FREE(lmv->tgts, lmv->tgts_size); RETURN(0); } + static int lmv_process_config(struct obd_device *obd, obd_count len, void *buf) { struct lustre_cfg *lcfg = buf; @@ -727,12 +716,12 @@ static int lmv_process_config(struct obd_device *obd, obd_count len, void *buf) ENTRY; switch(lcfg->lcfg_command) { - case LCFG_LMV_ADD_MDC: + case LCFG_LMV_ADD_OBD: if (LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(tgt_uuid.uuid)) GOTO(out, rc = -EINVAL); obd_str2uuid(&tgt_uuid, lustre_cfg_string(lcfg, 1)); - rc = lmv_add_mdc(obd, &tgt_uuid); + rc = lmv_add_target(obd, &tgt_uuid); GOTO(out, rc); default: { CERROR("Unknown command: %d\n", lcfg->lcfg_command); @@ -803,9 +792,7 @@ static int lmv_getstatus(struct obd_export *exp, struct lu_fid *fid) } static int lmv_getattr(struct obd_export *exp, struct lu_fid *fid, - __u64 valid, const char *xattr_name, - const void *xattr_data, unsigned int xattr_datalen, - unsigned int ea_size, struct obd_capa *ocapa, + obd_valid valid, int ea_size, struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; @@ -822,28 +809,25 @@ static int lmv_getattr(struct obd_export *exp, struct lu_fid *fid, LASSERT(i < lmv->desc.ld_tgt_count); rc = md_getattr(lmv->tgts[i].ltd_exp, fid, valid, - xattr_name, xattr_data, xattr_datalen, - ea_size, ocapa, request); + ea_size, request); if (rc) RETURN(rc); - obj = lmv_grab_obj(obd, fid); + obj = lmv_obj_grab(obd, fid); CDEBUG(D_OTHER, "GETATTR for "DFID3" %s\n", PFID3(fid), obj ? "(splitted)" : ""); - /* - * if object is splitted, then we loop over all the slaves and gather + /* if object is splitted, then we loop over all the slaves and gather * size attribute. In ideal world we would have to gather also mds field * from all slaves, as object is spread over the cluster and this is * definitely interesting information and it is not good to loss it, - * but... - */ + * but... */ if (obj) { struct mdt_body *body; if (*request == NULL) { - lmv_put_obj(obj); + lmv_obj_put(obj); RETURN(rc); } @@ -851,7 +835,7 @@ static int lmv_getattr(struct obd_export *exp, struct lu_fid *fid, sizeof(*body)); LASSERT(body != NULL); - lmv_lock_obj(obj); + lmv_obj_lock(obj); for (i = 0; i < obj->lo_objcount; i++) { @@ -868,31 +852,13 @@ static int lmv_getattr(struct obd_export *exp, struct lu_fid *fid, body->size += obj->lo_objs[i].li_size; } - lmv_unlock_obj(obj); - lmv_put_obj(obj); + lmv_obj_unlock(obj); + lmv_obj_put(obj); } RETURN(rc); } -static int lmv_access_check(struct obd_export *exp, - struct lu_fid *fid, - struct ptlrpc_request **request) -{ - struct obd_device *obd = exp->exp_obd; - struct lmv_obd *lmv = &obd->u.lmv; - int rc, i; - ENTRY; - - rc = lmv_check_connect(obd); - if (rc) - RETURN(rc); - - LASSERT(i < lmv->desc.ld_tgt_count); - rc = md_access_check(lmv->tgts[i].ltd_exp, fid, request); - RETURN(rc); -} - static int lmv_change_cbdata(struct obd_export *exp, struct lu_fid *fid, ldlm_iterator_t it, @@ -920,64 +886,6 @@ static int lmv_change_cbdata(struct obd_export *exp, RETURN(0); } -static int lmv_change_cbdata_name(struct obd_export *exp, - struct lu_fid *pid, - char *name, int len, - struct lu_fid *cid, - ldlm_iterator_t it, - void *data) -{ - struct obd_device *obd = exp->exp_obd; - struct lmv_obd *lmv = &obd->u.lmv; - struct lu_fid rcid = *cid; - struct lmv_obj *obj; - int i, rc = 0, mds; - ENTRY; - - rc = lmv_check_connect(obd); - if (rc) - RETURN(rc); - - i = lmv_fld_lookup(obd, pid); - LASSERT(i < lmv->desc.ld_tgt_count); - i = lmv_fld_lookup(obd, cid); - LASSERT(i < lmv->desc.ld_tgt_count); - - CDEBUG(D_OTHER, "CBDATA for "DFID3":%*s -> "DFID3"\n", - PFID3(pid), len, name, PFID3(cid)); - - /* this is default mds for directory name belongs to. */ - mds = lmv_fld_lookup(obd, pid); - obj = lmv_grab_obj(obd, pid); - if (obj) { - /* directory is splitted. look for right mds for this name. */ - mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount, name, len); - rcid = obj->lo_objs[mds].li_fid; - mds = lmv_fld_lookup(obd, &rcid); - lmv_put_obj(obj); - } - rc = md_change_cbdata(lmv->tgts[mds].ltd_exp, &rcid, it, data); - RETURN(rc); -} - -static int lmv_valid_attrs(struct obd_export *exp, struct lu_fid *fid) -{ - struct obd_device *obd = exp->exp_obd; - struct lmv_obd *lmv = &obd->u.lmv; - int i, rc = 0; - ENTRY; - - rc = lmv_check_connect(obd); - if (rc) - RETURN(rc); - - CDEBUG(D_OTHER, "validate "DFID3"\n", PFID3(fid)); - i = lmv_fld_lookup(obd, fid); - LASSERT(i < lmv->desc.ld_tgt_count); - rc = md_valid_attrs(lmv->tgts[i].ltd_exp, fid); - RETURN(rc); -} - static int lmv_close(struct obd_export *exp, struct md_op_data *op_data, struct obd_client_handle *och, struct ptlrpc_request **request) @@ -1015,29 +923,32 @@ int lmv_get_mea_and_update_object(struct obd_export *exp, valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA | OBD_MD_MEA; - /* time to update mea of parent fid */ i = lmv_fld_lookup(obd, fid); - rc = md_getattr(lmv->tgts[i].ltd_exp, fid, valid, NULL, - NULL, 0, mealen, NULL, &req); + LASSERT(i < lmv->desc.ld_tgt_count); + + /* time to update mea of parent fid */ + rc = md_getattr(lmv->tgts[i].ltd_exp, fid, valid, + mealen, &req); if (rc) { CERROR("md_getattr() failed, error %d\n", rc); GOTO(cleanup, rc); } - rc = mdc_req2lustre_md(exp, req, 0, NULL, &md); + rc = md_get_lustre_md(lmv->tgts[i].ltd_exp, req, 0, + NULL, &md); if (rc) { - CERROR("mdc_req2lustre_md() failed, error %d\n", rc); + CERROR("mdc_get_lustre_md() failed, error %d\n", rc); GOTO(cleanup, rc); } if (md.mea == NULL) GOTO(cleanup, rc = -ENODATA); - obj = lmv_create_obj(exp, fid, md.mea); + obj = lmv_obj_create(exp, fid, md.mea); if (IS_ERR(obj)) rc = PTR_ERR(obj); else - lmv_put_obj(obj); + lmv_obj_put(obj); obd_free_memmd(exp, (struct lov_stripe_md **)&md.mea); @@ -1050,7 +961,8 @@ cleanup: int lmv_create(struct obd_export *exp, struct md_op_data *op_data, const void *data, int datalen, int mode, __u32 uid, - __u32 gid, __u64 rdev, struct ptlrpc_request **request) + __u32 gid, __u32 cap_effective, __u64 rdev, + struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -1067,21 +979,20 @@ int lmv_create(struct obd_export *exp, struct md_op_data *op_data, RETURN(-EIO); repeat: LASSERT(++loop <= 2); - obj = lmv_grab_obj(obd, &op_data->fid1); + obj = lmv_obj_grab(obd, &op_data->fid1); if (obj) { mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount, op_data->name, op_data->namelen); op_data->fid1 = obj->lo_objs[mds].li_fid; - lmv_put_obj(obj); + lmv_obj_put(obj); } CDEBUG(D_OTHER, "CREATE '%*s' on "DFID3"\n", op_data->namelen, op_data->name, PFID3(&op_data->fid1)); mds = lmv_fld_lookup(obd, &op_data->fid1); - rc = md_create(lmv->tgts[mds].ltd_exp, - op_data, data, datalen, mode, uid, gid, rdev, - request); + rc = md_create(lmv->tgts[mds].ltd_exp, op_data, data, datalen, + mode, uid, gid, rdev, cap_effective, request); if (rc == 0) { if (*request == NULL) RETURN(rc); @@ -1106,20 +1017,20 @@ repeat: RETURN(rc); } -static int lmv_done_writing(struct obd_export *exp, struct obdo *obdo) +static int lmv_done_writing(struct obd_export *exp, + struct md_op_data *op_data) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - int rc; + int rc, mds; ENTRY; rc = lmv_check_connect(obd); if (rc) RETURN(rc); - /* FIXME: choose right MDC here */ - CWARN("this method isn't implemented yet\n"); - rc = md_done_writing(lmv->tgts[0].ltd_exp, obdo); + mds = lmv_fld_lookup(obd, &op_data->fid1); + rc = md_done_writing(lmv->tgts[mds].ltd_exp, op_data); RETURN(rc); } @@ -1132,7 +1043,7 @@ lmv_enqueue_slaves(struct obd_export *exp, int locktype, { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - struct mea *mea = op_data->mea1; + struct lmv_stripe_md *mea = op_data->mea1; struct md_op_data *op_data2; int i, rc, mds; ENTRY; @@ -1152,20 +1063,20 @@ lmv_enqueue_slaves(struct obd_export *exp, int locktype, rc = md_enqueue(lmv->tgts[mds].ltd_exp, locktype, it, lockmode, op_data2, lockh + i, lmm, lmmsize, - cb_compl, cb_blocking, cb_data); + cb_compl, cb_blocking, cb_data, 0); CDEBUG(D_OTHER, "take lock on slave "DFID3" -> %d/%d\n", - PFID3(&mea->mea_ids[i]), rc, LUSTRE_IT(it)->it_status); + PFID3(&mea->mea_ids[i]), rc, it->d.lustre.it_status); if (rc) GOTO(cleanup, rc); - if (LUSTRE_IT(it)->it_data) { + if (it->d.lustre.it_data) { struct ptlrpc_request *req; - req = (struct ptlrpc_request *) LUSTRE_IT(it)->it_data; + req = (struct ptlrpc_request *)it->d.lustre.it_data; ptlrpc_req_finished(req); } - if (LUSTRE_IT(it)->it_status) - GOTO(cleanup, rc = LUSTRE_IT(it)->it_status); + if (it->d.lustre.it_status) + GOTO(cleanup, rc = it->d.lustre.it_status); } OBD_FREE(op_data2, sizeof(*op_data2)); @@ -1187,9 +1098,10 @@ lmv_enqueue_remote(struct obd_export *exp, int lock_type, struct lookup_intent *it, int lock_mode, struct md_op_data *op_data, struct lustre_handle *lockh, void *lmm, int lmmsize, ldlm_completion_callback cb_compl, - ldlm_blocking_callback cb_blocking, void *cb_data) + ldlm_blocking_callback cb_blocking, void *cb_data, + int extra_lock_flags) { - struct ptlrpc_request *req = LUSTRE_IT(it)->it_data; + struct ptlrpc_request *req = it->d.lustre.it_data; struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; struct lustre_handle plock; @@ -1208,25 +1120,25 @@ lmv_enqueue_remote(struct obd_export *exp, int lock_type, LL_IT2STR(it), PFID3(&op_data->fid1), PFID3(&body->fid1)); /* we got LOOKUP lock, but we really need attrs */ - pmode = LUSTRE_IT(it)->it_lock_mode; + pmode = it->d.lustre.it_lock_mode; LASSERT(pmode != 0); memcpy(&plock, lockh, sizeof(plock)); - LUSTRE_IT(it)->it_lock_mode = 0; - LUSTRE_IT(it)->it_data = NULL; - LASSERT((body->valid & OBD_MD_FID) != 0); + it->d.lustre.it_lock_mode = 0; + it->d.lustre.it_data = NULL; memcpy(&rdata, op_data, sizeof(rdata)); rdata.fid1 = body->fid1; rdata.name = NULL; rdata.namelen = 0; - LUSTRE_IT(it)->it_disposition &= ~DISP_ENQ_COMPLETE; + it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE; ptlrpc_req_finished(req); i = lmv_fld_lookup(obd, &rdata.fid1); rc = md_enqueue(lmv->tgts[i].ltd_exp, lock_type, it, lock_mode, &rdata, lockh, lmm, - lmmsize, cb_compl, cb_blocking, cb_data); + lmmsize, cb_compl, cb_blocking, cb_data, + extra_lock_flags); ldlm_lock_decref(&plock, pmode); RETURN(rc); } @@ -1236,7 +1148,8 @@ lmv_enqueue(struct obd_export *exp, int lock_type, struct lookup_intent *it, int lock_mode, struct md_op_data *op_data, struct lustre_handle *lockh, void *lmm, int lmmsize, ldlm_completion_callback cb_compl, - ldlm_blocking_callback cb_blocking, void *cb_data) + ldlm_blocking_callback cb_blocking, void *cb_data, + int extra_lock_flags) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -1256,14 +1169,14 @@ lmv_enqueue(struct obd_export *exp, int lock_type, } if (op_data->namelen) { - obj = lmv_grab_obj(obd, &op_data->fid1); + obj = lmv_obj_grab(obd, &op_data->fid1); if (obj) { /* directory is splitted. look for right mds for this * name */ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount, (char *)op_data->name, op_data->namelen); op_data->fid1 = obj->lo_objs[mds].li_fid; - lmv_put_obj(obj); + lmv_obj_put(obj); } } CDEBUG(D_OTHER, "ENQUEUE '%s' on "DFID3"\n", LL_IT2STR(it), @@ -1272,18 +1185,20 @@ lmv_enqueue(struct obd_export *exp, int lock_type, mds = lmv_fld_lookup(obd, &op_data->fid1); rc = md_enqueue(lmv->tgts[mds].ltd_exp, lock_type, it, lock_mode, op_data, lockh, lmm, - lmmsize, cb_compl, cb_blocking, cb_data); + lmmsize, cb_compl, cb_blocking, cb_data, + extra_lock_flags); if (rc == 0 && it->it_op == IT_OPEN) rc = lmv_enqueue_remote(exp, lock_type, it, lock_mode, op_data, lockh, lmm, lmmsize, - cb_compl, cb_blocking, cb_data); + cb_compl, cb_blocking, cb_data, + extra_lock_flags); RETURN(rc); } static int -lmv_getattr_lock(struct obd_export *exp, struct lu_fid *fid, - char *filename, int namelen, __u64 valid, - unsigned int ea_size, struct ptlrpc_request **request) +lmv_getattr_name(struct obd_export *exp, struct lu_fid *fid, + const char *filename, int namelen, obd_valid valid, + int ea_size, struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -1300,28 +1215,25 @@ lmv_getattr_lock(struct obd_export *exp, struct lu_fid *fid, mds = lmv_fld_lookup(obd, fid); repeat: LASSERT(++loop <= 2); - obj = lmv_grab_obj(obd, fid); + obj = lmv_obj_grab(obd, fid); if (obj) { /* directory is splitted. look for right mds for this name */ mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount, filename, namelen - 1); rid = obj->lo_objs[mds].li_fid; - lmv_put_obj(obj); + lmv_obj_put(obj); } CDEBUG(D_OTHER, "getattr_lock for %*s on "DFID3" -> "DFID3"\n", namelen, filename, PFID3(fid), PFID3(&rid)); mds = lmv_fld_lookup(obd, &rid); - rc = md_getattr_lock(lmv->tgts[mds].ltd_exp, + rc = md_getattr_name(lmv->tgts[mds].ltd_exp, &rid, filename, namelen, - valid == OBD_MD_FLID ? valid : valid | OBD_MD_FID, - ea_size, request); + valid, ea_size, request); if (rc == 0) { body = lustre_msg_buf((*request)->rq_repmsg, 0, sizeof(*body)); LASSERT(body != NULL); - LASSERT((body->valid & OBD_MD_FID) != 0 - || body->valid == OBD_MD_FLID); if (body->valid & OBD_MD_MDS) { struct ptlrpc_request *req = NULL; @@ -1330,7 +1242,7 @@ repeat: CDEBUG(D_OTHER, "request attrs for "DFID3"\n", PFID3(&rid)); mds = lmv_fld_lookup(obd, &rid); - rc = md_getattr_lock(lmv->tgts[mds].ltd_exp, + rc = md_getattr_name(lmv->tgts[mds].ltd_exp, &rid, NULL, 1, valid, ea_size, &req); ptlrpc_req_finished(*request); *request = req; @@ -1366,12 +1278,12 @@ static int lmv_link(struct obd_export *exp, struct md_op_data *op_data, if (op_data->namelen != 0) { /* usual link request */ - obj = lmv_grab_obj(obd, &op_data->fid2); + obj = lmv_obj_grab(obd, &op_data->fid2); if (obj) { rc = raw_name2idx(obj->lo_hashtype, obj->lo_objcount, op_data->name, op_data->namelen); op_data->fid2 = obj->lo_objs[rc].li_fid; - lmv_put_obj(obj); + lmv_obj_put(obj); } mds = lmv_fld_lookup(obd, &op_data->fid2); @@ -1428,19 +1340,19 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, * target directory can be splitted, sowe should forward request * to the right MDS. */ - obj = lmv_grab_obj(obd, &op_data->fid2); + obj = lmv_obj_grab(obd, &op_data->fid2); if (obj) { mds = raw_name2idx(obj->lo_hashtype, obj->lo_objcount, (char *)new, newlen); op_data->fid2 = obj->lo_objs[mds].li_fid; CDEBUG(D_OTHER, "forward to MDS #%u ("DFID3")\n", mds, PFID3(&op_data->fid2)); - lmv_put_obj(obj); + lmv_obj_put(obj); } goto request; } - obj = lmv_grab_obj(obd, &op_data->fid1); + obj = lmv_obj_grab(obd, &op_data->fid1); if (obj) { /* * directory is already splitted, so we have to forward request @@ -1451,10 +1363,10 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, op_data->fid1 = obj->lo_objs[mds].li_fid; CDEBUG(D_OTHER, "forward to MDS #%u ("DFID3")\n", mds, PFID3(&op_data->fid1)); - lmv_put_obj(obj); + lmv_obj_put(obj); } - obj = lmv_grab_obj(obd, &op_data->fid2); + obj = lmv_obj_grab(obd, &op_data->fid2); if (obj) { /* * directory is already splitted, so we have to forward request @@ -1466,7 +1378,7 @@ static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data, op_data->fid2 = obj->lo_objs[mds].li_fid; CDEBUG(D_OTHER, "forward to MDS #%u ("DFID3")\n", mds, PFID3(&op_data->fid2)); - lmv_put_obj(obj); + lmv_obj_put(obj); } mds = lmv_fld_lookup(obd, &op_data->fid1); @@ -1485,8 +1397,7 @@ request: static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data, struct iattr *iattr, void *ea, int ealen, void *ea2, - int ea2len, void *ea3, int ea3len, - struct ptlrpc_request **request) + int ea2len, struct ptlrpc_request **request) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -1500,7 +1411,7 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data, if (rc) RETURN(rc); - obj = lmv_grab_obj(obd, &op_data->fid1); + obj = lmv_obj_grab(obd, &op_data->fid1); CDEBUG(D_OTHER, "SETATTR for "DFID3", valid 0x%x%s\n", PFID3(&op_data->fid1), iattr->ia_valid, obj ? ", splitted" : ""); @@ -1511,8 +1422,8 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data, mds = lmv_fld_lookup(obd, &op_data->fid1); rc = md_setattr(lmv->tgts[mds].ltd_exp, - op_data, iattr, ea, ealen, ea2, ea2len, - ea3, ea3len, &req); + op_data, iattr, ea, ealen, ea2, + ea2len, &req); if (lu_fid_eq(&obj->lo_fid, &obj->lo_objs[i].li_fid)) { /* @@ -1527,18 +1438,16 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data, if (rc) break; } - lmv_put_obj(obj); + lmv_obj_put(obj); } else { mds = lmv_fld_lookup(obd, &op_data->fid1); LASSERT(mds < lmv->desc.ld_tgt_count); - rc = md_setattr(lmv->tgts[mds].ltd_exp, - op_data, iattr, ea, ealen, ea2, ea2len, ea3, - ea3len, request); + rc = md_setattr(lmv->tgts[mds].ltd_exp, op_data, iattr, ea, + ealen, ea2, ea2len, request); if (rc == 0) { body = lustre_msg_buf((*request)->rq_repmsg, 0, sizeof(*body)); LASSERT(body != NULL); - LASSERT((body->valid & OBD_MD_FID) != 0); } } RETURN(rc); @@ -1591,7 +1500,7 @@ int lmv_dirobj_blocking_ast(struct ldlm_lock *lock, lock->l_resource->lr_name.name[0], lock->l_resource->lr_name.name[1], PFID3(&obj->lo_fid)); - lmv_put_obj(obj); + lmv_obj_put(obj); } break; default: @@ -1637,9 +1546,9 @@ static int lmv_readpage(struct obd_export *exp, struct lu_fid *fid, CDEBUG(D_OTHER, "READPAGE at %llu from "DFID3"\n", offset, PFID3(&rid)); - obj = lmv_grab_obj(obd, fid); + obj = lmv_obj_grab(obd, fid); if (obj) { - lmv_lock_obj(obj); + lmv_obj_lock(obj); /* find dirobj containing page with requested offset. */ for (i = 0; i < obj->lo_objcount; i++) { @@ -1649,13 +1558,13 @@ static int lmv_readpage(struct obd_export *exp, struct lu_fid *fid, } rid = obj->lo_objs[i].li_fid; - lmv_unlock_obj(obj); - lmv_put_obj(obj); + lmv_obj_unlock(obj); + lmv_obj_put(obj); CDEBUG(D_OTHER, "forward to "DFID3" with offset %lu\n", PFID3(&rid), (unsigned long)offset); } - i = lmv_fld_lookup(obd, rid); + i = lmv_fld_lookup(obd, &rid); rc = md_readpage(lmv->tgts[i].ltd_exp, &rid, offset, page, request); @@ -1673,7 +1582,7 @@ static int lmv_unlink_slaves(struct obd_export *exp, struct md_op_data *op_data, { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - struct mea *mea = op_data->mea1; + struct lmv_stripe_md *mea = op_data->mea1; struct md_op_data *op_data2; int i, mds, rc = 0; ENTRY; @@ -1709,12 +1618,12 @@ static int lmv_unlink_slaves(struct obd_export *exp, struct md_op_data *op_data, RETURN(rc); } -static int lmv_delete_inode(struct obd_export *exp, struct lu_fid *fid) +static int lmv_delete(struct obd_export *exp, struct lu_fid *fid) { ENTRY; LASSERT(exp && fid); - if (lmv_delete_obj(exp, fid)) { + if (lmv_obj_delete(exp, fid)) { CDEBUG(D_OTHER, "lmv object "DFID3" is destroyed.\n", PFID3(fid)); } @@ -1742,12 +1651,12 @@ static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data, if (op_data->namelen != 0) { struct lmv_obj *obj; - obj = lmv_grab_obj(obd, &op_data->fid1); + obj = lmv_obj_grab(obd, &op_data->fid1); if (obj) { i = raw_name2idx(obj->lo_hashtype, obj->lo_objcount, op_data->name, op_data->namelen); op_data->fid1 = obj->lo_objs[i].li_fid; - lmv_put_obj(obj); + lmv_obj_put(obj); } CDEBUG(D_OTHER, "unlink '%*s' in "DFID3" -> %u\n", op_data->namelen, op_data->name, PFID3(&op_data->fid1), @@ -1761,26 +1670,7 @@ static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data, RETURN(rc); } -static struct obd_device *lmv_get_real_obd(struct obd_export *exp, - struct lu_fid *fid) -{ - struct obd_device *obd = exp->exp_obd; - struct lmv_obd *lmv = &obd->u.lmv; - int rc, i; - ENTRY; - - rc = lmv_check_connect(obd); - if (rc) - RETURN(ERR_PTR(rc)); - i = lmv_fld_lookup(obd, fid); - obd = lmv->tgts[i].ltd_exp->exp_obd; - EXIT; - - return obd; -} - static int lmv_obd_create_single(struct obd_export *exp, struct obdo *oa, - void *acl, int acl_size, struct lov_stripe_md **ea, struct obd_trans_info *oti) { @@ -1794,8 +1684,8 @@ static int lmv_obd_create_single(struct obd_export *exp, struct obdo *oa, LASSERT(ea == NULL); LASSERT(oa->o_mds < lmv->desc.ld_tgt_count); - rc = obd_create(lmv->tgts[oa->o_mds].ltd_exp, oa, - acl, acl_size, &obj_mdp, oti); + rc = obd_create(lmv->tgts[oa->o_mds].ltd_exp, + oa, &obj_mdp, oti); RETURN(rc); } @@ -1805,14 +1695,13 @@ static int lmv_obd_create_single(struct obd_export *exp, struct obdo *oa, * values for "master" object, as it will be used. */ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, - void *acl, int acl_size, struct lov_stripe_md **ea, struct obd_trans_info *oti) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; + struct lmv_stripe_md *mea; struct lu_fid mid; int i, c, rc = 0; - struct mea *mea; ENTRY; rc = lmv_check_connect(obd); @@ -1822,15 +1711,12 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, LASSERT(oa != NULL); if (ea == NULL) { - rc = lmv_obd_create_single(exp, oa, acl, acl_size, NULL, oti); + rc = lmv_obd_create_single(exp, oa, NULL, oti); if (rc) CERROR("Can't create object, rc = %d\n", rc); RETURN(rc); } - /* acl is only suppied when mds create single remote obj */ - LASSERT(acl == NULL && acl_size == 0); - if (*ea == NULL) { rc = obd_alloc_diskmd(exp, (struct lov_mds_md **)ea); if (rc < 0) { @@ -1844,17 +1730,15 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, RETURN(-ENOMEM); } - /* - * here we should take care about splitted dir, so store cookie and fid - * for "master" object should already be allocated and passed in @oa. - */ + /* here we should take care about splitted dir, so store cookie and fid + * for "master" object should already be allocated and passed in @oa. */ LASSERT(oa->o_id != 0); LASSERT(oa->o_fid != 0); /* save "master" object fid */ - obdo2id(&mid, oa); + obdo2fid(oa, &mid); - mea = (struct mea *)*ea; + mea = (struct lmv_stripe_md *)*ea; mea->mea_master = -1; mea->mea_magic = MEA_MAGIC_ALL_CHARS; @@ -1883,8 +1767,7 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, oa->o_valid = OBD_MD_FLGENER | OBD_MD_FLTYPE | OBD_MD_FLMODE | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLID; - rc = obd_create(lmv->tgts[c].ltd_exp, oa, NULL, 0, - &obj_mdp, oti); + rc = obd_create(lmv->tgts[c].ltd_exp, oa, &obj_mdp, oti); if (rc) { CERROR("obd_create() failed on MDT target %d, " "error %d\n", c, rc); @@ -1908,7 +1791,7 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, LASSERT(oa->o_id); /* fill mea by store cookie and fid */ - obdo2id(&mea->mea_ids[c], oa); + obdo2fid(oa, &mea->mea_ids[c]); c++; } LASSERT(c == mea->mea_count); @@ -1919,42 +1802,49 @@ int lmv_obd_create(struct obd_export *exp, struct obdo *oa, RETURN(rc); } -static int lmv_llog_init(struct obd_device *obd, struct obd_llogs *llogs, - struct obd_device *tgt, int count, - struct llog_catid *logid) +static int lmv_llog_init(struct obd_device *obd, struct obd_device *tgt, + int count, struct llog_catid *logid) { struct llog_ctxt *ctxt; int rc; ENTRY; - rc = obd_llog_setup(obd, llogs, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL, - &llog_client_ops); + rc = llog_setup(obd, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL, + &llog_client_ops); if (rc == 0) { - ctxt = llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT); + ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT); ctxt->loc_imp = tgt->u.cli.cl_import; } RETURN(rc); } -static int lmv_llog_finish(struct obd_device *obd, - struct obd_llogs *llogs, int count) +static int lmv_llog_finish(struct obd_device *obd, int count) { int rc; ENTRY; - rc = obd_llog_cleanup(llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT)); + rc = llog_cleanup(llog_get_context(obd, LLOG_CONFIG_REPL_CTXT)); RETURN(rc); } -static int lmv_precleanup(struct obd_device *obd, int flags) +static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage) { int rc = 0; - - rc = obd_llog_finish(obd, &obd->obd_llogs, 0); - if (rc != 0) - CERROR("failed to cleanup llogging subsystems\n"); + switch (stage) { + case OBD_CLEANUP_EARLY: + /* XXX: here should be calling obd_precleanup() down to + * stack. */ + break; + case OBD_CLEANUP_SELF_EXP: + rc = obd_llog_finish(obd, 0); + if (rc != 0) + CERROR("failed to cleanup llogging subsystems\n"); + break; + default: + break; + } RETURN(rc); } @@ -1978,7 +1868,7 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen, __u32 *mdsize = val; *vallen = sizeof(__u32); *mdsize = sizeof(struct lu_fid) * lmv->desc.ld_tgt_count - + sizeof(struct mea); + + sizeof(struct lmv_stripe_md); RETURN(0); } else if (keylen == strlen("mdsnum") && !strcmp(key, "mdsnum")) { struct obd_uuid *cluuid = &lmv->cluuid; @@ -2041,7 +1931,7 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen, rc = obd_get_info(lmv->tgts[0].ltd_exp, keylen, key, vallen, val); RETURN(rc); - } else if (keylen >= strlen("getext") && !strcmp(key, "getext")) { + }/* else if (keylen >= strlen("getext") && !strcmp(key, "getext")) { struct lmv_tgt_desc *tgts; int i; @@ -2053,7 +1943,6 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen, for (i = 0, tgts = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgts++) { - /* all tgts should be connected when this get called. */ if (!tgts || !tgts->ltd_exp) { CERROR("target not setup?\n"); continue; @@ -2065,7 +1954,7 @@ static int lmv_get_info(struct obd_export *exp, __u32 keylen, RETURN(rc); } RETURN(0); - } + }*/ CDEBUG(D_IOCTL, "invalid key\n"); RETURN(-EINVAL); @@ -2112,7 +2001,7 @@ int lmv_set_info(struct obd_export *exp, obd_count keylen, struct obd_device *tgt_obd; tgt_obd = class_find_client_obd(&tgt->uuid, - OBD_MDC_DEVICENAME, + LUSTRE_MDC_NAME, &obd->obd_uuid); if (!tgt_obd) { CERROR("can't set info %s, " @@ -2179,12 +2068,12 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, { struct obd_device *obd = class_exp2obd(exp); struct lmv_obd *lmv = &obd->u.lmv; - struct mea *meap, *lsmp; + struct lmv_stripe_md *meap, *lsmp; int mea_size, i; ENTRY; mea_size = (sizeof(struct lu_fid) * - lmv->desc.ld_tgt_count) + sizeof(struct mea); + lmv->desc.ld_tgt_count) + sizeof(struct lmv_stripe_md); if (!lmmp) RETURN(mea_size); @@ -2203,8 +2092,8 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, if (!lsm) RETURN(mea_size); - lsmp = (struct mea *)lsm; - meap = (struct mea *)*lmmp; + lsmp = (struct lmv_stripe_md *)lsm; + meap = (struct lmv_stripe_md *)*lmmp; if (lsmp->mea_magic != MEA_MAGIC_LAST_CHAR && lsmp->mea_magic != MEA_MAGIC_ALL_CHARS) @@ -2216,7 +2105,7 @@ int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp, for (i = 0; i < lmv->desc.ld_tgt_count; i++) { meap->mea_ids[i] = meap->mea_ids[i]; - id_cpu_to_le(&meap->mea_ids[i]); + fid_cpu_to_le(&meap->mea_ids[i]); } RETURN(mea_size); @@ -2226,15 +2115,15 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, struct lov_mds_md *lmm, int lmm_size) { struct obd_device *obd = class_exp2obd(exp); - struct mea **tmea = (struct mea **)lsmp; - struct mea *mea = (struct mea *)lmm; + struct lmv_stripe_md **tmea = (struct lmv_stripe_md **)lsmp; + struct lmv_stripe_md *mea = (struct lmv_stripe_md *)lmm; struct lmv_obd *lmv = &obd->u.lmv; - int mea_size, i, rc = 0; + int mea_size, i; __u32 magic; ENTRY; mea_size = sizeof(struct lu_fid) * - lmv->desc.ld_tgt_count + sizeof(struct mea); + lmv->desc.ld_tgt_count + sizeof(struct lmv_stripe_md); if (lsmp == NULL) return mea_size; @@ -2258,18 +2147,8 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, { magic = le32_to_cpu(mea->mea_magic); } else { - struct mea_old *old = (struct mea_old *)lmm; - - mea_size = sizeof(struct lu_fid) * old->mea_count + - sizeof(struct mea_old); - - if (old->mea_count > 256 || old->mea_master > 256 || - lmm_size < mea_size || old->mea_master > old->mea_count) { - CWARN("bad MEA: count %u, master %u, size %u\n", - old->mea_count, old->mea_master, mea_size); - GOTO(out_free_mea, rc = -EINVAL); - } - magic = MEA_MAGIC_LAST_CHAR; + /* old mea isnot handled here */ + LBUG(); } (*tmea)->mea_magic = magic; @@ -2278,22 +2157,20 @@ int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp, for (i = 0; i < (*tmea)->mea_count; i++) { (*tmea)->mea_ids[i] = mea->mea_ids[i]; - id_le_to_cpu(&(*tmea)->mea_ids[i]); + fid_le_to_cpu(&(*tmea)->mea_ids[i]); } RETURN(mea_size); - -out_free_mea: - OBD_FREE(*tmea, mea_size); - return rc; } int lmv_brw(int rw, struct obd_export *exp, struct obdo *oa, struct lov_stripe_md *ea, obd_count oa_bufs, struct brw_page *pgarr, struct obd_trans_info *oti) { + /* splitting is not needed in lmv */ +#if 0 struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; - struct mea *mea = (struct mea *) ea; + struct lmv_stripe_md *mea = (struct lmv_stripe_md *) ea; int err; LASSERT(oa != NULL); @@ -2308,6 +2185,8 @@ int lmv_brw(int rw, struct obd_export *exp, struct obdo *oa, err = obd_brw(rw, lmv->tgts[oa->o_mds].ltd_exp, oa, NULL, oa_bufs, pgarr, oti); RETURN(err); +#endif + return -EINVAL; } static int lmv_cancel_unused(struct obd_export *exp, @@ -2333,10 +2212,60 @@ static int lmv_cancel_unused(struct obd_export *exp, RETURN(rc); } +int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data) +{ + struct obd_device *obd = exp->exp_obd; + struct lmv_obd *lmv = &obd->u.lmv; + + ENTRY; + RETURN(md_set_lock_data(lmv->tgts[0].ltd_exp, lockh, data)); +} + +int lmv_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, + int offset, struct obd_export *dt_exp, struct lustre_md *md) +{ + struct obd_device *obd = exp->exp_obd; + struct lmv_obd *lmv = &obd->u.lmv; + int rc; + + ENTRY; + rc = md_get_lustre_md(lmv->tgts[0].ltd_exp, req, offset, dt_exp, md); + RETURN(rc); +} + +int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md) +{ + struct obd_device *obd = exp->exp_obd; + struct lmv_obd *lmv = &obd->u.lmv; + + ENTRY; + RETURN(md_free_lustre_md(lmv->tgts[0].ltd_exp, md)); +} + +int lmv_set_open_replay_data(struct obd_export *exp, + struct obd_client_handle *och, + struct ptlrpc_request *open_req) +{ + struct obd_device *obd = exp->exp_obd; + struct lmv_obd *lmv = &obd->u.lmv; + + ENTRY; + RETURN(md_set_open_replay_data(lmv->tgts[0].ltd_exp, + och, open_req)); +} + +int lmv_clear_open_replay_data(struct obd_export *exp, + struct obd_client_handle *och) +{ + struct obd_device *obd = exp->exp_obd; + struct lmv_obd *lmv = &obd->u.lmv; + + ENTRY; + RETURN(md_clear_open_replay_data(lmv->tgts[0].ltd_exp, och)); +} + struct obd_ops lmv_obd_ops = { .o_owner = THIS_MODULE, - .o_attach = lmv_attach, - .o_detach = lmv_detach, .o_setup = lmv_setup, .o_cleanup = lmv_cleanup, .o_precleanup = lmv_precleanup, @@ -2352,33 +2281,34 @@ struct obd_ops lmv_obd_ops = { .o_packmd = lmv_packmd, .o_unpackmd = lmv_unpackmd, .o_brw = lmv_brw, - .o_init_ea_size = lmv_init_ea_size, .o_notify = lmv_notify, .o_iocontrol = lmv_iocontrol, .o_cancel_unused = lmv_cancel_unused, }; struct md_ops lmv_md_ops = { - .m_getstatus = lmv_getstatus, - .m_getattr = lmv_getattr, - .m_change_cbdata = lmv_change_cbdata, - .m_change_cbdata_name = lmv_change_cbdata_name, - .m_close = lmv_close, - .m_create = lmv_create, - .m_done_writing = lmv_done_writing, - .m_enqueue = lmv_enqueue, - .m_getattr_lock = lmv_getattr_lock, - .m_intent_lock = lmv_intent_lock, - .m_link = lmv_link, - .m_rename = lmv_rename, - .m_setattr = lmv_setattr, - .m_sync = lmv_sync, - .m_readpage = lmv_readpage, - .m_unlink = lmv_unlink, - .m_get_real_obd = lmv_get_real_obd, - .m_valid_attrs = lmv_valid_attrs, - .m_delete_inode = lmv_delete_inode, - .m_access_check = lmv_access_check, + .m_getstatus = lmv_getstatus, + .m_change_cbdata = lmv_change_cbdata, + .m_close = lmv_close, + .m_create = lmv_create, + .m_done_writing = lmv_done_writing, + .m_enqueue = lmv_enqueue, + .m_getattr = lmv_getattr, + .m_getattr_name = lmv_getattr_name, + .m_intent_lock = lmv_intent_lock, + .m_link = lmv_link, + .m_rename = lmv_rename, + .m_setattr = lmv_setattr, + .m_sync = lmv_sync, + .m_readpage = lmv_readpage, + .m_unlink = lmv_unlink, + .m_init_ea_size = lmv_init_ea_size, + .m_delete = lmv_delete, + .m_set_lock_data = lmv_set_lock_data, + .m_get_lustre_md = lmv_get_lustre_md, + .m_free_lustre_md = lmv_free_lustre_md, + .m_set_open_replay_data = lmv_set_open_replay_data, + .m_clear_open_replay_data = lmv_clear_open_replay_data }; int __init lmv_init(void) @@ -2396,8 +2326,7 @@ int __init lmv_init(void) lprocfs_init_vars(lmv, &lvars); rc = class_register_type(&lmv_obd_ops, &lmv_md_ops, - lvars.module_vars, - OBD_LMV_DEVICENAME); + lvars.module_vars, LUSTRE_LMV_NAME, NULL); if (rc) kmem_cache_destroy(obj_cache); @@ -2407,7 +2336,7 @@ int __init lmv_init(void) #ifdef __KERNEL__ static void lmv_exit(void) { - class_unregister_type(OBD_LMV_DEVICENAME); + class_unregister_type(LUSTRE_LMV_NAME); LASSERTF(kmem_cache_destroy(obj_cache) == 0, "can't free lmv objects cache, %d object(s)" diff --git a/lustre/lmv/lmv_objmgr.c b/lustre/lmv/lmv_object.c similarity index 84% rename from lustre/lmv/lmv_objmgr.c rename to lustre/lmv/lmv_object.c index 9be9d43..034e100 100644 --- a/lustre/lmv/lmv_objmgr.c +++ b/lustre/lmv/lmv_object.c @@ -54,9 +54,9 @@ static spinlock_t obj_list_lock = SPIN_LOCK_UNLOCKED; /* creates new obj on passed @fid and @mea. */ struct lmv_obj * -lmv_alloc_obj(struct obd_device *obd, +lmv_obj_alloc(struct obd_device *obd, struct lu_fid *fid, - struct mea *mea) + struct lmv_stripe_md *mea) { int i; struct lmv_obj *obj; @@ -108,7 +108,7 @@ err_obj: /* destroy passed @obj. */ void -lmv_free_obj(struct lmv_obj *obj) +lmv_obj_free(struct lmv_obj *obj) { struct lmv_obd *lmv = &obj->lo_obd->u.lmv; unsigned int obj_size; @@ -124,37 +124,37 @@ lmv_free_obj(struct lmv_obj *obj) } static void -__add_obj(struct lmv_obj *obj) +__lmv_obj_add(struct lmv_obj *obj) { atomic_inc(&obj->lo_count); list_add(&obj->lo_list, &obj_list); } void -lmv_add_obj(struct lmv_obj *obj) +lmv_obj_add(struct lmv_obj *obj) { spin_lock(&obj_list_lock); - __add_obj(obj); + __lmv_obj_add(obj); spin_unlock(&obj_list_lock); } static void -__del_obj(struct lmv_obj *obj) +__lmv_obj_del(struct lmv_obj *obj) { list_del(&obj->lo_list); - lmv_free_obj(obj); + lmv_obj_free(obj); } void -lmv_del_obj(struct lmv_obj *obj) +lmv_obj_del(struct lmv_obj *obj) { spin_lock(&obj_list_lock); - __del_obj(obj); + __lmv_obj_del(obj); spin_unlock(&obj_list_lock); } static struct lmv_obj * -__get_obj(struct lmv_obj *obj) +__lmv_obj_get(struct lmv_obj *obj) { LASSERT(obj != NULL); atomic_inc(&obj->lo_count); @@ -162,16 +162,16 @@ __get_obj(struct lmv_obj *obj) } struct lmv_obj * -lmv_get_obj(struct lmv_obj *obj) +lmv_obj_get(struct lmv_obj *obj) { spin_lock(&obj_list_lock); - __get_obj(obj); + __lmv_obj_get(obj); spin_unlock(&obj_list_lock); return obj; } static void -__put_obj(struct lmv_obj *obj) +__lmv_obj_put(struct lmv_obj *obj) { LASSERT(obj); @@ -179,20 +179,20 @@ __put_obj(struct lmv_obj *obj) struct lu_fid *fid = &obj->lo_fid; CDEBUG(D_OTHER, "last reference to "DFID3" - " "destroying\n", PFID3(fid)); - __del_obj(obj); + __lmv_obj_del(obj); } } void -lmv_put_obj(struct lmv_obj *obj) +lmv_obj_put(struct lmv_obj *obj) { spin_lock(&obj_list_lock); - __put_obj(obj); + __lmv_obj_put(obj); spin_unlock(&obj_list_lock); } static struct lmv_obj * -__grab_obj(struct obd_device *obd, struct lu_fid *fid) +__lmv_obj_grab(struct obd_device *obd, struct lu_fid *fid) { struct lmv_obj *obj; struct list_head *cur; @@ -217,20 +217,20 @@ __grab_obj(struct obd_device *obd, struct lu_fid *fid) /* check if this is what we're looking for. */ if (lu_fid_eq(&obj->lo_fid, fid)) - return __get_obj(obj); + return __lmv_obj_get(obj); } return NULL; } struct lmv_obj * -lmv_grab_obj(struct obd_device *obd, struct lu_fid *fid) +lmv_obj_grab(struct obd_device *obd, struct lu_fid *fid) { struct lmv_obj *obj; ENTRY; spin_lock(&obj_list_lock); - obj = __grab_obj(obd, fid); + obj = __lmv_obj_grab(obd, fid); spin_unlock(&obj_list_lock); RETURN(obj); @@ -239,33 +239,34 @@ lmv_grab_obj(struct obd_device *obd, struct lu_fid *fid) /* looks in objects list for an object that matches passed @fid. If it is not * found -- creates it using passed @mea and puts onto list. */ static struct lmv_obj * -__create_obj(struct obd_device *obd, struct lu_fid *fid, struct mea *mea) +__lmv_obj_create(struct obd_device *obd, struct lu_fid *fid, + struct lmv_stripe_md *mea) { struct lmv_obj *new, *obj; ENTRY; - obj = lmv_grab_obj(obd, fid); + obj = lmv_obj_grab(obd, fid); if (obj) RETURN(obj); /* no such object yet, allocate and initialize it. */ - new = lmv_alloc_obj(obd, fid, mea); + new = lmv_obj_alloc(obd, fid, mea); if (!new) RETURN(NULL); /* check if someone create it already while we were dealing with * allocating @obj. */ spin_lock(&obj_list_lock); - obj = __grab_obj(obd, fid); + obj = __lmv_obj_grab(obd, fid); if (obj) { /* someone created it already - put @obj and getting out. */ - lmv_free_obj(new); + lmv_obj_free(new); spin_unlock(&obj_list_lock); RETURN(obj); } - __add_obj(new); - __get_obj(new); + __lmv_obj_add(new); + __lmv_obj_get(new); spin_unlock(&obj_list_lock); @@ -279,7 +280,8 @@ __create_obj(struct obd_device *obd, struct lu_fid *fid, struct mea *mea) /* creates object from passed @fid and @mea. If @mea is NULL, it will be * obtained from correct MDT and used for constructing the object. */ struct lmv_obj * -lmv_create_obj(struct obd_export *exp, struct lu_fid *fid, struct mea *mea) +lmv_obj_create(struct obd_export *exp, struct lu_fid *fid, + struct lmv_stripe_md *mea) { struct obd_device *obd = exp->exp_obd; struct lmv_obd *lmv = &obd->u.lmv; @@ -306,16 +308,15 @@ lmv_create_obj(struct obd_export *exp, struct lu_fid *fid, struct mea *mea) mds = lmv_fld_lookup(obd, fid); - rc = md_getattr(lmv->tgts[mds].ltd_exp, - fid, valid, NULL, NULL, 0, mealen, NULL, &req); + rc = md_getattr(lmv->tgts[mds].ltd_exp, fid, valid, mealen, &req); if (rc) { CERROR("md_getattr() failed, error %d\n", rc); GOTO(cleanup, obj = ERR_PTR(rc)); } - rc = mdc_req2lustre_md(exp, req, 0, NULL, &md); + rc = md_get_lustre_md(exp, req, 0, NULL, &md); if (rc) { - CERROR("mdc_req2lustre_md() failed, error %d\n", rc); + CERROR("mdc_get_lustre_md() failed, error %d\n", rc); GOTO(cleanup, obj = ERR_PTR(rc)); } @@ -326,7 +327,7 @@ lmv_create_obj(struct obd_export *exp, struct lu_fid *fid, struct mea *mea) } /* got mea, now create obj for it. */ - obj = __create_obj(obd, fid, mea); + obj = __lmv_obj_create(obd, fid, mea); if (!obj) { CERROR("Can't create new object "DFID3"\n", PFID3(fid)); @@ -347,10 +348,10 @@ cleanup: * looks for object with @fid and orders to destroy it. It is possible the object * will not be destroyed right now, because it is still using by someone. In * this case it will be marked as "freeing" and will not be accessible anymore - * for subsequent callers of lmv_grab_obj(). + * for subsequent callers of lmv_obj_grab(). */ int -lmv_delete_obj(struct obd_export *exp, struct lu_fid *fid) +lmv_obj_delete(struct obd_export *exp, struct lu_fid *fid) { struct obd_device *obd = exp->exp_obd; struct lmv_obj *obj; @@ -358,11 +359,11 @@ lmv_delete_obj(struct obd_export *exp, struct lu_fid *fid) ENTRY; spin_lock(&obj_list_lock); - obj = __grab_obj(obd, fid); + obj = __lmv_obj_grab(obd, fid); if (obj) { obj->lo_state |= O_FREEING; - __put_obj(obj); - __put_obj(obj); + __lmv_obj_put(obj); + __lmv_obj_put(obj); rc = 1; } spin_unlock(&obj_list_lock); @@ -371,7 +372,7 @@ lmv_delete_obj(struct obd_export *exp, struct lu_fid *fid) } int -lmv_setup_mgr(struct obd_device *obd) +lmv_mgr_setup(struct obd_device *obd) { ENTRY; LASSERT(obd != NULL); @@ -383,7 +384,7 @@ lmv_setup_mgr(struct obd_device *obd) } void -lmv_cleanup_mgr(struct obd_device *obd) +lmv_mgr_cleanup(struct obd_device *obd) { struct list_head *cur, *tmp; struct lmv_obj *obj; @@ -404,7 +405,7 @@ lmv_cleanup_mgr(struct obd_device *obd) CERROR("obj "DFID3" has count > 1 (%d)\n", PFID3(&obj->lo_fid), atomic_read(&obj->lo_count)); } - __put_obj(obj); + __lmv_obj_put(obj); } spin_unlock(&obj_list_lock); EXIT; diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 8cf28a1..bcf6c4a 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -2478,7 +2478,7 @@ int __init lov_init(void) quota_interface = PORTAL_SYMBOL_GET(lov_quota_interface); init_obd_quota_ops(quota_interface, &lov_obd_ops); - rc = class_register_type(&lov_obd_ops, lvars.module_vars, + rc = class_register_type(&lov_obd_ops, NULL, lvars.module_vars, OBD_LOV_DEVICENAME, NULL); if (rc && quota_interface) PORTAL_SYMBOL_PUT(osc_quota_interface); diff --git a/lustre/mdc/mdc_internal.h b/lustre/mdc/mdc_internal.h index f4022b1..938a654 100644 --- a/lustre/mdc/mdc_internal.h +++ b/lustre/mdc/mdc_internal.h @@ -1,4 +1,32 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * + * Copyright (c) 2003 Cluster File Systems, Inc. + * + * This file is part of the Lustre file system, http://www.lustre.org + * Lustre is a trademark of Cluster File Systems, Inc. + * + * You may have signed or agreed to another license before downloading + * this software. If so, you are bound by the terms and conditions + * of that agreement, and the following does not apply to you. See the + * LICENSE file included with this distribution for more information. + * + * If you did not agree to a different license, then this copy of Lustre + * is open source software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * In either case, Lustre is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * license text for more details. + */ + +#ifndef _MDC_INTERNAL_H +#define _MDC_INTERNAL_H + #include + void mdc_pack_req_body(struct ptlrpc_request *req, int offset, __u64 valid, struct lu_fid *fid, int ea_size); void mdc_pack_rep_body(struct ptlrpc_request *); @@ -75,3 +103,95 @@ static inline void mdc_put_rpc_lock(struct mdc_rpc_lock *lck, /* Quota stuff */ extern quota_interface_t *quota_interface; +/* mdc/mdc_locks.c */ +int mdc_set_lock_data(struct obd_export *exp, + __u64 *lockh, void *data); + +int mdc_change_cbdata(struct obd_export *exp, struct lu_fid *fid, + ldlm_iterator_t it, void *data); +int mdc_intent_lock(struct obd_export *exp, + struct md_op_data *, + void *lmm, int lmmsize, + struct lookup_intent *, int, + struct ptlrpc_request **reqp, + ldlm_blocking_callback cb_blocking, int extra_lock_flags); +int mdc_enqueue(struct obd_export *exp, + int lock_type, + struct lookup_intent *it, + int lock_mode, + struct md_op_data *op_data, + struct lustre_handle *lockh, + void *lmm, + int lmmlen, + ldlm_completion_callback cb_completion, + ldlm_blocking_callback cb_blocking, + void *cb_data, int extra_lock_flags); + +/* mdc/mdc_request.c */ +int mdc_init_ea_size(struct obd_export *exp, int easize, int def_easzie, + int cookiesize); + +int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid); +int mdc_getattr(struct obd_export *exp, struct lu_fid *fid, + obd_valid valid, int ea_size, + struct ptlrpc_request **request); +int mdc_getattr_name(struct obd_export *exp, struct lu_fid *fid, + const char *filename, int namelen, obd_valid valid, + int ea_size, struct ptlrpc_request **request); +int mdc_setattr(struct obd_export *exp, struct md_op_data *op_data, + struct iattr *iattr, void *ea, int ealen, void *ea2, int ea2len, + struct ptlrpc_request **request); +int mdc_setxattr(struct obd_export *exp, struct lu_fid *fid, + obd_valid valid, const char *xattr_name, + const char *input, int input_size, + int output_size, int flags, + struct ptlrpc_request **request); +int mdc_getxattr(struct obd_export *exp, struct lu_fid *fid, + obd_valid valid, const char *xattr_name, + const char *input, int input_size, + int output_size, struct ptlrpc_request **request); +int mdc_open(struct obd_export *exp, obd_id ino, int type, int flags, + struct lov_mds_md *lmm, int lmm_size, struct lustre_handle *fh, + struct ptlrpc_request **); + +struct obd_client_handle; + +int mdc_get_lustre_md(struct obd_export *md_exp, struct ptlrpc_request *req, + int offset, struct obd_export *dt_exp, struct lustre_md *md); + +int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md); + +int mdc_set_open_replay_data(struct obd_export *exp, + struct obd_client_handle *och, + struct ptlrpc_request *open_req); + +int mdc_clear_open_replay_data(struct obd_export *exp, + struct obd_client_handle *och); + +int mdc_close(struct obd_export *, struct md_op_data *, + struct obd_client_handle *, struct ptlrpc_request **); + +int mdc_readpage(struct obd_export *exp, struct lu_fid *fid, + __u64 offset, struct page *, struct ptlrpc_request **); + +int mdc_create(struct obd_export *exp, struct md_op_data *op_data, + const void *data, int datalen, int mode, __u32 uid, + __u32 gid, __u32 cap_effective, __u64 rdev, + struct ptlrpc_request **request); + +int mdc_unlink(struct obd_export *exp, struct md_op_data *op_data, + struct ptlrpc_request **request); + +int mdc_link(struct obd_export *exp, struct md_op_data *op_data, + struct ptlrpc_request **); + +int mdc_rename(struct obd_export *exp, struct md_op_data *op_data, + const char *old, int oldlen, const char *new, int newlen, + struct ptlrpc_request **request); + +int mdc_sync(struct obd_export *exp, struct lu_fid *fid, + struct ptlrpc_request **); + +int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data); + +#endif diff --git a/lustre/mdc/mdc_locks.c b/lustre/mdc/mdc_locks.c index 513a3fb..803e40a 100644 --- a/lustre/mdc/mdc_locks.c +++ b/lustre/mdc/mdc_locks.c @@ -109,18 +109,17 @@ int it_open_error(int phase, struct lookup_intent *it) EXPORT_SYMBOL(it_open_error); /* this must be called on a lockh that is known to have a referenced lock */ -void mdc_set_lock_data(__u64 *l, void *data) +int mdc_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data) { struct ldlm_lock *lock; - struct lustre_handle *lockh = (struct lustre_handle *)l; ENTRY; - if (!*l) { + if (!*lockh) { EXIT; - return; + RETURN(0); } - lock = ldlm_handle2lock(lockh); + lock = ldlm_handle2lock((struct lustre_handle *)lockh); LASSERT(lock != NULL); l_lock(&lock->l_resource->lr_namespace->ns_lock); @@ -140,9 +139,8 @@ void mdc_set_lock_data(__u64 *l, void *data) l_unlock(&lock->l_resource->lr_namespace->ns_lock); LDLM_LOCK_PUT(lock); - EXIT; + RETURN(0); } -EXPORT_SYMBOL(mdc_set_lock_data); int mdc_change_cbdata(struct obd_export *exp, struct lu_fid *fid, ldlm_iterator_t it, void *data) @@ -499,8 +497,6 @@ int mdc_enqueue(struct obd_export *exp, RETURN(rc); } -EXPORT_SYMBOL(mdc_enqueue); - /* * This long block is all about fixing up the lock and request state * so that it is correct as of the moment _before_ the operation was @@ -531,14 +527,15 @@ EXPORT_SYMBOL(mdc_enqueue); int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, void *lmm, int lmmsize, struct lookup_intent *it, int lookup_flags, struct ptlrpc_request **reqp, - ldlm_blocking_callback cb_blocking, int extra_lock_flags) + ldlm_blocking_callback cb_blocking, + int extra_lock_flags) { - struct lustre_handle lockh; struct ptlrpc_request *request; - int rc = 0; - struct mdt_body *mdt_body; struct lustre_handle old_lock; + struct lustre_handle lockh; + struct mdt_body *mdt_body; struct ldlm_lock *lock; + int rc = 0; ENTRY; LASSERT(it); @@ -591,7 +588,6 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, * this and use the request from revalidate. In this case, revalidate * never dropped its reference, so the refcounts are all OK */ if (!it_disposition(it, DISP_ENQ_COMPLETE)) { - rc = mdc_enqueue(exp, LDLM_IBITS, it, it_to_lock_mode(it), op_data, &lockh, lmm, lmmsize, ldlm_completion_ast, cb_blocking, NULL, @@ -693,4 +689,3 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data, RETURN(rc); } -EXPORT_SYMBOL(mdc_intent_lock); diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 23bf934..d76dcce 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -165,7 +165,7 @@ int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size, } int mdc_getattr(struct obd_export *exp, struct lu_fid *fid, - obd_valid valid, unsigned int ea_size, + obd_valid valid, int ea_size, struct ptlrpc_request **request) { struct ptlrpc_request *req; @@ -199,8 +199,8 @@ int mdc_getattr(struct obd_export *exp, struct lu_fid *fid, } int mdc_getattr_name(struct obd_export *exp, struct lu_fid *fid, - const char *filename, int namelen, unsigned long valid, - unsigned int ea_len, struct ptlrpc_request **request) + const char *filename, int namelen, obd_valid valid, + int ea_len, struct ptlrpc_request **request) { struct ptlrpc_request *req; int rc, size[] = { sizeof(struct mdt_body), namelen }; @@ -370,9 +370,8 @@ int mdc_unpack_acl(struct obd_export *exp, struct ptlrpc_request *req, #define mdc_unpack_acl(exp, req, md, offset) 0 #endif -int mdc_req2lustre_md(struct ptlrpc_request *req, int offset, - struct obd_export *exp, - struct lustre_md *md) +int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req, + int offset, struct obd_export *dt_exp, struct lustre_md *md) { int rc = 0; ENTRY; @@ -400,7 +399,7 @@ int mdc_req2lustre_md(struct ptlrpc_request *req, int offset, LASSERT (lmm != NULL); LASSERT_REPSWABBED (req, offset); - rc = obd_unpackmd(exp, &md->lsm, lmm, lmmsize); + rc = obd_unpackmd(dt_exp, &md->lsm, lmm, lmmsize); if (rc < 0) RETURN(rc); @@ -410,12 +409,11 @@ int mdc_req2lustre_md(struct ptlrpc_request *req, int offset, offset++; } - /* for ACL, it's possible that FLACL is set but aclsize is zero. - * only when aclsize != 0 there's an actual segment for ACL in - * reply buffer. - */ + /* for ACL, it's possible that FLACL is set but aclsize is zero. only + * when aclsize != 0 there's an actual segment for ACL in reply + * buffer. */ if ((md->body->valid & OBD_MD_FLACL) && md->body->aclsize) { - rc = mdc_unpack_acl(exp, req, md, offset); + rc = mdc_unpack_acl(dt_exp, req, md, offset); if (rc) GOTO(err_out, rc); offset++; @@ -425,12 +423,13 @@ out: err_out: if (md->lsm) - obd_free_memmd(exp, &md->lsm); + obd_free_memmd(dt_exp, &md->lsm); goto out; } -void mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md) +int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { + ENTRY; if (md->lsm) obd_free_memmd(exp, &md->lsm); @@ -440,6 +439,7 @@ void mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md) md->posix_acl = NULL; } #endif + RETURN(0); } static void mdc_commit_open(struct ptlrpc_request *req) @@ -505,8 +505,9 @@ static void mdc_replay_open(struct ptlrpc_request *req) EXIT; } -void mdc_set_open_replay_data(struct obd_client_handle *och, - struct ptlrpc_request *open_req) +int mdc_set_open_replay_data(struct obd_export *exp, + struct obd_client_handle *och, + struct ptlrpc_request *open_req) { struct mdc_open_data *mod; struct mdt_rec_create *rec = lustre_msg_buf(open_req->rq_reqmsg, @@ -514,7 +515,8 @@ void mdc_set_open_replay_data(struct obd_client_handle *och, sizeof(*rec)); struct mdt_body *body = lustre_msg_buf(open_req->rq_repmsg, 1, sizeof(*body)); - + ENTRY; + LASSERT(body != NULL); /* incoming message in my byte order (it's been swabbed) */ LASSERT(rec != NULL); @@ -524,7 +526,7 @@ void mdc_set_open_replay_data(struct obd_client_handle *och, OBD_ALLOC(mod, sizeof(*mod)); if (mod == NULL) { DEBUG_REQ(D_ERROR, open_req, "can't allocate mdc_open_data"); - return; + RETURN(0); } och->och_mod = mod; @@ -537,11 +539,14 @@ void mdc_set_open_replay_data(struct obd_client_handle *och, open_req->rq_cb_data = mod; DEBUG_REQ(D_HA, open_req, "set up replay data"); + RETURN(0); } -void mdc_clear_open_replay_data(struct obd_client_handle *och) +int mdc_clear_open_replay_data(struct obd_export *exp, + struct obd_client_handle *och) { struct mdc_open_data *mod = och->och_mod; + ENTRY; /* Don't free the structure now (it happens in mdc_commit_open, after * we're sure we won't need to fix up the close request in the future), @@ -551,6 +556,7 @@ void mdc_clear_open_replay_data(struct obd_client_handle *och) if (mod != NULL) mod->mod_och = NULL; och->och_mod = NULL; + RETURN(0); } static void mdc_commit_close(struct ptlrpc_request *req) @@ -1114,42 +1120,21 @@ err_rpc_lock: * us to make MDS RPCs with large enough reply buffers to hold the * maximum-sized (= maximum striped) EA and cookie without having to * calculate this (via a call into the LOV + OSCs) each time we make an RPC. */ -int mdc_init_ea_size(struct obd_export *mdc_exp, struct obd_export *lov_exp) +int mdc_init_ea_size(struct obd_export *exp, int easize, + int def_easize, int cookiesize) { - struct obd_device *obd = mdc_exp->exp_obd; + struct obd_device *obd = exp->exp_obd; struct client_obd *cli = &obd->u.cli; - struct lov_stripe_md lsm = { .lsm_magic = LOV_MAGIC }; - struct lov_desc desc; - __u32 valsize = sizeof(desc); - __u32 stripes; - int rc, size; ENTRY; + if (cli->cl_max_mds_easize < easize) + cli->cl_max_mds_easize = easize; - rc = obd_get_info(lov_exp, strlen(KEY_LOVDESC) + 1, KEY_LOVDESC, - &valsize, &desc); - if (rc) - RETURN(rc); - - stripes = min(desc.ld_tgt_count, (__u32)LOV_MAX_STRIPE_COUNT); - lsm.lsm_stripe_count = stripes; - size = obd_size_diskmd(lov_exp, &lsm); - - if (cli->cl_max_mds_easize < size) - cli->cl_max_mds_easize = size; + if (cli->cl_default_mds_easize < def_easize) + cli->cl_default_mds_easize = def_easize; - lsm.lsm_stripe_count = desc.ld_default_stripe_count; - size = obd_size_diskmd(lov_exp, &lsm); - - if (cli->cl_default_mds_easize < size) - cli->cl_default_mds_easize = size; - - size = stripes * sizeof(struct llog_cookie); - if (cli->cl_max_mds_cookiesize < size) - cli->cl_max_mds_cookiesize = size; - - CDEBUG(D_HA, "updating max_mdsize/max_cookiesize: %d/%d\n", - cli->cl_max_mds_easize, cli->cl_max_mds_cookiesize); + if (cli->cl_max_mds_cookiesize < cookiesize) + cli->cl_max_mds_cookiesize = cookiesize; RETURN(0); } @@ -1225,22 +1210,46 @@ static int mdc_llog_finish(struct obd_device *obd, int count) } struct obd_ops mdc_obd_ops = { - .o_owner = THIS_MODULE, - .o_setup = mdc_setup, - .o_precleanup = mdc_precleanup, - .o_cleanup = mdc_cleanup, - .o_add_conn = client_import_add_conn, - .o_del_conn = client_import_del_conn, - .o_connect = client_connect_import, - .o_disconnect = client_disconnect_export, - .o_iocontrol = mdc_iocontrol, - .o_set_info = mdc_set_info, - .o_statfs = mdc_statfs, - .o_pin = mdc_pin, - .o_unpin = mdc_unpin, - .o_import_event = mdc_import_event, - .o_llog_init = mdc_llog_init, - .o_llog_finish = mdc_llog_finish, + .o_owner = THIS_MODULE, + .o_setup = mdc_setup, + .o_precleanup = mdc_precleanup, + .o_cleanup = mdc_cleanup, + .o_add_conn = client_import_add_conn, + .o_del_conn = client_import_del_conn, + .o_connect = client_connect_import, + .o_disconnect = client_disconnect_export, + .o_iocontrol = mdc_iocontrol, + .o_set_info = mdc_set_info, + .o_statfs = mdc_statfs, + .o_pin = mdc_pin, + .o_unpin = mdc_unpin, + .o_import_event = mdc_import_event, + .o_llog_init = mdc_llog_init, + .o_llog_finish = mdc_llog_finish, +}; + +struct md_ops mdc_md_ops = { + .m_getstatus = mdc_getstatus, + .m_change_cbdata = mdc_change_cbdata, + .m_close = mdc_close, + .m_create = mdc_create, + .m_done_writing = mdc_done_writing, + .m_enqueue = mdc_enqueue, + .m_getattr = mdc_getattr, + .m_getattr_name = mdc_getattr_name, + .m_intent_lock = mdc_intent_lock, + .m_link = mdc_link, + .m_rename = mdc_rename, + .m_setattr = mdc_setattr, + .m_sync = mdc_sync, + .m_readpage = mdc_readpage, + .m_unlink = mdc_unlink, + .m_init_ea_size = mdc_init_ea_size, + .m_set_lock_data = mdc_set_lock_data, + .m_get_lustre_md = mdc_get_lustre_md, + .m_free_lustre_md = mdc_free_lustre_md, + .m_set_open_replay_data = mdc_set_open_replay_data, + .m_clear_open_replay_data = mdc_clear_open_replay_data }; static quota_interface_t *quota_interface; @@ -1255,7 +1264,7 @@ int __init mdc_init(void) quota_interface = PORTAL_SYMBOL_GET(mdc_quota_interface); init_obd_quota_ops(quota_interface, &mdc_obd_ops); - rc = class_register_type(&mdc_obd_ops, lvars.module_vars, + rc = class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars, LUSTRE_MDC_NAME, NULL); if (rc && quota_interface) PORTAL_SYMBOL_PUT(mdc_quota_interface); @@ -1276,26 +1285,6 @@ MODULE_AUTHOR("Cluster File Systems, Inc. "); MODULE_DESCRIPTION("Lustre Metadata Client"); MODULE_LICENSE("GPL"); -EXPORT_SYMBOL(mdc_req2lustre_md); -EXPORT_SYMBOL(mdc_free_lustre_md); -EXPORT_SYMBOL(mdc_change_cbdata); -EXPORT_SYMBOL(mdc_getstatus); -EXPORT_SYMBOL(mdc_getattr); -EXPORT_SYMBOL(mdc_getattr_name); -EXPORT_SYMBOL(mdc_create); -EXPORT_SYMBOL(mdc_unlink); -EXPORT_SYMBOL(mdc_rename); -EXPORT_SYMBOL(mdc_link); -EXPORT_SYMBOL(mdc_readpage); -EXPORT_SYMBOL(mdc_setattr); -EXPORT_SYMBOL(mdc_close); -EXPORT_SYMBOL(mdc_done_writing); -EXPORT_SYMBOL(mdc_sync); -EXPORT_SYMBOL(mdc_set_open_replay_data); -EXPORT_SYMBOL(mdc_clear_open_replay_data); -EXPORT_SYMBOL(mdc_init_ea_size); -EXPORT_SYMBOL(mdc_getxattr); -EXPORT_SYMBOL(mdc_setxattr); EXPORT_SYMBOL(mdc_fld); module_init(mdc_init); diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index e521e50..4a2dd6b 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -812,7 +812,7 @@ static int __init mdd_mod_init(void) struct lprocfs_static_vars lvars; lprocfs_init_vars(mdd, &lvars); - return class_register_type(&mdd_obd_device_ops, lvars.module_vars, + return class_register_type(&mdd_obd_device_ops, NULL, lvars.module_vars, LUSTRE_MDD0_NAME, &mdd_device_type); } diff --git a/lustre/mds/handler.c b/lustre/mds/handler.c index 6b2eb81..71502b6 100644 --- a/lustre/mds/handler.c +++ b/lustre/mds/handler.c @@ -2644,10 +2644,10 @@ static int __init mds_init(void) init_obd_quota_ops(quota_interface, &mds_obd_ops); lprocfs_init_vars(mds, &lvars); - class_register_type(&mds_obd_ops, + class_register_type(&mds_obd_ops, NULL, lvars.module_vars, LUSTRE_MDS_NAME, NULL); lprocfs_init_vars(mdt, &lvars); - class_register_type(&mdt_obd_ops, + class_register_type(&mdt_obd_ops, NULL, lvars.module_vars, LUSTRE_MDT_NAME, NULL); return 0; @@ -2695,7 +2695,7 @@ static int __init mds_cmd_init(void) struct lprocfs_static_vars lvars; lprocfs_init_vars(mds, &lvars); - class_register_type(&mds_cmd_obd_ops, lvars.module_vars, + class_register_type(&mds_cmd_obd_ops, NULL, lvars.module_vars, LUSTRE_MDS_NAME, NULL); return 0; diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index f5d5023..ecc7fb0 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1618,8 +1618,9 @@ static int __init mdt_mod_init(void) mdt_num_threads = MDT_NUM_THREADS; lprocfs_init_vars(mdt, &lvars); - return class_register_type(&mdt_obd_device_ops, lvars.module_vars, - LUSTRE_MDT0_NAME, &mdt_device_type); + return class_register_type(&mdt_obd_device_ops, NULL, + lvars.module_vars, LUSTRE_MDT0_NAME, + &mdt_device_type); } static void __exit mdt_mod_exit(void) diff --git a/lustre/mgc/mgc_request.c b/lustre/mgc/mgc_request.c index 2992d84..e88e641 100644 --- a/lustre/mgc/mgc_request.c +++ b/lustre/mgc/mgc_request.c @@ -1100,7 +1100,8 @@ struct obd_ops mgc_obd_ops = { int __init mgc_init(void) { - return class_register_type(&mgc_obd_ops, NULL, LUSTRE_MGC_NAME, NULL); + return class_register_type(&mgc_obd_ops, NULL, NULL, + LUSTRE_MGC_NAME, NULL); } #ifdef __KERNEL__ diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index e5dfea7..10ef4b33 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -689,7 +689,7 @@ static int __init mgs_init(void) struct lprocfs_static_vars lvars; lprocfs_init_vars(mgs, &lvars); - class_register_type(&mgs_obd_ops, + class_register_type(&mgs_obd_ops, NULL, lvars.module_vars, LUSTRE_MGS_NAME, NULL); return 0; diff --git a/lustre/obdclass/Makefile.in b/lustre/obdclass/Makefile.in index aef52de..9e5aeb6 100644 --- a/lustre/obdclass/Makefile.in +++ b/lustre/obdclass/Makefile.in @@ -4,7 +4,7 @@ obdclass-objs := llog.o llog_cat.o llog_lvfs.o llog_obd.o llog_swab.o obdclass-objs += class_obd.o lu_object.o obdclass-objs += debug.o genops.o sysctl.o uuid.o llog_ioctl.o obdclass-objs += lprocfs_status.o lustre_handles.o lustre_peer.o -obdclass-objs += statfs_pack.o obdo.o obd_config.o obd_mount.o prng.o +obdclass-objs += statfs_pack.o obdo.o obd_config.o obd_mount.o mea.o prng.o ifeq ($(PATCHLEVEL),6) diff --git a/lustre/obdclass/autoMakefile.am b/lustre/obdclass/autoMakefile.am index 163596e..0951147 100644 --- a/lustre/obdclass/autoMakefile.am +++ b/lustre/obdclass/autoMakefile.am @@ -1,7 +1,7 @@ if LIBLUSTRE noinst_LIBRARIES = liblustreclass.a -liblustreclass_a_SOURCES = class_obd.c debug.c genops.c statfs_pack.c uuid.c +liblustreclass_a_SOURCES = class_obd.c debug.c genops.c statfs_pack.c mea.c uuid.c liblustreclass_a_SOURCES += lustre_handles.c lustre_peer.c lprocfs_status.c liblustreclass_a_SOURCES += obdo.c obd_config.c llog.c llog_obd.c llog_cat.c liblustreclass_a_SOURCES += llog_lvfs.c llog_swab.c diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 943f436..1f9b1e1 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -430,6 +430,10 @@ EXPORT_SYMBOL(class_cleanup); EXPORT_SYMBOL(class_detach); EXPORT_SYMBOL(class_manual_cleanup); +/* mea.c */ +EXPORT_SYMBOL(mea_name2idx); +EXPORT_SYMBOL(raw_name2idx); + #ifdef LPROCFS int obd_proc_read_version(char *page, char **start, off_t off, int count, int *eof, void *data) diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 35ed2b7..f8d6b51 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -86,24 +86,27 @@ struct obd_type *class_get_type(const char *name) } #endif if (type) - try_module_get(type->typ_ops->o_owner); + try_module_get(type->typ_dt_ops->o_owner); return type; } void class_put_type(struct obd_type *type) { LASSERT(type); - module_put(type->typ_ops->o_owner); + module_put(type->typ_dt_ops->o_owner); } -int class_register_type(struct obd_ops *ops, struct lprocfs_vars *vars, - const char *name, struct lu_device_type *ldt) +#define CLASS_MAX_NAME 1024 + +int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, + struct lprocfs_vars *vars, const char *name, + struct lu_device_type *ldt) { struct obd_type *type; int rc = 0; ENTRY; - LASSERT(strnlen(name, 1024) < 1024); /* sanity check */ + LASSERT(strnlen(name, CLASS_MAX_NAME) < CLASS_MAX_NAME); /* sanity check */ if (class_search_type(name)) { CDEBUG(D_IOCTL, "Type %s already registered\n", name); @@ -115,12 +118,17 @@ int class_register_type(struct obd_ops *ops, struct lprocfs_vars *vars, if (type == NULL) RETURN(rc); - OBD_ALLOC(type->typ_ops, sizeof(*type->typ_ops)); + OBD_ALLOC(type->typ_dt_ops, sizeof(*type->typ_dt_ops)); + OBD_ALLOC(type->typ_md_ops, sizeof(*type->typ_md_ops)); OBD_ALLOC(type->typ_name, strlen(name) + 1); - if (type->typ_ops == NULL || type->typ_name == NULL) + + if (type->typ_dt_ops == NULL || + type->typ_md_ops == NULL || + type->typ_name == NULL) GOTO (failed, rc); - *(type->typ_ops) = *ops; + *(type->typ_dt_ops) = *dt_ops; + *(type->typ_md_ops) = *md_ops; strcpy(type->typ_name, name); #ifdef LPROCFS @@ -148,8 +156,10 @@ int class_register_type(struct obd_ops *ops, struct lprocfs_vars *vars, failed: if (type->typ_name != NULL) OBD_FREE(type->typ_name, strlen(name) + 1); - if (type->typ_ops != NULL) - OBD_FREE (type->typ_ops, sizeof (*type->typ_ops)); + if (type->typ_md_ops != NULL) + OBD_FREE (type->typ_md_ops, sizeof (*type->typ_md_ops)); + if (type->typ_dt_ops != NULL) + OBD_FREE (type->typ_dt_ops, sizeof (*type->typ_dt_ops)); OBD_FREE(type, sizeof(*type)); RETURN(rc); } @@ -168,7 +178,8 @@ int class_unregister_type(const char *name) CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt); /* This is a bad situation, let's make the best of it */ /* Remove ops, but leave the name for debugging */ - OBD_FREE(type->typ_ops, sizeof(*type->typ_ops)); + OBD_FREE(type->typ_dt_ops, sizeof(*type->typ_dt_ops)); + OBD_FREE(type->typ_md_ops, sizeof(*type->typ_md_ops)); RETURN(-EBUSY); } @@ -184,8 +195,10 @@ int class_unregister_type(const char *name) list_del(&type->typ_chain); spin_unlock(&obd_types_lock); OBD_FREE(type->typ_name, strlen(name) + 1); - if (type->typ_ops != NULL) - OBD_FREE(type->typ_ops, sizeof(*type->typ_ops)); + if (type->typ_dt_ops != NULL) + OBD_FREE(type->typ_dt_ops, sizeof(*type->typ_dt_ops)); + if (type->typ_md_ops != NULL) + OBD_FREE(type->typ_md_ops, sizeof(*type->typ_md_ops)); OBD_FREE(type, sizeof(*type)); RETURN(0); } /* class_unregister_type */ diff --git a/lustre/obdclass/llog_obd.c b/lustre/obdclass/llog_obd.c index 4435eba..23d84b4 100644 --- a/lustre/obdclass/llog_obd.c +++ b/lustre/obdclass/llog_obd.c @@ -352,7 +352,7 @@ int obd_llog_init(struct obd_device *obd, struct obd_device *disk_obd, { int rc; ENTRY; - OBD_CHECK_OP(obd, llog_init, 0); + OBD_CHECK_DT_OP(obd, llog_init, 0); OBD_COUNTER_INCREMENT(obd, llog_init); rc = OBP(obd, llog_init)(obd, disk_obd, count, logid); @@ -364,7 +364,7 @@ int obd_llog_finish(struct obd_device *obd, int count) { int rc; ENTRY; - OBD_CHECK_OP(obd, llog_finish, 0); + OBD_CHECK_DT_OP(obd, llog_finish, 0); OBD_COUNTER_INCREMENT(obd, llog_finish); rc = OBP(obd, llog_finish)(obd, count); diff --git a/lustre/obdclass/llog_test.c b/lustre/obdclass/llog_test.c index 471db4d..7f25981 100644 --- a/lustre/obdclass/llog_test.c +++ b/lustre/obdclass/llog_test.c @@ -686,7 +686,7 @@ static int __init llog_test_init(void) struct lprocfs_static_vars lvars; lprocfs_init_vars(llog_test, &lvars); - return class_register_type(&llog_obd_ops, + return class_register_type(&llog_obd_ops, NULL, lvars.module_vars,"llog_test", NULL); } diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index b4df232..3e62e1908 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -755,6 +755,83 @@ void lprocfs_free_obd_stats(struct obd_device *obd) } } +#define LPROCFS_MD_OP_INIT(base, stats, op) \ +do { \ + unsigned int coffset = base + MD_COUNTER_OFFSET(op); \ + LASSERT(coffset < stats->ls_num); \ + lprocfs_counter_init(stats, coffset, 0, #op, "reqs"); \ +} while (0) + +int lprocfs_alloc_md_stats(struct obd_device *obd, + unsigned num_private_stats) +{ + struct lprocfs_stats *stats; + unsigned int num_stats; + int rc, i; + + LASSERT(obd->md_stats == NULL); + LASSERT(obd->obd_proc_entry != NULL); + LASSERT(obd->md_cntr_base == 0); + + num_stats = 1 + MD_COUNTER_OFFSET(delete) + + num_private_stats; + stats = lprocfs_alloc_stats(num_stats); + if (stats == NULL) + return -ENOMEM; + + LPROCFS_MD_OP_INIT(num_private_stats, stats, getstatus); + LPROCFS_MD_OP_INIT(num_private_stats, stats, change_cbdata); + LPROCFS_MD_OP_INIT(num_private_stats, stats, close); + LPROCFS_MD_OP_INIT(num_private_stats, stats, create); + LPROCFS_MD_OP_INIT(num_private_stats, stats, done_writing); + LPROCFS_MD_OP_INIT(num_private_stats, stats, enqueue); + LPROCFS_MD_OP_INIT(num_private_stats, stats, getattr); + LPROCFS_MD_OP_INIT(num_private_stats, stats, getattr_name); + LPROCFS_MD_OP_INIT(num_private_stats, stats, intent_lock); + LPROCFS_MD_OP_INIT(num_private_stats, stats, link); + LPROCFS_MD_OP_INIT(num_private_stats, stats, rename); + LPROCFS_MD_OP_INIT(num_private_stats, stats, setattr); + LPROCFS_MD_OP_INIT(num_private_stats, stats, sync); + LPROCFS_MD_OP_INIT(num_private_stats, stats, readpage); + LPROCFS_MD_OP_INIT(num_private_stats, stats, unlink); + LPROCFS_MD_OP_INIT(num_private_stats, stats, getxattr); + LPROCFS_MD_OP_INIT(num_private_stats, stats, setxattr); + LPROCFS_MD_OP_INIT(num_private_stats, stats, get_lustre_md); + LPROCFS_MD_OP_INIT(num_private_stats, stats, free_lustre_md); + LPROCFS_MD_OP_INIT(num_private_stats, stats, init_ea_size); + LPROCFS_MD_OP_INIT(num_private_stats, stats, set_open_replay_data); + LPROCFS_MD_OP_INIT(num_private_stats, stats, clear_open_replay_data); + LPROCFS_MD_OP_INIT(num_private_stats, stats, set_lock_data); + LPROCFS_MD_OP_INIT(num_private_stats, stats, delete); + + for (i = num_private_stats; i < num_stats; i++) { + if (stats->ls_percpu[0]->lp_cntr[i].lc_name == NULL) { + CERROR("Missing md_stat initializer md_op " + "operation at offset %d. Aborting.\n", + i - num_private_stats); + LBUG(); + } + } + rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats); + if (rc < 0) { + lprocfs_free_stats(stats); + } else { + obd->md_stats = stats; + obd->md_cntr_base = num_private_stats; + } + return rc; +} + +void lprocfs_free_md_stats(struct obd_device *obd) +{ + struct lprocfs_stats *stats = obd->md_stats; + + if (stats != NULL) { + obd->md_stats = NULL; + lprocfs_free_stats(stats); + } +} + int lprocfs_write_helper(const char *buffer, unsigned long count, int *val) { diff --git a/lustre/obdclass/mea.c b/lustre/obdclass/mea.c new file mode 100644 index 0000000..1042f09 --- /dev/null +++ b/lustre/obdclass/mea.c @@ -0,0 +1,91 @@ +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- + * vim:expandtab:shiftwidth=8:tabstop=8: + * + * Copyright (C) 2002, 2003 Cluster File Systems, Inc. + * + * This file is part of Lustre, http://www.lustre.org. + * + * Lustre is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * Lustre is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Lustre; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define DEBUG_SUBSYSTEM S_CLASS +#ifdef __KERNEL__ +#include /* for request_module() */ +#include +#include +#include +#include +#include +#else +#include +#include +#include +#endif +#include + +static int mea_last_char_hash(int count, char *name, int namelen) +{ + unsigned int c; + + c = name[namelen - 1]; + if (c == 0) + CWARN("looks like wrong len is passed\n"); + c = c % count; + return c; +} + +static int mea_all_chars_hash(int count, char *name, int namelen) +{ + unsigned int c = 0; + + while (--namelen >= 0) + c += name[namelen]; + c = c % count; + return c; +} + +int raw_name2idx(int hashtype, int count, const char *name, int namelen) +{ + unsigned int c = 0; + + LASSERT(namelen > 0); + if (count <= 1) + return 0; + + switch (hashtype) { + case MEA_MAGIC_LAST_CHAR: + c = mea_last_char_hash(count, (char *) name, namelen); + break; + case MEA_MAGIC_ALL_CHARS: + c = mea_all_chars_hash(count, (char *) name, namelen); + break; + default: + CERROR("unknown hash type 0x%x\n", hashtype); + } + + return c; +} + +int mea_name2idx(struct lmv_stripe_md *mea, char *name, int namelen) +{ + unsigned int c; + + LASSERT(mea && mea->mea_count); + + c = raw_name2idx(mea->mea_magic, mea->mea_count, name, namelen); + + LASSERT(c < mea->mea_count); + return c; +} + diff --git a/lustre/obdecho/echo.c b/lustre/obdecho/echo.c index 9b61175..beceb66 100644 --- a/lustre/obdecho/echo.c +++ b/lustre/obdecho/echo.c @@ -597,7 +597,7 @@ static int __init obdecho_init(void) if (rc != 0) goto failed_0; - rc = class_register_type(&echo_obd_ops, lvars.module_vars, + rc = class_register_type(&echo_obd_ops, NULL, lvars.module_vars, OBD_ECHO_DEVICENAME, NULL); if (rc != 0) goto failed_1; diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index aba93fe..3927d9d 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -1471,7 +1471,7 @@ int echo_client_init(void) struct lprocfs_static_vars lvars; lprocfs_init_vars(echo, &lvars); - return class_register_type(&echo_obd_ops, lvars.module_vars, + return class_register_type(&echo_obd_ops, NULL, lvars.module_vars, OBD_ECHO_CLIENT_DEVICENAME, NULL); } diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index 95f69e7..e27227b 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -3154,12 +3154,12 @@ static int __init obdfilter_init(void) init_obd_quota_ops(quota_interface, &filter_obd_ops); init_obd_quota_ops(quota_interface, &filter_sanobd_ops); - rc = class_register_type(&filter_obd_ops, lvars.module_vars, + rc = class_register_type(&filter_obd_ops, NULL, lvars.module_vars, LUSTRE_OST_NAME, NULL); if (rc) GOTO(out, rc); - rc = class_register_type(&filter_sanobd_ops, lvars.module_vars, + rc = class_register_type(&filter_sanobd_ops, NULL, lvars.module_vars, LUSTRE_OSTSAN_NAME, NULL); if (rc) { class_unregister_type(LUSTRE_OST_NAME); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 9340119..d30dfb6 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -3484,7 +3484,7 @@ int __init osc_init(void) lquota_init(quota_interface); init_obd_quota_ops(quota_interface, &osc_obd_ops); - rc = class_register_type(&osc_obd_ops, lvars.module_vars, + rc = class_register_type(&osc_obd_ops, NULL, lvars.module_vars, LUSTRE_OSC_NAME, NULL); if (rc) { if (quota_interface) @@ -3493,7 +3493,7 @@ int __init osc_init(void) } #if defined(__KERNEL__) && (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - rc = class_register_type(&sanosc_obd_ops, sanlvars.module_vars, + rc = class_register_type(&sanosc_obd_ops, NULL, sanlvars.module_vars, LUSTRE_SANOSC_NAME, NULL); if (rc) { class_unregister_type(LUSTRE_OSC_NAME); diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index 39cf790..803c473 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -564,7 +564,7 @@ static int __init osd_mod_init(void) struct lprocfs_static_vars lvars; lprocfs_init_vars(osd, &lvars); - return class_register_type(&osd_obd_device_ops, lvars.module_vars, + return class_register_type(&osd_obd_device_ops, NULL, lvars.module_vars, LUSTRE_OSD0_NAME, &osd_device_type); } diff --git a/lustre/ost/ost_handler.c b/lustre/ost/ost_handler.c index fada922..05de28d 100644 --- a/lustre/ost/ost_handler.c +++ b/lustre/ost/ost_handler.c @@ -1768,7 +1768,7 @@ static int __init ost_init(void) ENTRY; lprocfs_init_vars(ost, &lvars); - rc = class_register_type(&ost_obd_ops, lvars.module_vars, + rc = class_register_type(&ost_obd_ops, NULL, lvars.module_vars, LUSTRE_OSS_NAME, NULL); RETURN(rc); } diff --git a/lustre/quota/quotacheck_test.c b/lustre/quota/quotacheck_test.c index ba3778c..6d49bcd 100644 --- a/lustre/quota/quotacheck_test.c +++ b/lustre/quota/quotacheck_test.c @@ -199,7 +199,7 @@ static int __init quotacheck_test_init(void) struct lprocfs_static_vars lvars; lprocfs_init_vars(quotacheck_test, &lvars); - return class_register_type("acheck_obd_ops, lvars.module_vars, + return class_register_type("acheck_obd_ops, NULL, lvars.module_vars, "quotacheck_test", NULL); } diff --git a/lustre/quota/quotactl_test.c b/lustre/quota/quotactl_test.c index f352ea3..11c86b4 100644 --- a/lustre/quota/quotactl_test.c +++ b/lustre/quota/quotactl_test.c @@ -340,7 +340,7 @@ static int __init quotactl_test_init(void) struct lprocfs_static_vars lvars; lprocfs_init_vars(quotactl_test, &lvars); - return class_register_type("actl_obd_ops, lvars.module_vars, + return class_register_type("actl_obd_ops, NULL, lvars.module_vars, "quotactl_test", NULL); } -- 1.8.3.1