Whamcloud - gitweb
LU-12137 osd-ldiskfs: trace the obd device used for osd lookup
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_internal.h
index 3ea8ccf..c76b2a0 100644 (file)
@@ -238,6 +238,14 @@ struct osd_obj_orphan {
        __u32 oor_ino;
 };
 
+enum osd_t10_type {
+       OSD_T10_TYPE_UNKNOWN = 0,
+       OSD_T10_TYPE1_CRC,
+       OSD_T10_TYPE3_CRC,
+       OSD_T10_TYPE1_IP,
+       OSD_T10_TYPE3_IP
+};
+
 /*
  * osd device.
  */
@@ -259,7 +267,9 @@ struct osd_device {
                                  od_check_ff:1,
                                  od_is_ost:1,
                                  od_in_init:1,
-                                 od_index_in_idif:1;
+                                 od_index_in_idif:1,
+       /* Other flags */
+                                 od_nonrotational:1;
 
        __s64                     od_auto_scrub_interval;
        __u32                     od_dirent_journal;
@@ -291,9 +301,13 @@ struct osd_device {
        /* service name associated with the osd device */
        char                      od_svname[MAX_OBD_NAME];
        char                      od_mntdev[MAX_OBD_NAME];
+       uuid_t                  od_uuid;
 
-       /* quota slave instance */
-       struct qsd_instance      *od_quota_slave;
+       /* quota slave instance for inode */
+       struct qsd_instance      *od_quota_slave_md;
+
+       /* quota slave instance for block */
+       struct qsd_instance      *od_quota_slave_dt;
 
        /* osd seq instance */
        struct lu_client_seq    *od_cl_seq;
@@ -315,8 +329,18 @@ struct osd_device {
        struct inode            *od_index_backup_inode;
        enum lustre_index_backup_policy od_index_backup_policy;
        int                      od_index_backup_stop;
+       /* T10PI type, zero if not supported  */
+       enum osd_t10_type        od_t10_type;
 };
 
+static inline struct qsd_instance *osd_def_qsd(struct osd_device *osd)
+{
+       if (osd->od_is_ost)
+               return osd->od_quota_slave_dt;
+       else
+               return osd->od_quota_slave_md;
+}
+
 enum osd_full_scrub_ratio {
        /* Trigger OI scrub to scan the whole device directly. */
        OFSR_DIRECTLY   = 0,
@@ -374,11 +398,15 @@ struct osd_thandle {
        /* Link to the device, for debugging. */
        struct lu_ref_link      ot_dev_link;
        unsigned int            ot_credits;
+
+       /* quota IDs related to the transaction */
        unsigned short          ot_id_cnt;
-       __u8                    ot_id_types[OSD_MAX_UGID_CNT];
-       unsigned int            ot_remove_agents:1;
+       __u8                    ot_id_res[OSD_MAX_UGID_CNT];
+       __u8                    ot_id_types[OSD_MAX_UGID_CNT];
        uid_t                   ot_id_array[OSD_MAX_UGID_CNT];
        struct lquota_trans    *ot_quota_trans;
+
+       unsigned int            ot_remove_agents:1;
 #if OSD_THANDLE_STATS
         /** time when this handle was allocated */
        ktime_t oth_alloced;
@@ -517,12 +545,13 @@ struct osd_iobuf {
        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 niobuf_local     **dr_lnbs;
        struct lu_buf      dr_bl_buf;
+       struct lu_buf      dr_lnb_buf;
        sector_t          *dr_blocks;
        ktime_t            dr_start_time;
        ktime_t            dr_elapsed;  /* how long io took */
@@ -530,6 +559,22 @@ struct osd_iobuf {
        unsigned int       dr_init_at;  /* the line iobuf was initialized */
 };
 
+#ifdef HAVE_INODE_TIMESPEC64
+# define osd_timespec                  timespec64
+# define osd_timespec_trunc(ts, gran)  timespec64_trunc((ts), (gran))
+#else
+# define osd_timespec                  timespec
+# define osd_timespec_trunc(ts, gran)  timespec_trunc((ts), (gran))
+#endif
+
+static inline struct osd_timespec osd_inode_time(struct inode *inode,
+                                                s64 seconds)
+{
+       struct osd_timespec ts = { .tv_sec = seconds };
+
+       return osd_timespec_trunc(ts, inode->i_sb->s_time_gran);
+}
+
 #define OSD_INS_CACHE_SIZE     8
 
 struct osd_thread_info {
@@ -560,11 +605,6 @@ struct osd_thread_info {
        struct osd_inode_id    oti_id3;
         struct ost_id          oti_ostid;
 
-        /*
-         * XXX temporary: for ->i_op calls.
-         */
-        struct timespec        oti_time;
-
         /**
          * following ipd and it structures are used for osd_index_iam_lookup()
          * these are defined separately as we might do index operation
@@ -593,40 +633,38 @@ struct osd_thread_info {
        struct osd_idmap_cache oti_cache;
 
        /* dedicated OI cache for insert (which needs inum) */
-       struct osd_idmap_cache *oti_ins_cache;
-       int                    oti_ins_cache_size;
-       int                    oti_ins_cache_used;
+       struct osd_idmap_cache          *oti_ins_cache;
+       int                             oti_ins_cache_size;
+       int                             oti_ins_cache_used;
        /* inc by osd_trans_create and dec by osd_trans_stop */
-       int                    oti_ins_cache_depth;
-
-        int                    oti_r_locks;
-        int                    oti_w_locks;
-        int                    oti_txns;
-        /** used in osd_fid_set() to put xattr */
-        struct lu_buf          oti_buf;
-       struct lu_buf          oti_big_buf;
-        /** used in osd_ea_fid_set() to set fid into common ea */
+       int                             oti_ins_cache_depth;
+
+       int                             oti_r_locks;
+       int                             oti_w_locks;
+       int                             oti_txns;
+       /** used in osd_fid_set() to put xattr */
+       struct lu_buf                   oti_buf;
+       struct lu_buf                   oti_big_buf;
+       /** used in osd_ea_fid_set() to set fid into common ea */
        union {
                struct lustre_ost_attrs oti_ost_attrs;
-               struct filter_fid_old   oti_ff;
-               struct filter_fid       oti_ff_new;
+               struct filter_fid_18_23 oti_ff_old;
+               struct filter_fid       oti_ff;
        };
        /** 0-copy IO */
-       struct osd_iobuf       oti_iobuf;
+       struct osd_iobuf                oti_iobuf;
        /* used to access objects in /O */
-       struct inode          *oti_inode;
+       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 {
 #if defined(HAVE_DQUOT_QC_DQBLK)
                struct qc_dqblk         oti_qdq;
-#elif defined(HAVE_DQUOT_FS_DISK_QUOTA)
-               struct fs_disk_quota    oti_fdq;
 #else
-               struct if_dqblk         oti_dqblk;
+               struct fs_disk_quota    oti_fdq;
 #endif
                struct if_dqinfo        oti_dqinfo;
        };
@@ -644,10 +682,19 @@ struct osd_thread_info {
        unsigned int            oti_declare_ops_cred[OSD_OT_MAX];
        unsigned int            oti_declare_ops_used[OSD_OT_MAX];
        struct osd_directory    oti_iam;
+
+       struct page             **oti_dio_pages;
+       int                     oti_dio_pages_used;
 };
 
 extern int ldiskfs_pdo;
 
+#ifdef HAVE_BVEC_ITER_ALL
+#define DECLARE_BVEC_ITER_ALL(iter) struct bvec_iter_all iter
+#else
+#define DECLARE_BVEC_ITER_ALL(iter) int iter
+#endif
+
 #ifndef HAVE_VFS_SETXATTR
 #define osd_setxattr(dentry, inode, name, buf, len, flag) \
                ((inode)->i_op->setxattr(dentry, name, buf, len, flag))
@@ -681,7 +728,7 @@ static inline int __osd_xattr_set(struct osd_thread_info *info,
 {
        struct dentry *dentry = &info->oti_child_dentry;
 
-       ll_vfs_dq_init(inode);
+       dquot_initialize(inode);
        dentry->d_inode = inode;
        dentry->d_sb = inode->i_sb;
        return osd_setxattr(dentry, inode, name, buf, buflen, fl);
@@ -690,7 +737,6 @@ static inline int __osd_xattr_set(struct osd_thread_info *info,
 #ifdef CONFIG_PROC_FS
 /* osd_lproc.c */
 extern struct lprocfs_vars lprocfs_osd_obd_vars[];
-extern struct lprocfs_vars lprocfs_osd_module_vars[];
 int osd_procfs_init(struct osd_device *osd, const char *name);
 int osd_procfs_fini(struct osd_device *osd);
 void osd_brw_stats_update(struct osd_device *osd, struct osd_iobuf *iobuf);
@@ -700,7 +746,7 @@ int osd_register_proc_index_in_idif(struct osd_device *osd);
 
 #endif
 int osd_statfs(const struct lu_env *env, struct dt_device *dev,
-               struct obd_statfs *sfs);
+              struct obd_statfs *sfs, struct obd_statfs_info *info);
 struct inode *osd_iget(struct osd_thread_info *info, struct osd_device *dev,
                       struct osd_inode_id *id);
 struct inode *
@@ -751,6 +797,13 @@ int osd_oii_lookup(struct osd_device *dev, const struct lu_fid *fid,
                   struct osd_inode_id *id);
 void osd_scrub_dump(struct seq_file *m, struct osd_device *dev);
 
+struct dentry *osd_lookup_one_len_unlocked(struct osd_device *dev,
+                                          const char *name,
+                                          struct dentry *base, int len);
+struct dentry *osd_ios_lookup_one_len(struct osd_device *dev,
+                                     const char *name,
+                                     struct dentry *base, int len);
+
 int osd_fld_lookup(const struct lu_env *env, struct osd_device *osd,
                   u64 seq, struct lu_seq_range *range);
 
@@ -836,6 +889,13 @@ static inline void i_projid_write(struct inode *inode, __u32 projid)
 }
 #endif
 
+#ifdef HAVE_LDISKFS_IGET_WITH_FLAGS
+# define osd_ldiskfs_iget(sb, ino) \
+               ldiskfs_iget((sb), (ino), LDISKFS_IGET_HANDLE)
+#else
+# define osd_ldiskfs_iget(sb, ino) ldiskfs_iget((sb), (ino))
+#endif
+
 #ifdef HAVE_LDISKFS_INFO_JINODE
 # define osd_attach_jinode(inode) ldiskfs_inode_attach_jinode(inode)
 #else  /* HAVE_LDISKFS_INFO_JINODE */
@@ -863,7 +923,7 @@ static inline struct buffer_head *osd_ldiskfs_append(handle_t *handle,
                ldiskfs_journal_start(inode, type, nblocks)
 # define osd_transaction_size(dev) \
                (osd_journal(dev)->j_max_transaction_buffers / 2)
-#else
+#else /* ! defined LDISKFS_HT_MISC */
 # define LDISKFS_HT_MISC       0
 # define osd_journal_start_sb(sb, type, nblock) \
                ldiskfs_journal_start_sb(sb, nblock)
@@ -1337,11 +1397,18 @@ static inline struct buffer_head *__ldiskfs_bread(handle_t *handle,
        return bh;
 }
 
-#ifndef bio_set_dev
-# define bio_set_dev(bio, bdev) ((bio)->bi_bdev = bdev)
-# define bio_get_queue(bio)    bdev_get_queue((bio)->bi_bdev)
+#ifndef HAVE_BIO_INTEGRITY_ENABLED
+bool bio_integrity_enabled(struct bio *bio);
+#endif
+
+#ifdef HAVE_BI_BDEV
+# define bio_get_dev(bio)      ((bio)->bi_bdev)
+# define bio_get_disk(bio)     (bio_get_dev(bio)->bd_disk)
+# define bio_get_queue(bio)    bdev_get_queue(bio_get_dev(bio))
+# define bio_set_dev(bio, bdev) (bio_get_dev(bio) = (bdev))
 #else
-# define bio_get_queue(bio)    ((bio)->bi_disk->queue)
+# define bio_get_disk(bio)     ((bio)->bi_disk)
+# define bio_get_queue(bio)    (bio_get_disk(bio)->queue)
 #endif
 
 void ldiskfs_inc_count(handle_t *handle, struct inode *inode);
@@ -1411,4 +1478,61 @@ void osd_trunc_unlock_all(struct list_head *list);
 void osd_process_truncates(struct list_head *list);
 void osd_execute_truncate(struct osd_object *obj);
 
+#ifdef HAVE_BIO_ENDIO_USES_ONE_ARG
+#define osd_dio_complete_routine(bio, error) dio_complete_routine(bio)
+#else
+#define osd_dio_complete_routine(bio, error) dio_complete_routine(bio, error)
+#endif
+
+#ifndef HAVE___BI_CNT
+#define __bi_cnt bi_cnt
+#endif
+
+#ifndef HAVE_BI_OPF
+#define bi_opf bi_rw
+#endif
+
+#ifndef HAVE_CLEAN_BDEV_ALIASES
+#define clean_bdev_aliases(bdev, block, len)   \
+       unmap_underlying_metadata((bdev), (block))
+#endif
+
+#ifndef HAVE_BI_STATUS
+#define bi_status bi_error
+#endif
+
+/*
+ * Maximum size of xattr attributes for FEATURE_INCOMPAT_EA_INODE 1Mb
+ * This limit is arbitrary, but is reasonable for the xattr API.
+ */
+#define LDISKFS_XATTR_MAX_LARGE_EA_SIZE    (1024 * 1024)
+
+struct osd_bio_private {
+       struct osd_iobuf        *obp_iobuf;
+       /* Start page index in the obp_iobuf for the bio */
+       int                      obp_start_page_idx;
+};
+
+#ifdef HAVE_BIO_INTEGRITY_PREP_FN
+int osd_get_integrity_profile(struct osd_device *osd,
+                             integrity_gen_fn **generate_fn,
+                             integrity_vrfy_fn **verify_fn);
+#else
+#define integrity_gen_fn void
+#define integrity_vrfy_fn int
+static inline int osd_get_integrity_profile(struct osd_device *osd,
+                                           integrity_gen_fn **generate_fn,
+                                           integrity_vrfy_fn **verify_fn)
+{
+       return 0;
+}
+
+static inline bool bio_integrity_prep_fn(struct bio *bio,
+                                        integrity_gen_fn *generate_fn,
+                                        integrity_vrfy_fn *verify_fn)
+{
+       return bio_integrity_prep(bio);
+}
+#endif
+
 #endif /* _OSD_INTERNAL_H */