Whamcloud - gitweb
LU-15171 osd-ldiskfs: xattr_sem locking is missing for dquot_transfer
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_internal.h
index 7d2f970..705d8b0 100644 (file)
@@ -27,7 +27,6 @@
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * lustre/osd/osd_internal.h
  *
@@ -243,11 +242,14 @@ struct osd_obj_orphan {
 };
 
 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_T10_TYPE_UNKNOWN    = 0,
+       OSD_T10_TYPE1           = 0x1,
+       OSD_T10_TYPE3           = 0x2,
+       OSD_T10_TYPE_CRC        = 0x4,
+       OSD_T10_TYPE1_CRC       = OSD_T10_TYPE1 | OSD_T10_TYPE_CRC,
+       OSD_T10_TYPE3_CRC       = OSD_T10_TYPE3 | OSD_T10_TYPE_CRC,
+       OSD_T10_TYPE1_IP        = OSD_T10_TYPE1,
+       OSD_T10_TYPE3_IP        = OSD_T10_TYPE3,
 };
 
 /*
@@ -273,9 +275,11 @@ struct osd_device {
                                  od_in_init:1,
                                  od_index_in_idif:1,
        /* Other flags */
+                                 od_read_cache:1,
+                                 od_writethrough_cache:1,
                                  od_nonrotational:1;
 
-       __s64                     od_auto_scrub_interval;
+
        __u32                     od_dirent_journal;
        int                       od_index;
        struct proc_dir_entry    *od_proc_entry;
@@ -283,6 +287,7 @@ struct osd_device {
 
        spinlock_t                od_osfs_lock;
 
+       int                       od_fallocate_zero_blocks;
        int                       od_connects;
        struct lu_site            od_site;
 
@@ -301,9 +306,6 @@ struct osd_device {
         * served bypassing pagecache unless already cached */
        unsigned long           od_writethrough_max_iosize;
 
-       int                     od_read_cache;
-       int                     od_writethrough_cache;
-
        struct brw_stats        od_brw_stats;
        atomic_t                od_r_in_flight;
        atomic_t                od_w_in_flight;
@@ -404,8 +406,12 @@ enum osd_op_type {
 struct osd_access_lock {
        struct list_head         tl_list;
        struct osd_object       *tl_obj;
+       loff_t                   tl_start;
+       loff_t                   tl_end;
+       int                      tl_mode;
        bool                     tl_shared;
        bool                     tl_truncate;
+       bool                     tl_punch;
 };
 
 struct osd_thandle {
@@ -707,6 +713,9 @@ struct osd_thread_info {
 
        struct page             **oti_dio_pages;
        int                     oti_dio_pages_used;
+
+       struct osd_it_ea_dirent *oti_seq_dirent;
+       struct osd_it_ea_dirent *oti_dir_dirent;
 };
 
 extern int ldiskfs_pdo;
@@ -741,6 +750,17 @@ static inline int __osd_xattr_set(struct osd_thread_info *info,
        return ll_vfs_setxattr(dentry, inode, name, buf, buflen, fl);
 }
 
+static inline char *osd_oid_name(char *name, size_t name_size,
+                                const struct lu_fid *fid, u64 id)
+{
+       snprintf(name, name_size,
+                (fid_seq_is_rsvd(fid_seq(fid)) ||
+                 fid_seq_is_mdt0(fid_seq(fid)) ||
+                 fid_seq_is_idif(fid_seq(fid))) ? "%llu" : "%llx", id);
+
+       return name;
+}
+
 #ifdef CONFIG_PROC_FS
 /* osd_lproc.c */
 extern struct lprocfs_vars lprocfs_osd_obd_vars[];
@@ -761,12 +781,19 @@ 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, __u32 compat, __u32 incompat);
+struct osd_obj_seq *osd_seq_load(struct osd_thread_info *info,
+                                struct osd_device *osd, u64 seq);
 int osd_get_lma(struct osd_thread_info *info, struct inode *inode,
                struct dentry *dentry, struct lustre_ost_attrs *loa);
 void osd_add_oi_cache(struct osd_thread_info *info, struct osd_device *osd,
                      struct osd_inode_id *id, const struct lu_fid *fid);
 int osd_get_idif(struct osd_thread_info *info, struct inode *inode,
                 struct dentry *dentry, struct lu_fid *fid);
+struct osd_it_ea *osd_it_dir_init(const struct lu_env *env, struct inode *inode,
+                                 __u32 attr);
+void osd_it_dir_fini(const struct lu_env *env, struct osd_it_ea *oie,
+                    struct inode *inode);
+int osd_ldiskfs_it_fill(const struct lu_env *env, const struct dt_it *di);
 
 int osd_obj_map_init(const struct lu_env *env, struct osd_device *osd);
 void osd_obj_map_fini(struct osd_device *dev);
@@ -792,15 +819,19 @@ int osd_obj_spec_insert(struct osd_thread_info *info, struct osd_device *osd,
 int osd_obj_spec_update(struct osd_thread_info *info, struct osd_device *osd,
                        const struct lu_fid *fid, const struct osd_inode_id *id,
                        handle_t *th);
+int osd_obj_del_entry(struct osd_thread_info *info, struct osd_device *osd,
+                     struct dentry *dird, char *name, int namelen,
+                     handle_t *th);
 
 char *osd_lf_fid2name(const struct lu_fid *fid);
 int osd_scrub_start(const struct lu_env *env, struct osd_device *dev,
                    __u32 flags);
 void osd_scrub_stop(struct osd_device *dev);
-int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev);
+int osd_scrub_setup(const struct lu_env *env, struct osd_device *dev,
+                   bool restored);
 void osd_scrub_cleanup(const struct lu_env *env, struct osd_device *dev);
-int osd_oii_insert(struct osd_device *dev, struct osd_idmap_cache *oic,
-                  int insert);
+int osd_oii_insert(struct osd_device *dev, const struct lu_fid *fid,
+                  struct osd_inode_id *id, int insert);
 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);
@@ -827,6 +858,13 @@ int osd_lookup_in_remote_parent(struct osd_thread_info *oti,
 
 int osd_ost_seq_exists(struct osd_thread_info *info, struct osd_device *osd,
                       __u64 seq);
+int osd_scrub_refresh_mapping(struct osd_thread_info *info,
+                             struct osd_device *dev,
+                             const struct lu_fid *fid,
+                             const struct osd_inode_id *id,
+                             int ops, bool force,
+                             enum oi_check_flags flags, bool *exist);
+
 /* 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,
@@ -1067,7 +1105,7 @@ static inline void osd_object_put(const struct lu_env *env,
 
 static inline int osd_object_is_root(const struct osd_object *obj)
 {
-        return osd_sb(osd_obj2dev(obj))->s_root->d_inode == obj->oo_inode;
+       return obj->oo_inode && is_root_inode(obj->oo_inode);
 }
 
 static inline struct osd_object *osd_obj(const struct lu_object *o)
@@ -1513,6 +1551,12 @@ osd_index_backup(const struct lu_env *env, struct osd_device *osd, bool backup)
 # define ldiskfs_has_feature_dirdata(sb) \
        LDISKFS_HAS_INCOMPAT_FEATURE(sb, LDISKFS_FEATURE_INCOMPAT_DIRDATA)
 # endif
+# ifdef LDISKFS_FEATURE_INCOMPAT_LARGEDIR
+# define ldiskfs_has_feature_largedir(sb) \
+       LDISKFS_HAS_INCOMPAT_FEATURE(sb, LDISKFS_FEATURE_INCOMPAT_LARGEDIR)
+# define ldiskfs_set_feature_largedir(sb) \
+       LDISKFS_SET_INCOMPAT_FEATURE(sb, LDISKFS_FEATURE_INCOMPAT_LARGEDIR)
+# endif
 # ifdef LDISKFS_FEATURE_COMPAT_HAS_JOURNAL
 # define ldiskfs_has_feature_journal(sb) \
        LDISKFS_HAS_COMPAT_FEATURE(sb, LDISKFS_FEATURE_COMPAT_HAS_JOURNAL)
@@ -1531,7 +1575,7 @@ osd_index_backup(const struct lu_env *env, struct osd_device *osd, bool backup)
 int osd_trunc_lock(struct osd_object *obj, struct osd_thandle *oh,
                   bool shared);
 void osd_trunc_unlock_all(const struct lu_env *env, struct list_head *list);
-void osd_process_truncates(struct list_head *list);
+void osd_process_truncates(const struct lu_env *env, struct list_head *list);
 void osd_execute_truncate(struct osd_object *obj);
 
 #ifdef HAVE_BIO_ENDIO_USES_ONE_ARG
@@ -1597,4 +1641,12 @@ static inline bool bio_integrity_prep_fn(struct bio *bio,
 #define osd_bio_nr_segs(bio)           bio_segments((bio))
 #endif /* HAVE_BIO_BI_PHYS_SEGMENTS */
 
+#ifdef HAVE_GET_INODE_USAGE
+#define lock_dquot_transfer(inode) down_read(&LDISKFS_I(inode)->xattr_sem)
+#define unlock_dquot_transfer(inode) up_read(&LDISKFS_I(inode)->xattr_sem)
+#else
+#define lock_dquot_transfer(inode) do {} while (0)
+#define unlock_dquot_transfer(inode) do {} while (0)
+#endif
+
 #endif /* _OSD_INTERNAL_H */