Whamcloud - gitweb
LU-1199 build: Cleanup ldiskfs kernel config defines
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_internal.h
index 3d5f893..75a2a8a 100644 (file)
 /* struct dirent64 */
 #include <linux/dirent.h>
 
+#include <ldiskfs/ldiskfs_config.h>
 #include <ldiskfs/ldiskfs.h>
 #include <ldiskfs/ldiskfs_jbd2.h>
-#ifdef HAVE_LDISKFS_JOURNAL_CALLBACK_ADD
-# define journal_callback ldiskfs_journal_cb_entry
-# define osd_journal_callback_set(handle, func, jcb) \
-         ldiskfs_journal_callback_add(handle, func, jcb)
-#else
-# define osd_journal_callback_set(handle, func, jcb) \
-         jbd2_journal_callback_set(handle, func, jcb)
-#endif
 
 /* fsfilt_{get|put}_ops */
 #include <lustre_fsfilt.h>
@@ -83,12 +76,24 @@ struct inode;
 
 #define OSD_COUNTERS (0)
 
-/* Lustre special inode::i_state to indicate OI scrub skip this inode. */
-#define I_LUSTRE_NOSCRUB       (1 << 31)
+/* ldiskfs special inode::i_state_flags need to be accessed with
+ * ldiskfs_{set,clear,test}_inode_state() only */
+
+/* OI scrub should skip this inode. */
+#define LDISKFS_STATE_LUSTRE_NOSCRUB   31
+
+/* Do not add OI mapping for this inode. */
+#define LDISKFS_STATE_LUSTRE_NO_OI     30
 
 /** Enable thandle usage statistics */
 #define OSD_THANDLE_STATS (0)
 
+#define MAX_OBJID_GROUP (FID_SEQ_ECHO + 1)
+
+#define OBJECTS        "OBJECTS"
+#define ADMIN_USR      "admin_quotafile_v2.usr"
+#define ADMIN_GRP      "admin_quotafile_v2.grp"
+
 struct osd_directory {
         struct iam_container od_container;
         struct iam_descr     od_descr;
@@ -157,6 +162,16 @@ struct osd_obj_map {
        struct semaphore om_dir_init_sem;
 };
 
+struct osd_mdobj {
+       struct dentry   *om_root;      /* AGENT/<index> */
+       obd_seq         om_index;     /* mdt index */
+       cfs_list_t      om_list;      /* list to omm_list */
+};
+
+struct osd_mdobj_map {
+       struct dentry   *omm_remote_parent;
+};
+
 #define osd_ldiskfs_find_entry(dir, dentry, de, lock)   \
         ll_ldiskfs_find_entry(dir, dentry, de, lock)
 #define osd_ldiskfs_add_entry(handle, child, cinode, hlock) \
@@ -194,11 +209,9 @@ struct osd_otable_cache {
 
 struct osd_otable_it {
        struct osd_device       *ooi_dev;
+       pid_t                    ooi_pid;
        struct osd_otable_cache  ooi_cache;
 
-       /* For osd_otable_it_key. */
-       __u8                     ooi_key[16];
-
        /* The following bits can be updated/checked w/o lock protection.
         * If more bits will be introduced in the future and need lock to
         * protect, please add comment. */
@@ -208,7 +221,9 @@ struct osd_otable_it {
                                                    * filled into cache. */
                                 ooi_user_ready:1, /* The user out of OSD is
                                                    * ready to iterate. */
-                                ooi_waiting:1; /* it::next is waiting. */
+                                ooi_waiting:1, /* it::next is waiting. */
+                                ooi_stopping:1; /* Someone is stopping
+                                                 * the iteration. */
 };
 
 extern const int osd_dto_credits_noquota[];
@@ -244,13 +259,16 @@ struct osd_device {
         struct obd_statfs         od_statfs;
        spinlock_t                od_osfs_lock;
 
-       unsigned int              od_noscrub:1;
+       unsigned int              od_noscrub:1,
+                                 od_dirent_journal:1,
+                                 od_handle_nolma:1;
 
        struct fsfilt_operations *od_fsops;
        int                       od_connects;
        struct lu_site            od_site;
 
        struct osd_obj_map      *od_ost_map;
+       struct osd_mdobj_map    *od_mdt_map;
 
         unsigned long long        od_readcache_max_filesize;
         int                       od_read_cache;
@@ -263,6 +281,7 @@ struct osd_device {
        struct mutex              od_otable_mutex;
        struct osd_otable_it     *od_otable_it;
        struct osd_scrub          od_scrub;
+       cfs_list_t                od_ios_list;
 
        /* service name associated with the osd device */
        char                      od_svname[MAX_OBD_NAME];
@@ -300,12 +319,14 @@ enum {
        OSD_OT_MAX              = 11
 };
 
-#define OSD_TRACK_DECLARES
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 3, 90, 0)
+# define OSD_TRACK_DECLARES
+#endif
 
 struct osd_thandle {
         struct thandle          ot_super;
         handle_t               *ot_handle;
-        struct journal_callback ot_jcb;
+        struct ldiskfs_journal_cb_entry ot_jcb;
         cfs_list_t              ot_dcb_list;
         /* Link to the device, for debugging. */
         struct lu_ref_link     *ot_dev_link;
@@ -445,20 +466,22 @@ struct osd_it_quota {
 #define MAX_BLOCKS_PER_PAGE (CFS_PAGE_SIZE / 512)
 
 struct osd_iobuf {
-        cfs_waitq_t        dr_wait;
-        cfs_atomic_t       dr_numreqs;  /* number of reqs being processed */
-        int                dr_max_pages;
-        int                dr_npages;
-        int                dr_error;
-        int                dr_frags;
-        unsigned int       dr_ignore_quota:1;
-        unsigned int       dr_elapsed_valid:1; /* we really did count time */
-        unsigned int       dr_rw:1;
-        struct page       *dr_pages[PTLRPC_MAX_BRW_PAGES];
-        unsigned long      dr_blocks[PTLRPC_MAX_BRW_PAGES*MAX_BLOCKS_PER_PAGE];
-        unsigned long      dr_start_time;
-        unsigned long      dr_elapsed;  /* how long io took */
-        struct osd_device *dr_dev;
+       cfs_waitq_t        dr_wait;
+       cfs_atomic_t       dr_numreqs;  /* number of reqs being processed */
+       int                dr_max_pages;
+       int                dr_npages;
+       int                dr_error;
+       int                dr_frags;
+       unsigned int       dr_ignore_quota:1;
+       unsigned int       dr_elapsed_valid:1; /* we really did count time */
+       unsigned int       dr_rw:1;
+       struct lu_buf      dr_pg_buf;
+       struct page      **dr_pages;
+       struct lu_buf      dr_bl_buf;
+       unsigned long     *dr_blocks;
+       unsigned long      dr_start_time;
+       unsigned long      dr_elapsed;  /* how long io took */
+       struct osd_device *dr_dev;
        unsigned int       dr_init_at;  /* the line iobuf was initialized */
 };
 
@@ -514,10 +537,10 @@ struct osd_thread_info {
                struct osd_it_quota     oti_it_quota;
        };
 
-        /** pre-allocated buffer used by oti_it_ea, size OSD_IT_EA_BUFSIZE */
-        void                  *oti_it_ea_buf;
+       /** pre-allocated buffer used by oti_it_ea, size OSD_IT_EA_BUFSIZE */
+       void                    *oti_it_ea_buf;
 
-        cfs_kstatfs_t          oti_ksfs;
+       struct kstatfs          oti_ksfs;
 
         /** IAM iterator for index operation. */
         struct iam_iterator    oti_idx_it;
@@ -546,18 +569,20 @@ struct osd_thread_info {
                /* old LMA for compatibility */
                char                    oti_mdt_attrs_old[LMA_OLD_SIZE];
        };
-        /** 0-copy IO */
-        struct osd_iobuf       oti_iobuf;
-        struct inode           oti_inode;
-        int                    oti_created[PTLRPC_MAX_BRW_PAGES];
-        struct lu_env          oti_obj_delete_tx_env;
+       /** 0-copy IO */
+       struct osd_iobuf       oti_iobuf;
+       struct inode           oti_inode;
 #define OSD_FID_REC_SZ 32
-        char                   oti_ldp[OSD_FID_REC_SZ];
-        char                   oti_ldp2[OSD_FID_REC_SZ];
+       char                   oti_ldp[OSD_FID_REC_SZ];
+       char                   oti_ldp2[OSD_FID_REC_SZ];
 
        /* used by quota code */
        union {
+#ifdef HAVE_DQUOT_FS_DISK_QUOTA
+               struct fs_disk_quota    oti_fdq;
+#else
                struct if_dqblk         oti_dqblk;
+#endif
                struct if_dqinfo        oti_dqinfo;
        };
        struct lquota_id_info   oti_qi;
@@ -576,10 +601,22 @@ struct osd_thread_info {
        bool                    oti_rollback;
 #endif
 
+       char                    oti_name[48];
 };
 
 extern int ldiskfs_pdo;
 
+static inline int __osd_xattr_set(struct osd_thread_info *info,
+                                 struct inode *inode, const char *name,
+                                 const void *buf, int buflen, int fl)
+{
+       struct dentry *dentry = &info->oti_child_dentry;
+
+       ll_vfs_dq_init(inode);
+       dentry->d_inode = inode;
+       return inode->i_op->setxattr(dentry, name, buf, buflen, fl);
+}
+
 #ifdef LPROCFS
 /* osd_lproc.c */
 void lprocfs_osd_init_vars(struct lprocfs_static_vars *lvars);
@@ -594,10 +631,12 @@ int osd_object_auth(const struct lu_env *env, struct dt_object *dt,
                     struct lustre_capa *capa, __u64 opc);
 struct inode *osd_iget(struct osd_thread_info *info, struct osd_device *dev,
                       struct osd_inode_id *id);
-struct inode *osd_iget_fid(struct osd_thread_info *info, struct osd_device *dev,
-                          struct osd_inode_id *id, struct lu_fid *fid);
+int osd_ea_fid_set(struct osd_thread_info *info, struct inode *inode,
+                  const struct lu_fid *fid, __u64 flags);
+int osd_get_lma(struct osd_thread_info *info, struct inode *inode,
+               struct dentry *dentry, struct lustre_mdt_attrs *lma);
 
-int osd_obj_map_init(struct osd_device *osd);
+int osd_obj_map_init(const struct lu_env *env, struct osd_device *osd);
 void osd_obj_map_fini(struct osd_device *dev);
 int osd_obj_map_lookup(struct osd_thread_info *info, struct osd_device *osd,
                        const struct lu_fid *fid, struct osd_inode_id *id);
@@ -614,6 +653,7 @@ int osd_obj_spec_insert(struct osd_thread_info *info, struct osd_device *osd,
 
 void osd_scrub_file_reset(struct osd_scrub *scrub, __u8 *uuid, __u64 flags);
 int osd_scrub_file_store(struct osd_scrub *scrub);
+char *osd_lf_fid2name(const struct lu_fid *fid);
 int osd_scrub_start(struct osd_device *dev);
 int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev);
 void osd_scrub_cleanup(const struct lu_env *env, struct osd_device *dev);
@@ -625,6 +665,14 @@ int osd_scrub_dump(struct osd_device *dev, char *buf, int len);
 
 int osd_fld_lookup(const struct lu_env *env, struct osd_device *osd,
                   const struct lu_fid *fid, struct lu_seq_range *range);
+
+int osd_delete_from_remote_parent(const struct lu_env *env,
+                                 struct osd_device *osd,
+                                 struct osd_object *obj,
+                                 struct osd_thandle *oh);
+int osd_add_to_remote_parent(const struct lu_env *env, struct osd_device *osd,
+                            struct osd_object *obj, struct osd_thandle *oh);
+
 /* osd_quota_fmt.c */
 int walk_tree_dqentry(const struct lu_env *env, struct osd_object *obj,
                       int type, uint blk, int depth, uint index,
@@ -649,6 +697,9 @@ void osd_quota_unpack(struct osd_object *obj, const struct dt_rec *rec);
 int osd_quota_migration(const struct lu_env *env, struct dt_object *dt,
                        const struct dt_index_features *feat);
 
+/* osd_compat.c */
+struct osd_obj_seq *osd_seq_load(struct osd_device *osd, obd_seq seq);
+
 static inline bool is_quota_glb_feat(const struct dt_index_features *feat)
 {
        return (feat == &dt_quota_iusr_features ||
@@ -698,7 +749,6 @@ static inline struct osd_oi *osd_fid2oi(struct osd_device *osd,
 {
        LASSERTF(!fid_is_idif(fid), DFID"\n", PFID(fid));
        LASSERTF(!fid_is_last_id(fid), DFID"\n", PFID(fid));
-       LASSERTF(!fid_is_igif(fid), DFID"\n", PFID(fid));
        LASSERT(osd->od_oi_table != NULL && osd->od_oi_count >= 1);
        /* It can work even od_oi_count equals to 1 although it's unexpected,
         * the only reason we set it to 1 is for performance measurement */