X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Finclude%2Flinux%2Fobd_class.h;h=0a75ed79af1263eaeb10fd800054a490d014cd94;hp=e631078fd8e84df52f672f47f0ea808f074609a8;hb=6cdee33c927b30502925e9b007739f2317b72871;hpb=5fd7183a77a063f3c00285e79b57f37b77ef77ea diff --git a/lustre/include/linux/obd_class.h b/lustre/include/linux/obd_class.h index e631078..0a75ed7 100644 --- a/lustre/include/linux/obd_class.h +++ b/lustre/include/linux/obd_class.h @@ -28,7 +28,7 @@ # define __KERNEL__ # include # undef __KERNEL__ -#else +#else #include #include #include @@ -40,6 +40,7 @@ #include #include #include +#include #endif @@ -63,39 +64,7 @@ extern void proc_lustre_remove_obd_entry(const char* name, */ #ifdef __KERNEL__ -extern struct obd_export *class_conn2export(struct lustre_handle *conn); -extern struct obd_device *class_conn2obd(struct lustre_handle *conn); -extern int class_rconn2export(struct lustre_handle *conn, - struct lustre_handle *rconn); - -struct obd_export { - __u64 exp_cookie; - struct lustre_handle exp_rconnh; /* remote connection handle */ - struct lustre_handle exp_impconnh; - struct list_head exp_chain; - struct obd_device *exp_obd; - struct ptlrpc_connection *exp_connection; - struct mds_export_data exp_mds_data; -#if NOTYET && 0 - struct ldlm_export_data exp_ldlm_data; - struct ost_export_data exp_ost_data; -#endif - void *exp_data; /* device specific data */ - int exp_desclen; - char *exp_desc; - uuid_t exp_uuid; -}; - -struct obd_import { - __u64 imp_cookie; - struct lustre_handle imp_expconnh; - struct list_head imp_chain; - struct obd_device *imp_obd; - unsigned int imp_id; - void *imp_data; /* device specific data */ -}; - -static inline int obd_check_conn(struct lustre_handle *conn) +static inline int obd_check_conn(struct lustre_handle *conn) { struct obd_device *obd; if (!conn) { @@ -114,7 +83,7 @@ static inline int obd_check_conn(struct lustre_handle *conn) } if (!obd->obd_flags & OBD_SET_UP) { - CERROR("obd %d not setup\n", obd->obd_minor); + CERROR("obd %d not setup\n", obd->obd_minor); RETURN(-ENODEV); } @@ -133,24 +102,24 @@ static inline int obd_check_conn(struct lustre_handle *conn) #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_ops->o_ ## op -#define OBD_CHECK_SETUP(conn, export) \ +#define OBD_CHECK_SETUP(conn, exp) \ do { \ if (!(conn)) { \ CERROR("NULL connection\n"); \ RETURN(-EINVAL); \ } \ \ - export = class_conn2export(conn); \ - if (!(export)) { \ + exp = class_conn2export(conn); \ + if (!(exp)) { \ CERROR("No export\n"); \ RETURN(-EINVAL); \ } \ \ - if (!((export)->exp_obd->obd_flags & OBD_SET_UP)) { \ + if (!((exp)->exp_obd->obd_flags & OBD_SET_UP)) { \ CERROR("Device %d not setup\n", \ - (export)->exp_obd->obd_minor); \ + (exp)->exp_obd->obd_minor); \ RETURN(-EINVAL); \ } \ } while (0) @@ -162,16 +131,16 @@ do { \ RETURN(-EINVAL); \ } \ \ - if ( !((obd)->obd_flags & OBD_SET_UP) ) { \ + if (!((obd)->obd_flags & OBD_SET_UP)) { \ CERROR("Device %d not setup\n", \ (obd)->obd_minor); \ RETURN(-EINVAL); \ } \ } while (0) -#define OBD_CHECK_OP(obd,op) \ +#define OBD_CHECK_OP(obd, op) \ do { \ - if (!OBP((obd),op)) { \ + if (!OBP((obd), op)) { \ CERROR("obd_" #op ": dev %d no operation\n", \ obd->obd_minor); \ RETURN(-EOPNOTSUPP); \ @@ -181,24 +150,26 @@ do { \ static inline int obd_get_info(struct lustre_handle *conn, obd_count keylen, void *key, obd_count *vallen, void **val) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,get_info); - rc = OBP(export->exp_obd, get_info)(conn, keylen, key, vallen, val); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, get_info); + + rc = OBP(exp->exp_obd, get_info)(conn, keylen, key, vallen, val); RETURN(rc); } static inline int obd_set_info(struct lustre_handle *conn, obd_count keylen, void *key, obd_count vallen, void *val) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,set_info); - rc = OBP(export->exp_obd, set_info)(conn, keylen, key, vallen, val); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, set_info); + + rc = OBP(exp->exp_obd, set_info)(conn, keylen, key, vallen, val); RETURN(rc); } @@ -206,7 +177,7 @@ static inline int obd_setup(struct obd_device *obd, int datalen, void *data) { int rc; - OBD_CHECK_OP(obd,setup); + OBD_CHECK_OP(obd, setup); rc = OBP(obd, setup)(obd, datalen, data); RETURN(rc); @@ -217,88 +188,97 @@ static inline int obd_cleanup(struct obd_device *obd) int rc; OBD_CHECK_DEVSETUP(obd); - OBD_CHECK_OP(obd,cleanup); + OBD_CHECK_OP(obd, cleanup); rc = OBP(obd, cleanup)(obd); RETURN(rc); } -static inline int obd_create(struct lustre_handle *conn, struct obdo *obdo, struct lov_stripe_md **ea) +static inline int obd_create(struct lustre_handle *conn, struct obdo *obdo, + struct lov_stripe_md **ea) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,create); - rc = OBP(export->exp_obd, create)(conn, obdo, ea); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, create); + + rc = OBP(exp->exp_obd, create)(conn, obdo, ea); RETURN(rc); } -static inline int obd_destroy(struct lustre_handle *conn, struct obdo *obdo, struct lov_stripe_md *ea) +static inline int obd_destroy(struct lustre_handle *conn, struct obdo *obdo, + struct lov_stripe_md *ea) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,destroy); - rc = OBP(export->exp_obd, destroy)(conn, obdo, ea); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, destroy); + + rc = OBP(exp->exp_obd, destroy)(conn, obdo, ea); RETURN(rc); } -static inline int obd_getattr(struct lustre_handle *conn, - struct obdo *obdo, +static inline int obd_getattr(struct lustre_handle *conn, struct obdo *obdo, struct lov_stripe_md *ea) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,getattr); - rc = OBP(export->exp_obd, getattr)(conn, obdo, ea); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, getattr); + + rc = OBP(exp->exp_obd, getattr)(conn, obdo, ea); RETURN(rc); } -static inline int obd_close(struct lustre_handle *conn, struct obdo *obdo, struct lov_stripe_md *md) +static inline int obd_close(struct lustre_handle *conn, struct obdo *obdo, + struct lov_stripe_md *ea) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,close); - rc = OBP(export->exp_obd, close)(conn, obdo, md); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, close); + + rc = OBP(exp->exp_obd, close)(conn, obdo, ea); RETURN(rc); } -static inline int obd_open(struct lustre_handle *conn, struct obdo *obdo, - struct lov_stripe_md *md) + +static inline int obd_open(struct lustre_handle *conn, struct obdo *obdo, + struct lov_stripe_md *ea) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,open); - rc = OBP(export->exp_obd, open) (conn, obdo, md); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, open); + + rc = OBP(exp->exp_obd, open)(conn, obdo, ea); RETURN(rc); } -static inline int obd_setattr(struct lustre_handle *conn, - struct obdo *obdo, +static inline int obd_setattr(struct lustre_handle *conn, struct obdo *obdo, struct lov_stripe_md *ea) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,setattr); - rc = OBP(export->exp_obd, setattr)(conn, obdo, ea); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, setattr); + + rc = OBP(exp->exp_obd, setattr)(conn, obdo, ea); RETURN(rc); } -static inline int obd_connect(struct lustre_handle *conn, struct obd_device *obd, - char *cluuid) +static inline int obd_connect(struct lustre_handle *conn, + struct obd_device *obd, obd_uuid_t cluuid) { int rc; + OBD_CHECK_DEVSETUP(obd); - OBD_CHECK_OP(obd,connect); + OBD_CHECK_OP(obd, connect); rc = OBP(obd, connect)(conn, obd, cluuid); RETURN(rc); @@ -306,56 +286,59 @@ static inline int obd_connect(struct lustre_handle *conn, struct obd_device *obd static inline int obd_disconnect(struct lustre_handle *conn) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,disconnect); - rc = OBP(export->exp_obd, disconnect)(conn); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, disconnect); + + rc = OBP(exp->exp_obd, disconnect)(conn); RETURN(rc); } -static inline int obd_statfs(struct lustre_handle *conn, struct statfs *buf) +static inline int obd_statfs(struct lustre_handle *conn,struct obd_statfs *osfs) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,statfs); - rc = OBP(export->exp_obd, statfs)(conn, buf); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, statfs); + + rc = OBP(exp->exp_obd, statfs)(conn, osfs); RETURN(rc); } -static inline int obd_punch(struct lustre_handle *conn, struct obdo *tgt, - struct lov_stripe_md *md, +static inline int obd_punch(struct lustre_handle *conn, struct obdo *oa, + struct lov_stripe_md *ea, obd_size count, obd_off offset) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,punch); - rc = OBP(export->exp_obd, punch)(conn, tgt, md, count, offset); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, punch); + + rc = OBP(exp->exp_obd, punch)(conn, oa, ea, count, offset); RETURN(rc); } -static inline int obd_brw(int cmd, struct lustre_handle *conn, - struct lov_stripe_md *md, - obd_count oa_bufs, - struct brw_page *pg, +static inline int obd_brw(int cmd, struct lustre_handle *conn, + struct lov_stripe_md *ea, obd_count oa_bufs, + struct brw_page *pg, brw_callback_t callback, void *data) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,brw); + + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, brw); if (!(cmd & OBD_BRW_RWMASK)) { CERROR("obd_brw: cmd must be OBD_BRW_READ or OBD_BRW_WRITE\n"); LBUG(); } - rc = OBP(export->exp_obd, brw)(cmd, conn, md, oa_bufs, pg, callback, data); + rc = OBP(exp->exp_obd, brw)(cmd, conn, ea, oa_bufs, pg, callback, data); RETURN(rc); } @@ -364,12 +347,13 @@ static inline int obd_preprw(int cmd, struct lustre_handle *conn, int niocount, struct niobuf_remote *remote, struct niobuf_local *local, void **desc_private) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,preprw); - rc = OBP(export->exp_obd, preprw)(cmd, conn, objcount, obj, niocount, + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, preprw); + + rc = OBP(exp->exp_obd, preprw)(cmd, conn, objcount, obj, niocount, remote, local, desc_private); RETURN(rc); } @@ -379,12 +363,13 @@ static inline int obd_commitrw(int cmd, struct lustre_handle *conn, int niocount, struct niobuf_local *local, void *desc_private) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,commitrw); - rc = OBP(export->exp_obd, commitrw)(cmd, conn, objcount, obj, niocount, + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, commitrw); + + rc = OBP(exp->exp_obd, commitrw)(cmd, conn, objcount, obj, niocount, local, desc_private); RETURN(rc); } @@ -392,46 +377,63 @@ static inline int obd_commitrw(int cmd, struct lustre_handle *conn, static inline int obd_iocontrol(int cmd, struct lustre_handle *conn, int len, void *karg, void *uarg) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,iocontrol); - rc = OBP(export->exp_obd, iocontrol)(cmd, conn, len, karg, uarg); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, iocontrol); + + rc = OBP(exp->exp_obd, iocontrol)(cmd, conn, len, karg, uarg); RETURN(rc); } static inline int obd_enqueue(struct lustre_handle *conn, - struct lov_stripe_md *md, - struct lustre_handle *parent_lock, + struct lov_stripe_md *ea, + struct lustre_handle *parent_lock, __u32 type, void *cookie, int cookielen, __u32 mode, int *flags, void *cb, void *data, int datalen, struct lustre_handle *lockh) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,enqueue); - rc = OBP(export->exp_obd, enqueue)(conn, md, parent_lock, type, + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, enqueue); + + rc = OBP(exp->exp_obd, enqueue)(conn, ea, parent_lock, type, cookie, cookielen, mode, flags, cb, data, datalen, lockh); RETURN(rc); } -static inline int obd_cancel(struct lustre_handle *conn, struct lov_stripe_md *md, __u32 mode, +static inline int obd_cancel(struct lustre_handle *conn, + struct lov_stripe_md *ea, __u32 mode, struct lustre_handle *lockh) { + struct obd_export *exp; int rc; - struct obd_export *export; - OBD_CHECK_SETUP(conn, export); - OBD_CHECK_OP(export->exp_obd,cancel); - rc = OBP(export->exp_obd, cancel)(conn, md, mode, lockh); + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, cancel); + + rc = OBP(exp->exp_obd, cancel)(conn, ea, mode, lockh); RETURN(rc); } -#endif +static inline int obd_cancel_unused(struct lustre_handle *conn, + struct lov_stripe_md *ea, int local) +{ + struct obd_export *exp; + int rc; + + OBD_CHECK_SETUP(conn, exp); + OBD_CHECK_OP(exp->exp_obd, cancel_unused); + + rc = OBP(exp->exp_obd, cancel_unused)(conn, ea, local); + RETURN(rc); +} + +#endif /* * ======== OBD Metadata Support =========== @@ -490,12 +492,11 @@ static inline void obdo_from_iattr(struct obdo *oa, struct iattr *attr) } if (ia_valid & ATTR_MODE) { oa->o_mode = attr->ia_mode; - oa->o_valid |= OBD_MD_FLMODE; + oa->o_valid |= OBD_MD_FLTYPE | OBD_MD_FLMODE; if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID)) oa->o_mode &= ~S_ISGID; } - if (ia_valid & ATTR_UID) - { + if (ia_valid & ATTR_UID) { oa->o_uid = attr->ia_uid; oa->o_valid |= OBD_MD_FLUID; } @@ -506,39 +507,42 @@ static inline void obdo_from_iattr(struct obdo *oa, struct iattr *attr) } -static inline void iattr_from_obdo(struct iattr *attr, struct obdo *oa) +static inline void iattr_from_obdo(struct iattr *attr, struct obdo *oa, + obd_flag valid) { - unsigned int ia_valid = oa->o_valid; - memset(attr, 0, sizeof(*attr)); - if (ia_valid & OBD_MD_FLATIME) { + if (valid & OBD_MD_FLATIME) { attr->ia_atime = oa->o_atime; attr->ia_valid |= ATTR_ATIME; } - if (ia_valid & OBD_MD_FLMTIME) { + if (valid & OBD_MD_FLMTIME) { attr->ia_mtime = oa->o_mtime; attr->ia_valid |= ATTR_MTIME; } - if (ia_valid & OBD_MD_FLCTIME) { + if (valid & OBD_MD_FLCTIME) { attr->ia_ctime = oa->o_ctime; attr->ia_valid |= ATTR_CTIME; } - if (ia_valid & OBD_MD_FLSIZE) { + if (valid & OBD_MD_FLSIZE) { attr->ia_size = oa->o_size; attr->ia_valid |= ATTR_SIZE; } - if (ia_valid & OBD_MD_FLMODE) { - attr->ia_mode = oa->o_mode; + if (valid & OBD_MD_FLTYPE) { + attr->ia_mode = (attr->ia_mode & ~S_IFMT)|(oa->o_mode & S_IFMT); + attr->ia_valid |= ATTR_MODE; + } + if (valid & OBD_MD_FLMODE) { + attr->ia_mode = (attr->ia_mode & S_IFMT)|(oa->o_mode & ~S_IFMT); attr->ia_valid |= ATTR_MODE; if (!in_group_p(oa->o_gid) && !capable(CAP_FSETID)) attr->ia_mode &= ~S_ISGID; } - if (ia_valid & OBD_MD_FLUID) + if (valid & OBD_MD_FLUID) { attr->ia_uid = oa->o_uid; attr->ia_valid |= ATTR_UID; } - if (ia_valid & OBD_MD_FLGID) { + if (valid & OBD_MD_FLGID) { attr->ia_gid = oa->o_gid; attr->ia_valid |= ATTR_GID; } @@ -548,117 +552,126 @@ static inline void iattr_from_obdo(struct iattr *attr, struct obdo *oa) /* WARNING: the file systems must take care not to tinker with attributes they don't manage (such as blocks). */ -static inline void obdo_from_inode(struct obdo *dst, struct inode *src) +static inline void obdo_from_inode(struct obdo *dst, struct inode *src, + obd_flag valid) { - if ( dst->o_valid & OBD_MD_FLID ) - dst->o_id = src->i_ino; - if ( dst->o_valid & OBD_MD_FLATIME ) +// if (valid & OBD_MD_FLID) +// dst->o_id = src->i_ino; + if (valid & OBD_MD_FLATIME) dst->o_atime = src->i_atime; - if ( dst->o_valid & OBD_MD_FLMTIME ) + if (valid & OBD_MD_FLMTIME) dst->o_mtime = src->i_mtime; - if ( dst->o_valid & OBD_MD_FLCTIME ) + if (valid & OBD_MD_FLCTIME) dst->o_ctime = src->i_ctime; - if ( dst->o_valid & OBD_MD_FLSIZE ) + if (valid & OBD_MD_FLSIZE) dst->o_size = src->i_size; - if ( dst->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */ + if (valid & OBD_MD_FLBLOCKS) /* allocation of space */ dst->o_blocks = src->i_blocks; - if ( dst->o_valid & OBD_MD_FLBLKSZ ) + if (valid & OBD_MD_FLBLKSZ) dst->o_blksize = src->i_blksize; - if ( dst->o_valid & OBD_MD_FLMODE ) - dst->o_mode = src->i_mode; - if ( dst->o_valid & OBD_MD_FLUID ) + if (valid & OBD_MD_FLTYPE) + dst->o_mode = (dst->o_mode & ~S_IFMT) | (src->i_mode & S_IFMT); + if (valid & OBD_MD_FLMODE) + dst->o_mode = (dst->o_mode & S_IFMT) | (src->i_mode & ~S_IFMT); + if (valid & OBD_MD_FLUID) dst->o_uid = src->i_uid; - if ( dst->o_valid & OBD_MD_FLGID ) + if (valid & OBD_MD_FLGID) dst->o_gid = src->i_gid; - if ( dst->o_valid & OBD_MD_FLFLAGS ) + if (valid & OBD_MD_FLFLAGS) dst->o_flags = src->i_flags; - if ( dst->o_valid & OBD_MD_FLNLINK ) + if (valid & OBD_MD_FLNLINK) dst->o_nlink = src->i_nlink; - if ( dst->o_valid & OBD_MD_FLGENER ) + if (valid & OBD_MD_FLGENER) dst->o_generation = src->i_generation; - if ( dst->o_valid & OBD_MD_FLRDEV ) + if (valid & OBD_MD_FLRDEV) dst->o_rdev = src->i_rdev; + + dst->o_valid |= (valid & ~OBD_MD_FLID); } -static inline void obdo_to_inode(struct inode *dst, struct obdo *src) +static inline void obdo_to_inode(struct inode *dst, struct obdo *src, + obd_flag valid) { - - if ( src->o_valid & OBD_MD_FLID ) - dst->i_ino = src->o_id; - if ( src->o_valid & OBD_MD_FLATIME ) +// if (valid & OBD_MD_FLID) +// dst->i_ino = src->o_id; + if (valid & OBD_MD_FLATIME) dst->i_atime = src->o_atime; - if ( src->o_valid & OBD_MD_FLMTIME ) + if (valid & OBD_MD_FLMTIME) dst->i_mtime = src->o_mtime; - if ( src->o_valid & OBD_MD_FLCTIME ) + if (valid & OBD_MD_FLCTIME) dst->i_ctime = src->o_ctime; - if ( src->o_valid & OBD_MD_FLSIZE ) + if (valid & OBD_MD_FLSIZE) dst->i_size = src->o_size; - if ( src->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */ + if (valid & OBD_MD_FLBLOCKS) /* allocation of space */ dst->i_blocks = src->o_blocks; - if ( src->o_valid & OBD_MD_FLBLKSZ ) + if (valid & OBD_MD_FLBLKSZ) dst->i_blksize = src->o_blksize; - if ( src->o_valid & OBD_MD_FLMODE ) - dst->i_mode = src->o_mode; - if ( src->o_valid & OBD_MD_FLUID ) + if (valid & OBD_MD_FLTYPE) + dst->i_mode = (dst->i_mode & ~S_IFMT) | (src->o_mode & S_IFMT); + if (valid & OBD_MD_FLMODE) + dst->i_mode = (dst->i_mode & S_IFMT) | (src->o_mode & ~S_IFMT); + if (valid & OBD_MD_FLUID) dst->i_uid = src->o_uid; - if ( src->o_valid & OBD_MD_FLGID ) + if (valid & OBD_MD_FLGID) dst->i_gid = src->o_gid; - if ( src->o_valid & OBD_MD_FLFLAGS ) + if (valid & OBD_MD_FLFLAGS) dst->i_flags = src->o_flags; - if ( src->o_valid & OBD_MD_FLNLINK ) + if (valid & OBD_MD_FLNLINK) dst->i_nlink = src->o_nlink; - if ( src->o_valid & OBD_MD_FLGENER ) + if (valid & OBD_MD_FLGENER) dst->i_generation = src->o_generation; - if ( src->o_valid & OBD_MD_FLRDEV ) + if (valid & OBD_MD_FLRDEV) dst->i_rdev = src->o_rdev; } +#endif -#endif - -static inline void obdo_cpy_md(struct obdo *dst, struct obdo *src) +static inline void obdo_cpy_md(struct obdo *dst, struct obdo *src, + obd_flag valid) { #ifdef __KERNEL__ CDEBUG(D_INODE, "src obdo %Ld valid 0x%x, dst obdo %Ld\n", (unsigned long long)src->o_id, src->o_valid, (unsigned long long)dst->o_id); #endif - if ( src->o_valid & OBD_MD_FLATIME ) + if (valid & OBD_MD_FLATIME) dst->o_atime = src->o_atime; - if ( src->o_valid & OBD_MD_FLMTIME ) + if (valid & OBD_MD_FLMTIME) dst->o_mtime = src->o_mtime; - if ( src->o_valid & OBD_MD_FLCTIME ) + if (valid & OBD_MD_FLCTIME) dst->o_ctime = src->o_ctime; - if ( src->o_valid & OBD_MD_FLSIZE ) + if (valid & OBD_MD_FLSIZE) dst->o_size = src->o_size; - if ( src->o_valid & OBD_MD_FLBLOCKS ) /* allocation of space */ + if (valid & OBD_MD_FLBLOCKS) /* allocation of space */ dst->o_blocks = src->o_blocks; - if ( src->o_valid & OBD_MD_FLBLKSZ ) + if (valid & OBD_MD_FLBLKSZ) dst->o_blksize = src->o_blksize; - if ( src->o_valid & OBD_MD_FLMODE ) - dst->o_mode = src->o_mode; - if ( src->o_valid & OBD_MD_FLUID ) + if (valid & OBD_MD_FLTYPE) + dst->o_mode = (dst->o_mode & ~S_IFMT) | (src->o_mode & S_IFMT); + if (valid & OBD_MD_FLMODE) + dst->o_mode = (dst->o_mode & S_IFMT) | (src->o_mode & ~S_IFMT); + if (valid & OBD_MD_FLUID) dst->o_uid = src->o_uid; - if ( src->o_valid & OBD_MD_FLGID ) + if (valid & OBD_MD_FLGID) dst->o_gid = src->o_gid; - if ( src->o_valid & OBD_MD_FLFLAGS ) + if (valid & OBD_MD_FLFLAGS) dst->o_flags = src->o_flags; /* - if ( src->o_valid & OBD_MD_FLOBDFLG ) + if (valid & OBD_MD_FLOBDFLG) dst->o_obdflags = src->o_obdflags; */ - if ( src->o_valid & OBD_MD_FLNLINK ) + if (valid & OBD_MD_FLNLINK) dst->o_nlink = src->o_nlink; - if ( src->o_valid & OBD_MD_FLGENER ) + if (valid & OBD_MD_FLGENER) dst->o_generation = src->o_generation; - if ( src->o_valid & OBD_MD_FLRDEV ) + if (valid & OBD_MD_FLRDEV) dst->o_rdev = src->o_rdev; - if ( src->o_valid & OBD_MD_FLINLINE && + if (valid & OBD_MD_FLINLINE && src->o_obdflags & OBD_FL_INLINEDATA) { memcpy(dst->o_inline, src->o_inline, sizeof(src->o_inline)); dst->o_obdflags |= OBD_FL_INLINEDATA; } - dst->o_valid |= src->o_valid; + dst->o_valid |= valid; } @@ -680,13 +693,15 @@ static inline int obdo_cmp_md(struct obdo *dst, struct obdo *src, res = (res || (dst->o_blocks != src->o_blocks)); if ( compare & OBD_MD_FLBLKSZ ) res = (res || (dst->o_blksize != src->o_blksize)); + if ( compare & OBD_MD_FLTYPE ) + res = (res || (((dst->o_mode ^ src->o_mode) & S_IFMT) != 0)); if ( compare & OBD_MD_FLMODE ) - res = (res || (dst->o_mode != src->o_mode)); + res = (res || (((dst->o_mode ^ src->o_mode) & ~S_IFMT) != 0)); if ( compare & OBD_MD_FLUID ) res = (res || (dst->o_uid != src->o_uid)); if ( compare & OBD_MD_FLGID ) res = (res || (dst->o_gid != src->o_gid)); - if ( compare & OBD_MD_FLFLAGS ) + if ( compare & OBD_MD_FLFLAGS ) res = (res || (dst->o_flags != src->o_flags)); if ( compare & OBD_MD_FLNLINK ) res = (res || (dst->o_nlink != src->o_nlink)); @@ -704,20 +719,26 @@ static inline int obdo_cmp_md(struct obdo *dst, struct obdo *src, int class_register_type(struct obd_ops *ops, char *nm); int class_unregister_type(char *nm); int class_name2dev(char *name); -int class_uuid2dev(char *name); -struct obd_device *class_uuid2obd(char *name); +int class_uuid2dev(char *uuid); +struct obd_device *class_uuid2obd(char *uuid); struct obd_export *class_new_export(struct obd_device *obddev); +void class_destroy_export(struct obd_export *exp); int class_connect(struct lustre_handle *conn, struct obd_device *obd, - char *cluuid); + obd_uuid_t cluuid); int class_disconnect(struct lustre_handle *conn); void class_disconnect_all(struct obd_device *obddev); -struct obd_export *class_conn2export(struct lustre_handle *); /* generic operations shared by various OBD types */ int class_multi_setup(struct obd_device *obddev, uint32_t len, void *data); int class_multi_cleanup(struct obd_device *obddev); -extern void (*class_signal_client_failure)(struct ptlrpc_client *); +extern void (*class_signal_connection_failure)(struct ptlrpc_connection *); + +static inline struct ptlrpc_connection *class_rd2conn(struct recovd_data *rd) +{ + /* reuse list_entry's member-pointer offset stuff */ + return list_entry(rd, struct ptlrpc_connection, c_recovd_data); +} #endif @@ -725,4 +746,8 @@ extern void (*class_signal_client_failure)(struct ptlrpc_client *); extern void obd_sysctl_init (void); extern void obd_sysctl_clean (void); +/* uuid.c */ +typedef __u8 class_uuid_t[16]; +//int class_uuid_parse(obd_uuid_t in, class_uuid_t out); +void class_uuid_unparse(class_uuid_t in, obd_uuid_t out); #endif /* __LINUX_CLASS_OBD_H */