Whamcloud - gitweb
LU-2803 osd: osd-zfs to handle echo sequence (2) properly
[fs/lustre-release.git] / lustre / osd-zfs / osd_internal.h
index b321efd..3801296 100644 (file)
@@ -76,12 +76,22 @@ 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 */
                __u64            ozi_key; /* binary key for index files */
@@ -156,6 +166,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;
@@ -186,6 +197,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 */
+       cfs_list_t       os_seq_list;     /* list to seq_list */
+};
+
+struct osd_seq_list {
+       rwlock_t         osl_seq_list_lock;     /* lock for seq_list */
+       cfs_list_t       osl_seq_list;      /* list head for seq */
+       struct semaphore osl_seq_init_sem;
+};
+
 #define OSD_OST_MAP_SIZE       32
 
 /*
@@ -212,8 +236,7 @@ struct osd_device {
        uint64_t                 od_root;
        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,
@@ -334,6 +357,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 {
@@ -373,11 +405,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,6 +420,8 @@ 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);
 
 /* osd_index.c */
 int osd_index_try(const struct lu_env *env, struct dt_object *dt,
@@ -395,6 +429,10 @@ int osd_index_try(const struct lu_env *env, struct dt_object *dt,
 
 
 /* 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);