Whamcloud - gitweb
LU-7713 osd: osd-zfs should serialize destroy vs. others
[fs/lustre-release.git] / lustre / osd-zfs / osd_internal.h
index 12bf5a5..fa0c3f2 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -203,6 +203,7 @@ static inline struct osd_thread_info *osd_oti_get(const struct lu_env *env)
 struct osd_thandle {
        struct thandle           ot_super;
        struct list_head         ot_dcb_list;
+       struct list_head         ot_stop_dcb_list;
        struct list_head         ot_unlinked_list;
        struct list_head         ot_sa_list;
        struct semaphore         ot_sa_lock;
@@ -261,7 +262,8 @@ struct osd_device {
        unsigned int             od_oi_count;
        struct osd_seq_list     od_seq_list;
 
-       unsigned int             od_rdonly:1,
+       unsigned int             od_dev_set_rdonly:1, /**< osd_ro() called */
+                                od_prop_rdonly:1,  /**< ZFS property readonly */
                                 od_xattr_in_sa:1,
                                 od_quota_iused_est:1,
                                 od_is_ost:1,
@@ -316,19 +318,29 @@ struct osd_object {
        sa_handle_t             *oo_sa_hdl;
        nvlist_t                *oo_sa_xattr;
        struct list_head         oo_sa_linkage;
-       struct list_head         oo_unlinked_linkage;
 
+       /* used to implement osd_object_*_{lock|unlock} */
        struct rw_semaphore      oo_sem;
 
+       /* to serialize some updates: destroy vs. others,
+        * xattr_set, etc */
+       struct rw_semaphore      oo_guard;
+
+       /* protected by oo_guard */
+       struct list_head         oo_unlinked_linkage;
+
        /* cached attributes */
        rwlock_t                 oo_attr_lock;
        struct lu_attr           oo_attr;
 
-       /* protects extended attributes and oo_unlinked_linkage */
-       struct semaphore         oo_guard;
+       /* external dnode holding large EAs, protected by oo_guard */
        uint64_t                 oo_xattr;
        enum osd_destroy_type    oo_destroy;
 
+       __u32                    oo_destroyed:1;
+
+       /* the i_flags in LMA */
+       __u32                    oo_lma_flags;
        /* record size for index file */
        unsigned char            oo_keysize;
        unsigned char            oo_recsize;
@@ -460,8 +472,6 @@ int osd_fid_lookup(const struct lu_env *env,
 uint64_t osd_get_name_n_idx(const struct lu_env *env, struct osd_device *osd,
                            const struct lu_fid *fid, char *buf);
 int osd_options_init(void);
-int osd_convert_root_to_new_seq(const struct lu_env *env,
-                               struct osd_device *o);
 int osd_ost_seq_exists(const struct lu_env *env, struct osd_device *osd,
                       __u64 seq);
 /* osd_index.c */
@@ -516,6 +526,10 @@ osd_xattr_set_internal(const struct lu_env *env, struct osd_object *obj,
 {
        int rc;
 
+       if (unlikely(!dt_object_exists(&obj->oo_dt) || obj->oo_destroyed))
+               return -ENOENT;
+
+       LASSERT(obj->oo_db);
        if (osd_obj2dev(obj)->od_xattr_in_sa) {
                rc = __osd_sa_xattr_set(env, obj, buf, name, fl, oh);
                if (rc == -EFBIG)
@@ -529,16 +543,16 @@ osd_xattr_set_internal(const struct lu_env *env, struct osd_object *obj,
 
 static inline uint64_t attrs_fs2zfs(const uint32_t flags)
 {
-       return (((flags & FS_APPEND_FL)         ? ZFS_APPENDONLY        : 0) |
-               ((flags & FS_NODUMP_FL)         ? ZFS_NODUMP            : 0) |
-               ((flags & FS_IMMUTABLE_FL)      ? ZFS_IMMUTABLE         : 0));
+       return (flags & LUSTRE_APPEND_FL        ? ZFS_APPENDONLY        : 0) |
+               (flags & LUSTRE_NODUMP_FL       ? ZFS_NODUMP            : 0) |
+               (flags & LUSTRE_IMMUTABLE_FL    ? ZFS_IMMUTABLE         : 0);
 }
 
 static inline uint32_t attrs_zfs2fs(const uint64_t flags)
 {
-       return (((flags & ZFS_APPENDONLY)       ? FS_APPEND_FL          : 0) |
-               ((flags & ZFS_NODUMP)           ? FS_NODUMP_FL          : 0) |
-               ((flags & ZFS_IMMUTABLE)        ? FS_IMMUTABLE_FL       : 0));
+       return (flags & ZFS_APPENDONLY  ? LUSTRE_APPEND_FL      : 0) |
+               (flags & ZFS_NODUMP     ? LUSTRE_NODUMP_FL      : 0) |
+               (flags & ZFS_IMMUTABLE  ? LUSTRE_IMMUTABLE_FL   : 0);
 }
 
 #endif