Whamcloud - gitweb
LU-3660 acl: support mount option "noacl" for zfs
[fs/lustre-release.git] / lustre / osd-zfs / osd_internal.h
index b321efd..16e7633 100644 (file)
@@ -28,7 +28,7 @@
  * Use is subject to license terms.
  */
 /*
- * Copyright (c) 2012, Intel Corporation.
+ * Copyright (c) 2012, 2013, Intel Corporation.
  * Use is subject to license terms.
  */
 /*
 #define _OSD_INTERNAL_H
 
 #include <dt_object.h>
+#include <md_object.h>
 #include <lustre_quota.h>
+
+#define _SPL_KMEM_H
+#include <sys/kstat.h>
+#define kmem_zalloc(a, b)      kzalloc(a, b)
+#define kmem_free(ptr, sz)     ((void)(sz), kfree(ptr))
+#ifndef KM_SLEEP
+#define KM_SLEEP               GFP_KERNEL
+#endif
+
 #include <sys/arc.h>
 
 #include <sys/nvpair.h>
 
+#include <sys/zfs_znode.h>
 #include "udmu.h"
 
 #define LUSTRE_ROOT_FID_SEQ    0
@@ -76,14 +87,24 @@ struct osd_it_quota {
 
 /**
  * Iterator's in-memory data structure for ZAPs
+ *
+ * ZFS does not store . and .. on a disk, instead they are
+ * generated up on request
+ * to follow this format we do the same
  */
 struct osd_zap_it {
        zap_cursor_t            *ozi_zc;
        struct osd_object       *ozi_obj;
        struct lustre_capa      *ozi_capa;
-       unsigned                 ozi_reset:1;     /* 1 -- no need to advance */
+       unsigned                 ozi_reset:1;   /* 1 -- no need to advance */
+       /* ozi_pos - position of the cursor:
+        * 0 - before any record
+        * 1 - "."
+        * 2 - ".."
+        * 3 - real records */
+       unsigned                 ozi_pos:3;
        union {
-               char             ozi_name[NAME_MAX + 1]; /* file name for dir */
+               char             ozi_name[MAXNAMELEN]; /* file name for dir */
                __u64            ozi_key; /* binary key for index files */
        };
 };
@@ -146,7 +167,10 @@ struct osd_thread_info {
        };
 
        char                     oti_str[64];
-       char                     oti_key[MAXNAMELEN + 1];
+       union {
+               char             oti_key[MAXNAMELEN + 1];
+               __u64            oti_key64[(MAXNAMELEN + 1)/sizeof(__u64)];
+       };
        struct lustre_mdt_attrs oti_mdt_attrs;
 
        struct lu_attr           oti_la;
@@ -156,6 +180,7 @@ struct osd_thread_info {
        struct luz_direntry      oti_zde;
 
        struct lquota_id_info    oti_qi;
+       struct lu_seq_range      oti_seq_range;
 };
 
 extern struct lu_context_key osd_key;
@@ -167,8 +192,8 @@ static inline struct osd_thread_info *osd_oti_get(const struct lu_env *env)
 
 struct osd_thandle {
        struct thandle           ot_super;
-       cfs_list_t               ot_dcb_list;
-       cfs_list_t               ot_sa_list;
+       struct list_head         ot_dcb_list;
+       struct list_head         ot_sa_list;
        struct semaphore         ot_sa_lock;
        dmu_tx_t                *ot_tx;
        struct lquota_trans      ot_quota_trans;
@@ -186,6 +211,19 @@ struct osd_oi {
        uint64_t                oi_zapid;
 };
 
+struct osd_seq {
+       uint64_t         *os_compat_dirs;
+       int              os_subdir_count; /* subdir count for each seq */
+       obd_seq          os_seq;          /* seq number */
+       struct list_head os_seq_list;     /* list to seq_list */
+};
+
+struct osd_seq_list {
+       rwlock_t         osl_seq_list_lock;     /* lock for seq_list */
+       struct list_head osl_seq_list;          /* list head for seq */
+       struct semaphore osl_seq_init_sem;
+};
+
 #define OSD_OST_MAP_SIZE       32
 
 /*
@@ -204,20 +242,23 @@ struct osd_device {
        unsigned long            od_capa_timeout;
        __u32                    od_capa_alg;
        struct lustre_capa_key  *od_capa_keys;
-       cfs_hlist_head_t        *od_capa_hash;
+       struct hlist_head       *od_capa_hash;
 
        cfs_proc_dir_entry_t    *od_proc_entry;
        struct lprocfs_stats    *od_stats;
 
        uint64_t                 od_root;
+       uint64_t                 od_O_id;
        struct osd_oi           **od_oi_table;
        unsigned int             od_oi_count;
-       uint64_t                 od_ost_compat_dirs[OSD_OST_MAP_SIZE];
-       uint64_t                 od_ost_compat_grp0;
+       struct osd_seq_list     od_seq_list;
 
        unsigned int             od_rdonly:1,
                                 od_xattr_in_sa:1,
-                                od_quota_iused_est:1;
+                                od_quota_iused_est:1,
+                                od_is_ost:1,
+                                od_posix_acl:1;
+
        char                     od_mntdev[128];
        char                     od_svname[128];
 
@@ -234,11 +275,14 @@ struct osd_device {
        /* used to debug zerocopy logic: the fields track all
         * allocated, loaned and referenced buffers in use.
         * to be removed once the change is tested well. */
-       cfs_atomic_t             od_zerocopy_alloc;
-       cfs_atomic_t             od_zerocopy_loan;
-       cfs_atomic_t             od_zerocopy_pin;
+       atomic_t                 od_zerocopy_alloc;
+       atomic_t                 od_zerocopy_loan;
+       atomic_t                 od_zerocopy_pin;
 
        arc_prune_t             *arc_prune_cb;
+
+       /* osd seq instance */
+       struct lu_client_seq    *od_cl_seq;
 };
 
 struct osd_object {
@@ -253,7 +297,7 @@ struct osd_object {
        dmu_buf_t               *oo_db;
        sa_handle_t             *oo_sa_hdl;
        nvlist_t                *oo_sa_xattr;
-       cfs_list_t               oo_sa_linkage;
+       struct list_head         oo_sa_linkage;
 
        struct rw_semaphore      oo_sem;
 
@@ -266,7 +310,9 @@ struct osd_object {
        uint64_t                 oo_xattr;
 
        /* record size for index file */
-       int                      oo_recsize;
+       unsigned char            oo_keysize;
+       unsigned char            oo_recsize;
+       unsigned char            oo_recusize;   /* unit size */
 };
 
 int osd_statfs(const struct lu_env *, struct dt_device *, struct obd_statfs *);
@@ -334,6 +380,15 @@ static inline int osd_object_invariant(const struct lu_object *l)
        return osd_invariant(osd_obj(l));
 }
 
+static inline struct seq_server_site *osd_seq_site(struct osd_device *osd)
+{
+       return osd->od_dt_dev.dd_lu_dev.ld_site->ld_seq_site;
+}
+
+static inline char *osd_name(struct osd_device *osd)
+{
+       return osd->od_dt_dev.dd_lu_dev.ld_obd->obd_name;
+}
 
 #ifdef LPROCFS
 enum {
@@ -351,8 +406,7 @@ enum {
 };
 
 /* osd_lproc.c */
-extern struct lprocfs_vars lprocfs_osd_obd_vars[];
-extern struct lprocfs_vars lprocfs_osd_module_vars[];
+extern struct lprocfs_seq_vars lprocfs_osd_obd_vars[];
 
 int osd_procfs_init(struct osd_device *osd, const char *name);
 int osd_procfs_fini(struct osd_device *osd);
@@ -373,11 +427,11 @@ struct lu_object *osd_object_alloc(const struct lu_env *env,
 int osd_object_sa_update(struct osd_object *obj, sa_attr_type_t type,
                         void *buf, uint32_t buflen, struct osd_thandle *oh);
 int __osd_zap_create(const struct lu_env *env, udmu_objset_t *uos,
-                    dmu_buf_t **zap_dbp, dmu_tx_t *tx,
-                    struct lu_attr *la, void *tag, zap_flags_t flags);
+                    dmu_buf_t **zap_dbp, dmu_tx_t *tx, struct lu_attr *la,
+                    uint64_t parent, void *tag, zap_flags_t flags);
 int __osd_object_create(const struct lu_env *env, udmu_objset_t *uos,
-                       dmu_buf_t **dbp, dmu_tx_t *tx,
-                       struct lu_attr *la, void *tag);
+                       dmu_buf_t **dbp, dmu_tx_t *tx, struct lu_attr *la,
+                       uint64_t parent, void *tag);
 int __osd_object_free(udmu_objset_t *uos, uint64_t oid, dmu_tx_t *tx);
 
 /* osd_oi.c */
@@ -388,13 +442,21 @@ 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 */
 int osd_index_try(const struct lu_env *env, struct dt_object *dt,
                  const struct dt_index_features *feat);
-
+int osd_fld_lookup(const struct lu_env *env, struct osd_device *osd,
+                  obd_seq seq, struct lu_seq_range *range);
 
 /* osd_xattr.c */
+int __osd_xattr_load(udmu_objset_t *uos, uint64_t dnode, nvlist_t **sa_xattr);
+int __osd_xattr_get_large(const struct lu_env *env, udmu_objset_t *uos,
+                         uint64_t xattr, struct lu_buf *buf,
+                         const char *name, int *sizep);
 int osd_xattr_get(const struct lu_env *env, struct dt_object *dt,
                  struct lu_buf *buf, const char *name,
                  struct lustre_capa *capa);
@@ -437,5 +499,31 @@ osd_xattr_set_internal(const struct lu_env *env, struct osd_object *obj,
        return rc;
 }
 
+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));
+}
+
+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));
+}
+
 #endif
+
+#ifndef HAVE_DSL_POOL_CONFIG
+static inline void dsl_pool_config_enter(dsl_pool_t *dp, char *name)
+{
+}
+
+static inline void dsl_pool_config_exit(dsl_pool_t *dp, char *name)
+{
+}
+
+#endif
+
 #endif /* _OSD_INTERNAL_H */