Whamcloud - gitweb
- store object-existence flags in ->loh_attr
authornikita <nikita>
Wed, 16 Aug 2006 16:59:02 +0000 (16:59 +0000)
committernikita <nikita>
Wed, 16 Aug 2006 16:59:02 +0000 (16:59 +0000)
 - drop context argument from lu_object_exists()

15 files changed:
lustre/cmm/cmm_object.c
lustre/include/dt_object.h
lustre/include/lu_object.h
lustre/include/md_object.h
lustre/kernel_patches/patches/ext3-iam-separate.patch
lustre/kernel_patches/patches/ext3-iam-uapi.patch
lustre/mdd/mdd_handler.c
lustre/mdd/mdd_internal.h
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_lib.c
lustre/mdt/mdt_open.c
lustre/mdt/mdt_reint.c
lustre/mdt/mdt_xattr.c
lustre/osd/osd_handler.c

index a275d6f..635710b 100644 (file)
@@ -124,6 +124,7 @@ struct lu_object *cmm_object_alloc(const struct lu_context *ctx,
                         cro->cmm_obj.cmo_obj.mo_dir_ops = &cmr_dir_ops;
                         lo->lo_ops = &cmr_obj_ops;
                         cro->cmo_num = mdsnum;
+                        lo->lo_header->loh_attr |= LOHA_REMOTE;
                 }
         }
         RETURN(lo);
@@ -190,12 +191,6 @@ static int cml_object_init(const struct lu_context *ctx, struct lu_object *lo)
         RETURN(rc);
 }
 
-static int cml_object_exists(const struct lu_context *ctx,
-                             const struct lu_object *lo)
-{
-        return lu_object_exists(ctx, lu_object_next(lo));
-}
-
 static int cml_object_print(const struct lu_context *ctx, void *cookie,
                             lu_printer_t p, const struct lu_object *lo)
 {
@@ -205,8 +200,7 @@ static int cml_object_print(const struct lu_context *ctx, void *cookie,
 static struct lu_object_operations cml_obj_ops = {
        .loo_object_init    = cml_object_init,
        .loo_object_free    = cml_object_free,
-       .loo_object_print   = cml_object_print,
-       .loo_object_exists  = cml_object_exists
+       .loo_object_print   = cml_object_print
 };
 
 /* CMM local md_object operations */
@@ -408,7 +402,7 @@ static int cml_rename(const struct lu_context *ctx, struct md_object *mo_po,
         int rc;
         ENTRY;
 
-        if (mo_t && lu_object_exists(ctx, &mo_t->mo_lu) < 0) {
+        if (mo_t && lu_object_exists(&mo_t->mo_lu) < 0) {
                 /* mo_t is remote object and there is RPC to unlink it */
                 rc = mo_ref_del(ctx, md_object_next(mo_t), NULL);
                 if (rc)
@@ -526,13 +520,6 @@ static int cmr_object_init(const struct lu_context *ctx, struct lu_object *lo)
         RETURN(rc);
 }
 
-/* -1 is returned for remote object */
-static int cmr_object_exists(const struct lu_context *ctx,
-                             const struct lu_object *lo)
-{
-        return -1;
-}
-
 static int cmr_object_print(const struct lu_context *ctx, void *cookie,
                             lu_printer_t p, const struct lu_object *lo)
 {
@@ -542,8 +529,7 @@ static int cmr_object_print(const struct lu_context *ctx, void *cookie,
 static struct lu_object_operations cmr_obj_ops = {
        .loo_object_init    = cmr_object_init,
        .loo_object_free    = cmr_object_free,
-       .loo_object_print   = cmr_object_print,
-       .loo_object_exists  = cmr_object_exists
+       .loo_object_print   = cmr_object_print
 };
 
 /* CMM remote md_object operations. All are invalid */
index 9f52549..dd06458 100644 (file)
@@ -151,14 +151,14 @@ struct dt_object_operations {
         /*
          * Return standard attributes.
          *
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: lu_object_exists(&dt->do_lu);
          */
         int   (*do_attr_get)(const struct lu_context *ctxt,
                              struct dt_object *dt, struct lu_attr *attr);
         /*
          * Set standard attributes.
          *
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: dt_object_exists(dt);
          */
         int   (*do_attr_set)(const struct lu_context *ctxt,
                              struct dt_object *dt,
@@ -167,7 +167,7 @@ struct dt_object_operations {
         /*
          * Return a value of an extended attribute.
          *
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: dt_object_exists(dt);
          */
         int   (*do_xattr_get)(const struct lu_context *ctxt,
                               struct dt_object *dt,
@@ -177,7 +177,7 @@ struct dt_object_operations {
          *
          * @fl - flags from enum lu_xattr_flags
          *
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: dt_object_exists(dt);
          */
         int   (*do_xattr_set)(const struct lu_context *ctxt,
                               struct dt_object *dt,
@@ -186,7 +186,7 @@ struct dt_object_operations {
         /*
          * Delete existing extended attribute.
          *
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: dt_object_exists(dt);
          */
         int   (*do_xattr_del)(const struct lu_context *ctxt,
                               struct dt_object *dt,
@@ -195,15 +195,15 @@ struct dt_object_operations {
          * Place list of existing extended attributes into @buf (which has
          * length len).
          *
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: dt_object_exists(dt);
          */
         int   (*do_xattr_list)(const struct lu_context *ctxt,
                                struct dt_object *dt, void *buf, int buf_len);
         /*
          * Create new object on this device.
          *
-         * precondition: !lu_object_exists(ctxt, &dt->do_lu);
-         * postcondition: ergo(result == 0, lu_object_exists(ctxt, &dt->do_lu));
+         * precondition: !dt_object_exists(dt);
+         * postcondition: ergo(result == 0, dt_object_exists(dt));
          */
         int   (*do_create)(const struct lu_context *ctxt, struct dt_object *dt,
                            struct lu_attr *attr, struct thandle *th);
@@ -220,13 +220,13 @@ struct dt_object_operations {
                               const struct dt_index_features *feat);
         /*
          * Add nlink of the object
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: dt_object_exists(dt);
          */
         void  (*do_ref_add)(const struct lu_context *ctxt,
                             struct dt_object *dt, struct thandle *th);
         /*
          * Del nlink of the object
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: dt_object_exists(dt);
          */
         void  (*do_ref_del)(const struct lu_context *ctxt,
                             struct dt_object *dt, struct thandle *th);
@@ -240,12 +240,12 @@ struct dt_object_operations {
  */
 struct dt_body_operations {
         /*
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: dt_object_exists(dt);
          */
         ssize_t (*dbo_read)(const struct lu_context *ctxt, struct dt_object *dt,
                             void *buf, size_t count, loff_t *pos);
         /*
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: dt_object_exists(dt);
          */
         ssize_t (*dbo_write)(const struct lu_context *ctxt,
                              struct dt_object *dt, const void *buf,
@@ -272,18 +272,18 @@ struct dt_it;
  */
 struct dt_index_operations {
         /*
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: dt_object_exists(dt);
          */
         int (*dio_lookup)(const struct lu_context *ctxt, struct dt_object *dt,
                           struct dt_rec *rec, const struct dt_key *key);
         /*
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: dt_object_exists(dt);
          */
         int (*dio_insert)(const struct lu_context *ctxt, struct dt_object *dt,
                           const struct dt_rec *rec, const struct dt_key *key,
                           struct thandle *handle);
         /*
-         * precondition: lu_object_exists(ctxt, &dt->do_lu);
+         * precondition: dt_object_exists(dt);
          */
         int (*dio_delete)(const struct lu_context *ctxt, struct dt_object *dt,
                           const struct dt_key *key, struct thandle *handle);
@@ -294,7 +294,7 @@ struct dt_index_operations {
                 /*
                  * Allocate and initialize new iterator.
                  *
-                 * precondition: lu_object_exists(ctxt, &dt->do_lu);
+                 * precondition: dt_object_exists(dt);
                  */
                 struct dt_it *(*init)(const struct lu_context *ctxt,
                                       struct dt_object *dt);
@@ -357,6 +357,11 @@ int  dt_object_init(struct dt_object *obj,
 
 void dt_object_fini(struct dt_object *obj);
 
+static inline int dt_object_exists(const struct dt_object *dt)
+{
+        return lu_object_exists(&dt->do_lu);
+}
+
 struct txn_param {
         unsigned int tp_credits;
 };
index 3c1103b..c05e471 100644 (file)
@@ -195,12 +195,6 @@ struct lu_object_operations {
          */
         void (*loo_object_release)(const struct lu_context *ctx,
                                    struct lu_object *o);
-
-        /*
-         * Return true off object @o exists on a storage.
-         */
-        int (*loo_object_exists)(const struct lu_context *ctx,
-                                 const struct lu_object *o);
         /*
          * Debugging helper. Print given object.
          */
@@ -416,11 +410,13 @@ enum lu_object_header_flags {
 };
 
 enum lu_object_header_attr {
+        LOHA_EXISTS   = 1 << 0,
+        LOHA_REMOTE   = 1 << 1,
         /*
          * UNIX file type is stored in S_IFMT bits.
          */
-        LU_OBJECT_FT_START = (1 << 12), /* S_IFIFO */
-        LU_OBJECT_FT_END   = (1 << 15), /* S_IFREG */
+        LOHA_FT_START = 1 << 12, /* S_IFIFO */
+        LOHA_FT_END   = 1 << 15, /* S_IFREG */
 };
 
 /*
@@ -777,31 +773,35 @@ int lu_object_invariant(const struct lu_object *o);
  * Returns 1 iff object @o exists on the stable storage,
  * returns -1 iff object @o is on remote server.
  */
-static inline int lu_object_exists(const struct lu_context *ctx,
-                                   const struct lu_object *o)
+static inline int lu_object_exists(const struct lu_object *o)
 {
-        return o->lo_ops->loo_object_exists(ctx, o);
+        __u32 attr;
+
+        attr = o->lo_header->loh_attr;
+        if (attr & LOHA_REMOTE)
+                return -1;
+        else if (attr & LOHA_EXISTS)
+                return +1;
+        else
+                return 0;
 }
 
-static inline int lu_object_assert_exists(const struct lu_context *ctx,
-                                          const struct lu_object *o)
+static inline int lu_object_assert_exists(const struct lu_object *o)
 {
-        return lu_object_exists(ctx, o) != 0;
+        return lu_object_exists(o) != 0;
 }
 
-static inline int lu_object_assert_not_exists(const struct lu_context *ctx,
-                                              const struct lu_object *o)
+static inline int lu_object_assert_not_exists(const struct lu_object *o)
 {
-        return lu_object_exists(ctx, o) <= 0;
+        return lu_object_exists(o) <= 0;
 }
 
 /*
  * Attr of this object.
  */
-static inline const __u32 lu_object_attr(const struct lu_context *ctx,
-                                         const struct lu_object *o)
+static inline const __u32 lu_object_attr(const struct lu_object *o)
 {
-        LASSERT(lu_object_exists(ctx, o) > 0);
+        LASSERT(lu_object_exists(o) > 0);
         return o->lo_header->loh_attr;
 }
 
index 1d515c7..367538f 100644 (file)
@@ -55,8 +55,8 @@ enum ma_valid {
 };
 
 struct md_attr {
-        __u64                   ma_valid;  
-        __u64                   ma_need;  
+        __u64                   ma_valid;
+        __u64                   ma_need;
         __u64                   ma_attr_flags;
         struct lu_attr          ma_attr;
         struct lov_mds_md      *ma_lmm;
@@ -145,7 +145,7 @@ struct md_dir_operations {
         int (*mdo_rename)(const struct lu_context *ctxt,
                           struct md_object *spobj, struct md_object *tpobj,
                           const struct lu_fid *lf, const char *sname,
-                          struct md_object *tobj, const char *tname, 
+                          struct md_object *tobj, const char *tname,
                           struct md_attr *);
 
         int (*mdo_link)(const struct lu_context *ctxt, struct md_object *tobj,
index 047edc6..25ee8c9 100644 (file)
@@ -1,7 +1,7 @@
 Index: iam/fs/ext3/Makefile
 ===================================================================
 --- iam.orig/fs/ext3/Makefile  2006-05-31 20:24:32.000000000 +0400
-+++ iam/fs/ext3/Makefile       2006-08-14 23:16:52.000000000 +0400
++++ iam/fs/ext3/Makefile       2006-08-16 20:48:12.000000000 +0400
 @@ -6,7 +6,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o
  
  ext3-y        := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \
@@ -5549,7 +5549,7 @@ Index: iam/fs/ext3/namei.c
 Index: iam/include/linux/lustre_iam.h
 ===================================================================
 --- iam.orig/include/linux/lustre_iam.h        2006-05-31 20:24:32.000000000 +0400
-+++ iam/include/linux/lustre_iam.h     2006-08-14 23:16:52.000000000 +0400
++++ iam/include/linux/lustre_iam.h     2006-08-16 20:48:12.000000000 +0400
 @@ -1,9 +1,68 @@
 +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
 + * vim:expandtab:shiftwidth=8:tabstop=8:
index cfe8e17..def2640 100644 (file)
@@ -1,7 +1,7 @@
 Index: iam/fs/ext3/Makefile
 ===================================================================
---- iam.orig/fs/ext3/Makefile  2006-08-14 23:16:52.000000000 +0400
-+++ iam/fs/ext3/Makefile       2006-08-14 23:16:52.000000000 +0400
+--- iam.orig/fs/ext3/Makefile  2006-08-16 20:48:12.000000000 +0400
++++ iam/fs/ext3/Makefile       2006-08-16 20:48:13.000000000 +0400
 @@ -6,7 +6,7 @@ obj-$(CONFIG_EXT3_FS) += ext3.o
  
  ext3-y        := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o iopen.o \
@@ -13,8 +13,8 @@ Index: iam/fs/ext3/Makefile
  ext3-$(CONFIG_EXT3_FS_POSIX_ACL) += acl.o
 Index: iam/fs/ext3/dir.c
 ===================================================================
---- iam.orig/fs/ext3/dir.c     2006-08-14 23:16:52.000000000 +0400
-+++ iam/fs/ext3/dir.c  2006-08-14 23:16:52.000000000 +0400
+--- iam.orig/fs/ext3/dir.c     2006-08-16 20:48:12.000000000 +0400
++++ iam/fs/ext3/dir.c  2006-08-16 20:48:13.000000000 +0400
 @@ -28,6 +28,7 @@
  #include <linux/smp_lock.h>
  #include <linux/slab.h>
@@ -112,8 +112,8 @@ Index: iam/fs/ext3/dir.c
                    (filp->f_version != inode->i_version)) {
 Index: iam/fs/ext3/file.c
 ===================================================================
---- iam.orig/fs/ext3/file.c    2006-08-14 23:16:52.000000000 +0400
-+++ iam/fs/ext3/file.c 2006-08-14 23:16:52.000000000 +0400
+--- iam.orig/fs/ext3/file.c    2006-08-16 20:48:12.000000000 +0400
++++ iam/fs/ext3/file.c 2006-08-16 20:48:13.000000000 +0400
 @@ -23,6 +23,7 @@
  #include <linux/jbd.h>
  #include <linux/ext3_fs.h>
@@ -149,7 +149,7 @@ Index: iam/fs/ext3/file.c
 Index: iam/fs/ext3/iam-uapi.c
 ===================================================================
 --- iam.orig/fs/ext3/iam-uapi.c        2004-04-06 17:27:52.000000000 +0400
-+++ iam/fs/ext3/iam-uapi.c     2006-08-14 23:16:52.000000000 +0400
++++ iam/fs/ext3/iam-uapi.c     2006-08-16 20:48:13.000000000 +0400
 @@ -0,0 +1,361 @@
 +/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
 + * vim:expandtab:shiftwidth=8:tabstop=8:
@@ -514,8 +514,8 @@ Index: iam/fs/ext3/iam-uapi.c
 +}
 Index: iam/fs/ext3/ioctl.c
 ===================================================================
---- iam.orig/fs/ext3/ioctl.c   2006-08-14 23:16:52.000000000 +0400
-+++ iam/fs/ext3/ioctl.c        2006-08-14 23:16:52.000000000 +0400
+--- iam.orig/fs/ext3/ioctl.c   2006-08-16 20:48:12.000000000 +0400
++++ iam/fs/ext3/ioctl.c        2006-08-16 20:48:13.000000000 +0400
 @@ -250,6 +250,6 @@ flags_err:
  
  
@@ -526,8 +526,8 @@ Index: iam/fs/ext3/ioctl.c
  }
 Index: iam/include/linux/lustre_iam.h
 ===================================================================
---- iam.orig/include/linux/lustre_iam.h        2006-08-14 23:16:52.000000000 +0400
-+++ iam/include/linux/lustre_iam.h     2006-08-14 23:16:53.000000000 +0400
+--- iam.orig/include/linux/lustre_iam.h        2006-08-16 20:48:12.000000000 +0400
++++ iam/include/linux/lustre_iam.h     2006-08-16 20:48:13.000000000 +0400
 @@ -30,9 +30,6 @@
  #ifndef __LINUX_LUSTRE_IAM_H__
  #define __LINUX_LUSTRE_IAM_H__
index 7d0ae71..0f11256 100644 (file)
@@ -120,7 +120,7 @@ static int mdd_get_flags(const struct lu_context *ctxt, struct mdd_object *obj);
 
 static int mdd_object_start(const struct lu_context *ctxt, struct lu_object *o)
 {
-        if (lu_object_exists(ctxt, o))
+        if (lu_object_exists(o))
                 return mdd_get_flags(ctxt, lu2mdd_obj(o));
         else
                 return 0;
@@ -183,7 +183,7 @@ static int mdd_may_create(const struct lu_context *ctxt,
                           struct mdd_object *pobj, struct mdd_object *cobj)
 {
         ENTRY;
-        if (cobj && lu_object_exists(ctxt, &cobj->mod_obj.mo_lu))
+        if (cobj && lu_object_exists(&cobj->mod_obj.mo_lu))
                 RETURN(-EEXIST);
 
         if (mdd_is_dead_obj(pobj))
@@ -197,7 +197,7 @@ static inline int __mdd_la_get(const struct lu_context *ctxt,
                                struct mdd_object *obj, struct lu_attr *la)
 {
         struct dt_object  *next = mdd_object_child(obj);
-        LASSERT(lu_object_exists(ctxt, mdd2lu_obj(obj)));
+        LASSERT(lu_object_exists(mdd2lu_obj(obj)));
         return next->do_ops->do_attr_get(ctxt, next, la);
 
 }
@@ -235,7 +235,7 @@ static int mdd_may_delete(const struct lu_context *ctxt,
 
         LASSERT(cobj && pobj);
 
-        if (!lu_object_exists(ctxt, &cobj->mod_obj.mo_lu))
+        if (!lu_object_exists(&cobj->mod_obj.mo_lu))
                 RETURN(-ENOENT);
 
         if (mdd_is_immutable(cobj) || mdd_is_append(cobj))
@@ -294,10 +294,11 @@ static int mdd_attr_get_internal(const struct lu_context *ctxt,
                 rc = __mdd_iattr_get(ctxt, mdd_obj, ma);
 
         if (rc == 0 && ma->ma_need & MA_LOV) {
-                if (S_ISREG(lu_object_attr(ctxt, mdd2lu_obj(mdd_obj))) ||
-                    S_ISDIR(lu_object_attr(ctxt, mdd2lu_obj(mdd_obj)))) {
+                __u32 mode;
+
+                mode = lu_object_attr(mdd2lu_obj(mdd_obj));
+                if (S_ISREG(mode) || S_ISDIR(mode))
                         rc = __mdd_lmm_get(ctxt, mdd_obj, ma);
-                 }
         }
 
         CDEBUG(D_INODE, "after getattr rc = %d, ma_valid = "LPX64"\n",
@@ -336,7 +337,7 @@ static int mdd_xattr_get(const struct lu_context *ctxt, struct md_object *obj,
 
         ENTRY;
 
-        LASSERT(lu_object_exists(ctxt, &obj->mo_lu));
+        LASSERT(lu_object_exists(&obj->mo_lu));
 
         next = mdd_object_child(mdd_obj);
         rc = next->do_ops->do_xattr_get(ctxt, next, buf, buf_len, name);
@@ -353,7 +354,7 @@ static int mdd_readlink(const struct lu_context *ctxt, struct md_object *obj,
         int                rc;
         ENTRY;
 
-        LASSERT(lu_object_exists(ctxt, &obj->mo_lu));
+        LASSERT(lu_object_exists(&obj->mo_lu));
 
         next = mdd_object_child(mdd_obj);
         rc = next->do_body_ops->dbo_read(ctxt, next, buf, buf_len, &pos);
@@ -368,7 +369,7 @@ static int mdd_xattr_list(const struct lu_context *ctxt, struct md_object *obj,
 
         ENTRY;
 
-        LASSERT(lu_object_exists(ctxt, &obj->mo_lu));
+        LASSERT(lu_object_exists(&obj->mo_lu));
 
         next = mdd_object_child(mdd_obj);
         rc = next->do_ops->do_xattr_list(ctxt, next, buf, buf_len);
@@ -443,12 +444,6 @@ static int mdd_object_print(const struct lu_context *ctxt, void *cookie,
         return (*p)(ctxt, cookie, LUSTRE_MDD0_NAME"-object@%p", o);
 }
 
-static int mdd_object_exists(const struct lu_context *ctx,
-                             const struct lu_object *o)
-{
-        return lu_object_exists(ctx, lu_object_next(o));
-}
-
 static int mdd_mount(const struct lu_context *ctx, struct mdd_device *mdd)
 {
         int rc;
@@ -537,8 +532,7 @@ static struct lu_object_operations mdd_lu_obj_ops = {
        .loo_object_init    = mdd_object_init,
        .loo_object_start   = mdd_object_start,
        .loo_object_free    = mdd_object_free,
-       .loo_object_print   = mdd_object_print,
-       .loo_object_exists  = mdd_object_exists,
+       .loo_object_print   = mdd_object_print
 };
 
 void mdd_lock(const struct lu_context *ctxt, struct mdd_object *obj,
@@ -594,13 +588,13 @@ static int __mdd_object_create(const struct lu_context *ctxt,
         int rc;
         ENTRY;
 
-        if (!lu_object_exists(ctxt, mdd2lu_obj(obj))) {
+        if (!lu_object_exists(mdd2lu_obj(obj))) {
                 next = mdd_object_child(obj);
                 rc = next->do_ops->do_create(ctxt, next, attr, handle);
         } else
                 rc = -EEXIST;
 
-        LASSERT(ergo(rc == 0, lu_object_exists(ctxt, mdd2lu_obj(obj))));
+        LASSERT(ergo(rc == 0, lu_object_exists(mdd2lu_obj(obj))));
 
         RETURN(rc);
 }
@@ -610,7 +604,7 @@ int mdd_attr_set_internal(const struct lu_context *ctxt, struct mdd_object *o,
 {
         struct dt_object *next;
 
-        LASSERT(lu_object_exists(ctxt, mdd2lu_obj(o)));
+        LASSERT(lu_object_exists(mdd2lu_obj(o)));
         next = mdd_object_child(o);
         return next->do_ops->do_attr_set(ctxt, next, attr, handle);
 }
@@ -635,7 +629,7 @@ static int __mdd_xattr_set(const struct lu_context *ctxt, struct mdd_object *o,
         int rc = 0;
         ENTRY;
 
-        LASSERT(lu_object_exists(ctxt, mdd2lu_obj(o)));
+        LASSERT(lu_object_exists(mdd2lu_obj(o)));
         next = mdd_object_child(o);
         if (buf && buf_len > 0) {
                 rc = next->do_ops->do_xattr_set(ctxt, next, buf, buf_len, name,
@@ -889,7 +883,7 @@ static int __mdd_xattr_del(const struct lu_context *ctxt,struct mdd_device *mdd,
 {
         struct dt_object *next;
 
-        LASSERT(lu_object_exists(ctxt, mdd2lu_obj(obj)));
+        LASSERT(lu_object_exists(mdd2lu_obj(obj)));
         next = mdd_object_child(obj);
         return next->do_ops->do_xattr_del(ctxt, next, name, handle);
 }
@@ -1119,7 +1113,7 @@ static int mdd_unlink(const struct lu_context *ctxt, struct md_object *pobj,
                 GOTO(cleanup, rc);
 
         __mdd_ref_del(ctxt, mdd_cobj, handle);
-        if (S_ISDIR(lu_object_attr(ctxt, &cobj->mo_lu))) {
+        if (S_ISDIR(lu_object_attr(&cobj->mo_lu))) {
                 /* unlink dot */
                 __mdd_ref_del(ctxt, mdd_cobj, handle);
                 /* unlink dotdot */
@@ -1309,7 +1303,7 @@ static int mdd_rename(const struct lu_context *ctxt, struct md_object *src_pobj,
         if (rc)
                 GOTO(cleanup, rc);
 
-        if (tobj && lu_object_exists(ctxt, &tobj->mo_lu)) {
+        if (tobj && lu_object_exists(&tobj->mo_lu)) {
                 __mdd_ref_del(ctxt, mdd_tobj, handle);
                 /* remove dot reference */
                 if (S_ISDIR(mdd_object_type(ctxt, mdd_tobj)))
@@ -1734,7 +1728,7 @@ static int mdd_rename_tgt(const struct lu_context *ctxt, struct md_object *pobj,
         if (rc)
                 GOTO(cleanup, rc);
 
-        if (tobj && lu_object_exists(ctxt, &tobj->mo_lu))
+        if (tobj && lu_object_exists(&tobj->mo_lu))
                 __mdd_ref_del(ctxt, mdd_tobj, handle);
 cleanup:
         mdd_unlock2(ctxt, mdd_tpobj, mdd_tobj);
@@ -1783,7 +1777,7 @@ static void __mdd_ref_add(const struct lu_context *ctxt, struct mdd_object *obj,
 {
         struct dt_object *next;
 
-        LASSERT(lu_object_exists(ctxt, mdd2lu_obj(obj)));
+        LASSERT(lu_object_exists(mdd2lu_obj(obj)));
         next = mdd_object_child(obj);
         next->do_ops->do_ref_add(ctxt, next, handle);
 }
@@ -1815,7 +1809,7 @@ __mdd_ref_del(const struct lu_context *ctxt, struct mdd_object *obj,
 {
         struct dt_object *next = mdd_object_child(obj);
 
-        LASSERT(lu_object_exists(ctxt, mdd2lu_obj(obj)));
+        LASSERT(lu_object_exists(mdd2lu_obj(obj)));
 
         next->do_ops->do_ref_del(ctxt, next, handle);
 }
@@ -1826,6 +1820,7 @@ static int mdd_ref_del(const struct lu_context *ctxt, struct md_object *obj,
         struct mdd_object *mdd_obj = md2mdd_obj(obj);
         struct mdd_device *mdd = mdo2mdd(obj);
         struct thandle *handle;
+        int isdir;
         int rc;
         ENTRY;
 
@@ -1836,9 +1831,9 @@ static int mdd_ref_del(const struct lu_context *ctxt, struct md_object *obj,
 
         mdd_lock(ctxt, mdd_obj, DT_WRITE_LOCK);
 
+        isdir = S_ISDIR(lu_object_attr(&obj->mo_lu));
         /* rmdir checks */
-        if (S_ISDIR(lu_object_attr(ctxt, &obj->mo_lu)) &&
-            dt_try_as_dir(ctxt, mdd_object_child(mdd_obj))) {
+        if (isdir && dt_try_as_dir(ctxt, mdd_object_child(mdd_obj))) {
                 rc = mdd_dir_is_empty(ctxt, mdd_obj);
                 if (rc != 0)
                         GOTO(cleanup, rc);
@@ -1846,7 +1841,7 @@ static int mdd_ref_del(const struct lu_context *ctxt, struct md_object *obj,
 
         __mdd_ref_del(ctxt, mdd_obj, handle);
 
-        if (S_ISDIR(lu_object_attr(ctxt, &obj->mo_lu))) {
+        if (isdir) {
                 /* unlink dot */
                 __mdd_ref_del(ctxt, mdd_obj, handle);
         }
@@ -1883,7 +1878,7 @@ static int mdd_readpage(const struct lu_context *ctxt, struct md_object *obj,
         struct mdd_object *mdd_obj = md2mdd_obj(obj);
         int rc;
 
-        LASSERT(lu_object_exists(ctxt, mdd2lu_obj(mdd_obj)));
+        LASSERT(lu_object_exists(mdd2lu_obj(mdd_obj)));
         next = mdd_object_child(mdd_obj);
 
         mdd_lock(ctxt, mdd_obj, DT_READ_LOCK);
index 713b9b5..c98f3c0 100644 (file)
@@ -157,7 +157,7 @@ static inline const struct lu_fid *mdo2fid(const struct mdd_object *obj)
 static inline umode_t mdd_object_type(const struct lu_context *ctxt,
                                       const struct mdd_object *obj)
 {
-        return lu_object_attr(ctxt, &obj->mod_obj.mo_lu);
+        return lu_object_attr(&obj->mod_obj.mo_lu);
 }
 
 static inline int mdd_lov_mdsize(const struct lu_context *ctxt,
index 25c6288..3dddc9d 100644 (file)
@@ -317,10 +317,11 @@ static int mdt_getattr_internal(struct mdt_thread_info *info,
 static int mdt_getattr(struct mdt_thread_info *info)
 {
         int result;
+        struct mdt_object *obj;
 
-        LASSERT(info->mti_object != NULL);
-        LASSERT(lu_object_assert_exists(info->mti_ctxt,
-                                        &info->mti_object->mot_obj.mo_lu));
+        obj = info->mti_object;
+        LASSERT(obj != NULL);
+        LASSERT(lu_object_assert_exists(&obj->mot_obj.mo_lu));
         ENTRY;
 
 
@@ -334,7 +335,7 @@ static int mdt_getattr(struct mdt_thread_info *info)
         if (MDT_FAIL_CHECK(OBD_FAIL_MDS_GETATTR_PACK)) {
                 result = -ENOMEM;
         } else {
-                result = mdt_getattr_internal(info, info->mti_object);
+                result = mdt_getattr_internal(info, obj);
         }
         mdt_shrink_reply(info, 1);
         RETURN(result);
@@ -1030,8 +1031,7 @@ static int mdt_body_unpack(struct mdt_thread_info *info, __u32 flags)
                         obj = mdt_object_find(ctx, info->mti_mdt, &body->fid1);
                         if (!IS_ERR(obj)) {
                                 if ((flags & HABEO_CORPUS) &&
-                                    !lu_object_exists(ctx,
-                                                      &obj->mot_obj.mo_lu)) {
+                                    !lu_object_exists(&obj->mot_obj.mo_lu)) {
                                         mdt_object_put(ctx, obj);
                                         result = -ENOENT;
                                 } else {
@@ -1083,7 +1083,7 @@ int mdt_update_last_transno(struct mdt_thread_info *info, int rc)
                 return -EFAULT;
         if (info->mti_trans_flags & MDT_NONEED_TANSNO)
                 return 0;
-        
+
         last_committed = mdt->mdt_last_committed;
 
         if (rc == 0) {
@@ -2096,7 +2096,7 @@ static void mdt_stack_fini(const struct lu_context *ctx,
         struct lu_device *d = top, *n;
         struct lustre_cfg_bufs bufs;
         struct lustre_cfg     *lcfg;
-        
+
         /* process cleanup */
         lustre_cfg_bufs_reset(&bufs, NULL);
         lcfg = lustre_cfg_new(LCFG_CLEANUP, &bufs);
@@ -2105,7 +2105,7 @@ static void mdt_stack_fini(const struct lu_context *ctx,
                 return;
         }
         top->ld_ops->ldo_process_config(ctx, top, lcfg);
-        
+
         lu_site_purge(ctx, top->ld_site, ~0);
         while (d != NULL) {
                 struct obd_type *type;
@@ -2456,12 +2456,6 @@ static int mdt_object_print(const struct lu_context *ctxt, void *cookie,
         return (*p)(ctxt, cookie, LUSTRE_MDT0_NAME"-object@%p", o);
 }
 
-int mdt_object_exists(const struct lu_context *ctx,
-                      const struct lu_object *o)
-{
-        return lu_object_exists(ctx, lu_object_next(o));
-}
-
 static struct lu_device_operations mdt_lu_ops = {
         .ldo_object_alloc   = mdt_object_alloc,
         .ldo_process_config = mdt_process_config
@@ -2470,8 +2464,7 @@ static struct lu_device_operations mdt_lu_ops = {
 static struct lu_object_operations mdt_obj_ops = {
         .loo_object_init    = mdt_object_init,
         .loo_object_free    = mdt_object_free,
-        .loo_object_print   = mdt_object_print,
-        .loo_object_exists  = mdt_object_exists
+        .loo_object_print   = mdt_object_print
 };
 
 /* mds_connect_internal */
index a7742a3..1887596 100644 (file)
@@ -344,9 +344,6 @@ void mdt_lock_handle_init(struct mdt_lock_handle *lh);
 void mdt_lock_handle_fini(struct mdt_lock_handle *lh);
 
 
-int mdt_object_exists(const struct lu_context *ctx,
-                      const struct lu_object *o);
-
 int mdt_fs_setup(const struct lu_context *ctxt,
                  struct mdt_device *mdt);
 
index f1225aa..4098b75 100644 (file)
@@ -102,7 +102,7 @@ int mdt_handle_last_unlink(struct mdt_thread_info *info, struct mdt_object *mo,
         if (ma->ma_valid & MA_LOV) {
                 __u32 mode;
 
-                mode = lu_object_attr(info->mti_ctxt, &mo->mot_obj.mo_lu);
+                mode = lu_object_attr(&mo->mot_obj.mo_lu);
                 LASSERT(ma->ma_lmm_size);
                 mdt_dump_lmm(D_INFO, ma->ma_lmm);
                 repbody->eadatasize = ma->ma_lmm_size;
@@ -149,7 +149,7 @@ static __u64 mdt_attr_valid_xlate(__u64 in, struct mdt_reint_record *rr,
 
         if (in & ATTR_ATTR_FLAG)
                 out |= LA_FLAGS;
-        
+
         /*XXX need ATTR_RAW?*/
         in &= ~(ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|
                 ATTR_ATIME|ATTR_MTIME|ATTR_CTIME|ATTR_FROM_OPEN|
index d4e6946..7d5fc2f 100644 (file)
@@ -318,7 +318,7 @@ int mdt_open_by_fid(struct mdt_thread_info* info, const struct lu_fid *fid,
 
         o = mdt_object_find(info->mti_ctxt, info->mti_mdt, fid);
         if (!IS_ERR(o)) {
-                if (mdt_object_exists(info->mti_ctxt, &o->mot_obj.mo_lu) > 0) {
+                if (lu_object_exists(&o->mot_obj.mo_lu) > 0) {
                         if (flags & MDS_OPEN_EXCL &&
                             flags & MDS_OPEN_CREAT)
                                 rc = -EEXIST;
index de94623..175b04d 100644 (file)
@@ -157,7 +157,7 @@ static int mdt_reint_setattr(struct mdt_thread_info *info)
                 RETURN(rc = PTR_ERR(mo));
 
         next = mdt_object_child(mo);
-        if (lu_object_exists(info->mti_ctxt, &mo->mot_obj.mo_lu) <= 0)
+        if (lu_object_assert_not_exists(&mo->mot_obj.mo_lu))
                 GOTO(out_unlock, rc = -ENOENT);
 
         /* all attrs are packed into mti_attr in unpack_setattr */
@@ -301,7 +301,7 @@ static int mdt_reint_unlink(struct mdt_thread_info *info)
         if (rc)
                 GOTO(out_unlock_child, rc);
 
-        
+
         rc = mdt_handle_last_unlink(info, mc, ma);
 
         GOTO(out_unlock_child, rc);
index 658f961..627a0f7 100644 (file)
@@ -90,9 +90,9 @@ static int mdt_getxattr_pack_reply(struct mdt_thread_info * info)
                 rc =  min_t(int, info->mti_body->eadatasize, rc);
         }
         req_capsule_set_size(pill, &RMF_EADATA, RCL_SERVER, rc);
-        
+
         rc1 = req_capsule_pack(pill);
-        
+
         return rc = !rc1? rc1 : rc;
 }
 
@@ -108,8 +108,7 @@ int mdt_getxattr(struct mdt_thread_info *info)
         ENTRY;
 
         LASSERT(info->mti_object != NULL);
-        LASSERT(lu_object_assert_exists(info->mti_ctxt,
-                                 &info->mti_object->mot_obj.mo_lu));
+        LASSERT(lu_object_assert_exists(&info->mti_object->mot_obj.mo_lu));
 
         CDEBUG(D_INODE, "getxattr "DFID"\n",
                         PFID(&info->mti_body->fid1));
@@ -120,16 +119,16 @@ int mdt_getxattr(struct mdt_thread_info *info)
         next = mdt_object_child(info->mti_object);
 
         rc = mdt_getxattr_pack_reply(info);
-        if (rc < 0) 
+        if (rc < 0)
                 RETURN(rc);
-        
+
         rep_body = req_capsule_server_get(&info->mti_pill, &RMF_MDT_BODY);
         /*No EA, just go back*/
         if (rc == 0)
                 GOTO(no_xattr, rc);
 
         buf = req_capsule_server_get(&info->mti_pill, &RMF_EADATA);
-        buflen = rc; 
+        buflen = rc;
 
         if (info->mti_body->valid & OBD_MD_FLXATTR) {
                 char *xattr_name = req_capsule_client_get(&info->mti_pill,
index f482632..242a4f8 100644 (file)
@@ -120,8 +120,6 @@ static int   osd_object_init   (const struct lu_context *ctxt,
                                 struct lu_object *l);
 static void  osd_object_release(const struct lu_context *ctxt,
                                 struct lu_object *l);
-static int   osd_object_exists (const struct lu_context *ctx,
-                                const struct lu_object *o);
 static int   osd_object_print  (const struct lu_context *ctx, void *cookie,
                                 lu_printer_t p, const struct lu_object *o);
 static void  osd_device_free   (const struct lu_context *ctx,
@@ -307,7 +305,8 @@ static void osd_object_init0(struct osd_object *obj)
 {
         LASSERT(obj->oo_inode != NULL);
         obj->oo_dt.do_body_ops = &osd_body_ops;
-        obj->oo_dt.do_lu.lo_header->loh_attr |= obj->oo_inode->i_mode & S_IFMT;
+        obj->oo_dt.do_lu.lo_header->loh_attr |=
+                (LOHA_EXISTS | (obj->oo_inode->i_mode & S_IFMT));
 }
 
 static int osd_object_init(const struct lu_context *ctxt, struct lu_object *l)
@@ -379,13 +378,6 @@ static void osd_object_release(const struct lu_context *ctxt,
                 set_bit(LU_OBJECT_HEARD_BANSHEE, &l->lo_header->loh_flags);
 }
 
-static int osd_object_exists(const struct lu_context *ctx,
-                             const struct lu_object *o)
-{
-        LASSERT(osd_invariant(osd_obj(o)));
-        return !!(osd_obj(o)->oo_inode != NULL);
-}
-
 static int osd_object_print(const struct lu_context *ctx, void *cookie,
                             lu_printer_t p, const struct lu_object *l)
 {
@@ -605,7 +597,7 @@ static int osd_attr_get(const struct lu_context *ctxt, struct dt_object *dt,
                         struct lu_attr *attr)
 {
         struct osd_object *obj = osd_dt_obj(dt);
-        LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
         LASSERT(osd_invariant(obj));
         return osd_inode_getattr(ctxt, obj->oo_inode, attr);
 }
@@ -616,7 +608,7 @@ static int osd_attr_set(const struct lu_context *ctxt,
                         struct thandle *handle)
 {
         struct osd_object *obj = osd_dt_obj(dt);
-        LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
         LASSERT(osd_invariant(obj));
         return osd_inode_setattr(ctxt, obj->oo_inode, attr);
 }
@@ -873,7 +865,7 @@ static int osd_object_create(const struct lu_context *ctx, struct dt_object *dt,
         ENTRY;
 
         LASSERT(osd_invariant(obj));
-        LASSERT(!lu_object_exists(ctx, &dt->do_lu));
+        LASSERT(!dt_object_exists(dt));
 
         /*
          * XXX missing: permission checks.
@@ -907,7 +899,7 @@ static int osd_object_create(const struct lu_context *ctx, struct dt_object *dt,
                 osd_oi_write_unlock(&osd->od_oi);
         }
 
-        LASSERT(ergo(result == 0, lu_object_exists(ctx, &dt->do_lu)));
+        LASSERT(ergo(result == 0, dt_object_exists(dt)));
         LASSERT(osd_invariant(obj));
         return result;
 }
@@ -919,7 +911,7 @@ static void osd_object_ref_add(const struct lu_context *ctxt,
         struct inode *inode = obj->oo_inode;
 
         LASSERT(osd_invariant(obj));
-        LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
         if (inode->i_nlink < LDISKFS_LINK_MAX) {
                 inode->i_nlink ++;
                 mark_inode_dirty(inode);
@@ -936,7 +928,7 @@ static void osd_object_ref_del(const struct lu_context *ctxt,
         struct inode *inode = obj->oo_inode;
 
         LASSERT(osd_invariant(obj));
-        LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
         if (inode->i_nlink > 0) {
                 inode->i_nlink --;
                 mark_inode_dirty(inode);
@@ -953,7 +945,7 @@ static int osd_xattr_get(const struct lu_context *ctxt, struct dt_object *dt,
         struct osd_thread_info *info   = lu_context_key_get(ctxt, &osd_key);
         struct dentry          *dentry = &info->oti_dentry;
 
-        LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
         LASSERT(inode->i_op != NULL && inode->i_op->getxattr != NULL);
         dentry->d_inode = inode;
         return inode->i_op->getxattr(dentry, name, buf, size);
@@ -969,7 +961,7 @@ static int osd_xattr_set(const struct lu_context *ctxt, struct dt_object *dt,
         struct osd_thread_info *info   = lu_context_key_get(ctxt, &osd_key);
         struct dentry          *dentry = &info->oti_dentry;
 
-        LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
         LASSERT(inode->i_op != NULL && inode->i_op->setxattr != NULL);
         dentry->d_inode = inode;
 
@@ -990,7 +982,7 @@ static int osd_xattr_list(const struct lu_context *ctxt, struct dt_object *dt,
         struct osd_thread_info *info   = lu_context_key_get(ctxt, &osd_key);
         struct dentry          *dentry = &info->oti_dentry;
 
-        LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
         LASSERT(inode->i_op != NULL && inode->i_op->listxattr != NULL);
         dentry->d_inode = inode;
         return inode->i_op->listxattr(dentry, buf, size);
@@ -1003,7 +995,7 @@ static int osd_xattr_del(const struct lu_context *ctxt, struct dt_object *dt,
         struct osd_thread_info *info   = lu_context_key_get(ctxt, &osd_key);
         struct dentry          *dentry = &info->oti_dentry;
 
-        LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
         LASSERT(inode->i_op != NULL && inode->i_op->removexattr != NULL);
         dentry->d_inode = inode;
         return inode->i_op->removexattr(dentry, name);
@@ -1082,7 +1074,7 @@ static int osd_readpage(const struct lu_context *ctxt,
         int rc;
         int nob;
 
-        LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
         LASSERT(osd_invariant(obj));
         LASSERT(osd_has_index(obj));
 
@@ -1247,7 +1239,7 @@ static int osd_index_try(const struct lu_context *ctx, struct dt_object *dt,
         struct osd_object *obj = osd_dt_obj(dt);
 
         LASSERT(osd_invariant(obj));
-        LASSERT(lu_object_exists(ctx, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
 
         if (osd_sb(osd_obj2dev(obj))->s_root->d_inode == obj->oo_inode) {
                 dt->do_index_ops = &osd_index_compat_ops;
@@ -1294,7 +1286,7 @@ static int osd_index_delete(const struct lu_context *ctxt, struct dt_object *dt,
         ENTRY;
 
         LASSERT(osd_invariant(obj));
-        LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
         LASSERT(obj->oo_container.ic_object == obj->oo_inode);
         LASSERT(obj->oo_ipd != NULL);
 
@@ -1319,7 +1311,7 @@ static int osd_index_lookup(const struct lu_context *ctxt, struct dt_object *dt,
         ENTRY;
 
         LASSERT(osd_invariant(obj));
-        LASSERT(lu_object_exists(ctxt, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
         LASSERT(obj->oo_container.ic_object == obj->oo_inode);
         LASSERT(obj->oo_ipd != NULL);
 
@@ -1343,7 +1335,7 @@ static int osd_index_insert(const struct lu_context *ctx, struct dt_object *dt,
         ENTRY;
 
         LASSERT(osd_invariant(obj));
-        LASSERT(lu_object_exists(ctx, &dt->do_lu));
+        LASSERT(dt_object_exists(dt));
         LASSERT(obj->oo_container.ic_object == obj->oo_inode);
         LASSERT(obj->oo_ipd != NULL);
 
@@ -1372,7 +1364,7 @@ static struct dt_it *osd_it_init(const struct lu_context *ctx,
         struct osd_object *obj = osd_dt_obj(dt);
         struct lu_object  *lo  = &dt->do_lu;
 
-        LASSERT(lu_object_exists(ctx, lo));
+        LASSERT(lu_object_exists(lo));
         LASSERT(obj->oo_ipd != NULL);
 
         OBD_ALLOC_PTR(it);
@@ -1623,7 +1615,7 @@ static int osd_index_compat_insert(const struct lu_context *ctx,
 
         luch = lu_object_find(ctx, ludev->ld_site, fid);
         if (!IS_ERR(luch)) {
-                if (lu_object_exists(ctx, luch)) {
+                if (lu_object_exists(luch)) {
                         struct osd_object *child;
 
                         child = osd_obj(lu_object_locate(luch->lo_header,
@@ -2058,8 +2050,7 @@ static struct lu_object_operations osd_lu_obj_ops = {
         .loo_object_release   = osd_object_release,
         .loo_object_free      = osd_object_free,
         .loo_object_print     = osd_object_print,
-        .loo_object_invariant = osd_object_invariant,
-        .loo_object_exists    = osd_object_exists
+        .loo_object_invariant = osd_object_invariant
 };
 
 static struct lu_device_operations osd_lu_ops = {