Whamcloud - gitweb
LU-9728 osd: use GFP_HIGHUSER for non-local IO
[fs/lustre-release.git] / lustre / include / dt_object.h
index dd3f40b..436139f 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -27,7 +23,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2011, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -75,20 +71,20 @@ typedef enum {
 } mntopt_t;
 
 struct dt_device_param {
-        unsigned           ddp_max_name_len;
-        unsigned           ddp_max_nlink;
-        unsigned           ddp_block_shift;
-        mntopt_t           ddp_mntopts;
-        unsigned           ddp_max_ea_size;
-        int                ddp_mount_type;
-        unsigned long long ddp_maxbytes;
-        /* percentage of available space to reserve for grant error margin */
-        int                ddp_grant_reserved;
-        /* per-inode space consumption */
-        short              ddp_inodespace;
-        /* per-fragment grant overhead to be used by client for grant
-         * calculation */
-        int                ddp_grant_frag;
+       unsigned           ddp_max_name_len;
+       unsigned           ddp_max_nlink;
+       unsigned           ddp_symlink_max;
+       mntopt_t           ddp_mntopts;
+       unsigned           ddp_max_ea_size;
+       unsigned           ddp_mount_type;
+       unsigned long long ddp_maxbytes;
+       /* per-inode space consumption */
+       short              ddp_inodespace;
+       /* maximum number of blocks in an extent */
+       unsigned           ddp_max_extent_blks;
+       /* per-extent insertion overhead to be used by client for grant
+        * calculation */
+       unsigned           ddp_extent_tax;
 };
 
 /**
@@ -346,8 +342,9 @@ enum dt_index_flags {
  */
 extern const struct dt_index_features dt_directory_features;
 extern const struct dt_index_features dt_otable_features;
-extern const struct dt_index_features dt_lfsck_orphan_features;
-extern const struct dt_index_features dt_lfsck_features;
+extern const struct dt_index_features dt_lfsck_layout_orphan_features;
+extern const struct dt_index_features dt_lfsck_layout_dangling_features;
+extern const struct dt_index_features dt_lfsck_namespace_features;
 
 /* index features supported by the accounting objects */
 extern const struct dt_index_features dt_acct_features;
@@ -358,6 +355,9 @@ extern const struct dt_index_features dt_quota_glb_features;
 /* index features supported by the quota slave indexes */
 extern const struct dt_index_features dt_quota_slv_features;
 
+/* index features supported by the nodemap index */
+extern const struct dt_index_features dt_nodemap_features;
+
 /**
  * This is a general purpose dt allocation hint.
  * It now contains the parent object.
@@ -966,10 +966,8 @@ struct dt_object_operations {
         * \retval 0            on success
         * \retval negative     negated errno on error
         */
-       int (*do_object_sync)(const struct lu_env *env,
-                             struct dt_object *obj,
-                             __u64 start,
-                             __u64 end);
+       int (*do_object_sync)(const struct lu_env *env, struct dt_object *obj,
+                             __u64 start, __u64 end);
 
        /**
         * Lock object.
@@ -1012,6 +1010,61 @@ struct dt_object_operations {
                                struct dt_object *dt,
                                struct ldlm_enqueue_info *einfo,
                                union ldlm_policy_data *policy);
+
+       /**
+        * Invalidate attribute cache.
+        *
+        * This method invalidate attribute cache of the object, which is on OSP
+        * only.
+        *
+        * \param[in] env       execution envionment for this thread
+        * \param[in] dt        object
+        *
+        * \retval 0            on success
+        * \retval negative     negated errno on error
+        */
+       int   (*do_invalidate)(const struct lu_env *env, struct dt_object *dt);
+
+       /**
+        * Declare intention to instaintiate extended layout component.
+        *
+        * \param[in] env       execution environment
+        * \param[in] dt        DT object
+        * \param[in] layout    data structure to describe the changes to
+        *                      the DT object's layout
+        * \param[in] buf       buffer containing client's lovea or empty
+        *
+        * \retval 0            success
+        * \retval -ne          error code
+        */
+       int (*do_declare_layout_change)(const struct lu_env *env,
+                                       struct dt_object *dt,
+                                       struct layout_intent *layout,
+                                       const struct lu_buf *buf,
+                                       struct thandle *th);
+
+       /**
+        * Client is trying to write to un-instantiated layout component.
+        *
+        * \param[in] env       execution environment
+        * \param[in] dt        DT object
+        * \param[in] layout    data structure to describe the changes to
+        *                      the DT object's layout
+        * \param[in] buf       buffer containing client's lovea or empty
+        *
+        * \retval 0            success
+        * \retval -ne          error code
+        */
+       int (*do_layout_change)(const struct lu_env *env, struct dt_object *dt,
+                               struct layout_intent *layout,
+                               const struct lu_buf *buf, struct thandle *th);
+};
+
+enum dt_bufs_type {
+       DT_BUFS_TYPE_READ       = 0x0000,
+       DT_BUFS_TYPE_WRITE      = 0x0001,
+       DT_BUFS_TYPE_READAHEAD  = 0x0002,
+       DT_BUFS_TYPE_LOCAL      = 0x0004,
 };
 
 /**
@@ -1131,7 +1184,7 @@ struct dt_body_operations {
                            loff_t pos,
                            ssize_t len,
                            struct niobuf_local *lb,
-                           int rw);
+                           enum dt_bufs_type rw);
 
        /**
         * Release reference granted by ->dbo_bufs_get().
@@ -1315,6 +1368,27 @@ struct dt_body_operations {
                           __u64 start,
                           __u64 end,
                           struct thandle *th);
+       /**
+        * Give advices on specified region in an object.
+        *
+        * This method is used to give advices about access pattern on an
+        * given region of the object. The disk filesystem understands
+        * the advices and tunes cache/read-ahead policies.
+        *
+        * \param[in] env       execution environment for this thread
+        * \param[in] dt        object
+        * \param[in] start     the start of the region affected
+        * \param[in] end       the end of the region affected
+        * \param[in] advice    advice type
+        *
+        * \retval 0            on success
+        * \retval negative     negated errno on error
+        */
+       int   (*dbo_ladvise)(const struct lu_env *env,
+                            struct dt_object *dt,
+                            __u64 start,
+                            __u64 end,
+                            enum lu_ladvise_type advice);
 };
 
 /**
@@ -1705,7 +1779,8 @@ struct dt_device {
          * single-threaded start-up shut-down procedures.
          */
        struct list_head                   dd_txn_callbacks;
-       unsigned int                       dd_record_fid_accessed:1;
+       unsigned int                       dd_record_fid_accessed:1,
+                                          dd_rdonly:1;
 };
 
 int  dt_device_init(struct dt_device *dev, struct lu_device_type *t);
@@ -1824,8 +1899,12 @@ struct thandle {
        unsigned int            th_sync:1,
        /* local transation, no need to inform other layers */
                                th_local:1,
-       /* Whether we need wait the transaction to be submitted */
-                               th_wait_submit:1;
+       /* Whether we need wait the transaction to be submitted
+        * (send to remote target) */
+                               th_wait_submit:1,
+       /* complex transaction which will track updates on all targets,
+        * including OSTs */
+                               th_complex:1;
 };
 
 /**
@@ -1916,6 +1995,18 @@ dt_object_locate(struct dt_object *dto, struct dt_device *dt_dev)
        return NULL;
 }
 
+static inline void dt_object_put(const struct lu_env *env,
+                                struct dt_object *dto)
+{
+       lu_object_put(env, &dto->do_lu);
+}
+
+static inline void dt_object_put_nocache(const struct lu_env *env,
+                                        struct dt_object *dto)
+{
+       lu_object_put_nocache(env, &dto->do_lu);
+}
+
 int local_oid_storage_init(const struct lu_env *env, struct dt_device *dev,
                           const struct lu_fid *first_fid,
                           struct local_oid_storage **los);
@@ -1935,6 +2026,10 @@ int local_object_create(const struct lu_env *env,
                        struct dt_object *o,
                        struct lu_attr *attr, struct dt_object_format *dof,
                        struct thandle *th);
+struct dt_object *local_file_find(const struct lu_env *env,
+                                 struct local_oid_storage *los,
+                                 struct dt_object *parent,
+                                 const char *name);
 struct dt_object *local_file_find_or_create(const struct lu_env *env,
                                            struct local_oid_storage *los,
                                            struct dt_object *parent,
@@ -2291,7 +2386,7 @@ static inline int dt_ref_del(const struct lu_env *env,
 
 static inline int dt_bufs_get(const struct lu_env *env, struct dt_object *d,
                              struct niobuf_remote *rnb,
-                             struct niobuf_local *lnb, int rw)
+                             struct niobuf_local *lnb, enum dt_bufs_type rw)
 {
        LASSERT(d);
        LASSERT(d->do_body_ops);
@@ -2388,6 +2483,15 @@ static inline int dt_punch(const struct lu_env *env, struct dt_object *dt,
        return dt->do_body_ops->dbo_punch(env, dt, start, end, th);
 }
 
+static inline int dt_ladvise(const struct lu_env *env, struct dt_object *dt,
+                            __u64 start, __u64 end, int advice)
+{
+       LASSERT(dt);
+       LASSERT(dt->do_body_ops);
+       LASSERT(dt->do_body_ops->dbo_ladvise);
+       return dt->do_body_ops->dbo_ladvise(env, dt, start, end, advice);
+}
+
 static inline int dt_fiemap_get(const struct lu_env *env, struct dt_object *d,
                                struct fiemap *fm)
 {
@@ -2577,6 +2681,15 @@ static inline int dt_xattr_list(const struct lu_env *env, struct dt_object *dt,
        return dt->do_ops->do_xattr_list(env, dt, buf);
 }
 
+static inline int dt_invalidate(const struct lu_env *env, struct dt_object *dt)
+{
+       LASSERT(dt);
+       LASSERT(dt->do_ops);
+       LASSERT(dt->do_ops->do_invalidate);
+
+       return dt->do_ops->do_invalidate(env, dt);
+}
+
 static inline int dt_declare_delete(const struct lu_env *env,
                                     struct dt_object *dt,
                                     const struct dt_key *key,
@@ -2638,7 +2751,29 @@ static inline int dt_lookup(const struct lu_env *env,
         return ret;
 }
 
-#define LU221_BAD_TIME (0x80000000U + 24 * 3600)
+static inline int dt_declare_layout_change(const struct lu_env *env,
+                                          struct dt_object *o,
+                                          struct layout_intent *layout,
+                                          const struct lu_buf *buf,
+                                          struct thandle *th)
+{
+       LASSERT(o);
+       LASSERT(o->do_ops);
+       LASSERT(o->do_ops->do_declare_layout_change);
+       return o->do_ops->do_declare_layout_change(env, o, layout, buf, th);
+}
+
+static inline int dt_layout_change(const struct lu_env *env,
+                                  struct dt_object *o,
+                                  struct layout_intent *layout,
+                                  const struct lu_buf *buf,
+                                  struct thandle *th)
+{
+       LASSERT(o);
+       LASSERT(o->do_ops);
+       LASSERT(o->do_ops->do_layout_change);
+       return o->do_ops->do_layout_change(env, o, layout, buf, th);
+}
 
 struct dt_find_hint {
        struct lu_fid        *dfh_fid;