Whamcloud - gitweb
LU-13974 llog: check stale osp object
[fs/lustre-release.git] / lustre / include / dt_object.h
index fe778cf..0330989 100644 (file)
@@ -88,6 +88,7 @@ struct dt_device_param {
        unsigned int       ddp_brw_size;        /* optimal RPC size */
        /* T10PI checksum type, zero if not supported */
        enum cksum_types   ddp_t10_cksum_type;
+       bool               ddp_has_lseek_data_hole;
 };
 
 /**
@@ -297,6 +298,17 @@ struct dt_device_operations {
                       struct dt_device *dev);
 
        /**
+        * Wait pending quota update finish
+        *
+        * There might be a window that quota usage has been updated,
+        * but commit callback to reduce pending write have not been
+        * finished, this is used to wait all pending update done.
+        *
+        * \param[in] dev       dt device
+        */
+       void (*dt_wait_quota_pending)(struct dt_device *dev);
+
+       /**
         * Start transaction commit asynchronously.
         *
 
@@ -1051,6 +1063,18 @@ struct dt_object_operations {
        int   (*do_invalidate)(const struct lu_env *env, struct dt_object *dt);
 
        /**
+        * Check object stale state.
+        *
+        * OSP only.
+        *
+        * \param[in] dt        object
+        *
+        * \retval true         for stale object
+        * \retval false        for not stale object
+        */
+       bool (*do_check_stale)(struct dt_object *dt);
+
+       /**
         * Declare intention to instaintiate extended layout component.
         *
         * \param[in] env       execution environment
@@ -1436,8 +1460,8 @@ struct dt_body_operations {
         * \retval negative     negated errno on error
         */
        int (*dbo_declare_fallocate)(const struct lu_env *env,
-                                   struct dt_object *dt,
-                                   struct thandle *th);
+                                   struct dt_object *dt, __u64 start,
+                                   __u64 end, int mode, struct thandle *th);
        /**
         * Allocate specified region for an object
         *
@@ -1457,6 +1481,19 @@ struct dt_body_operations {
                            __u64 end,
                            int mode,
                            struct thandle *th);
+       /**
+        * Do SEEK_HOLE/SEEK_DATA request on object
+        *
+        * \param[in] env       execution environment for this thread
+        * \param[in] dt        object
+        * \param[in] offset    the offset to start seek from
+        * \param[in] whence    seek mode, SEEK_HOLE or SEEK_DATA
+        *
+        * \retval hole/data offset     on success
+        * \retval negative             negated errno on error
+        */
+       loff_t (*dbo_lseek)(const struct lu_env *env, struct dt_object *dt,
+                           loff_t offset, int whence);
 };
 
 /**
@@ -1975,7 +2012,9 @@ struct thandle {
         * including OSTs */
                                th_complex:1,
        /* whether ignore quota */
-                               th_ignore_quota:1;
+                               th_ignore_quota:1,
+       /* whether restart transaction */
+                               th_restart_tran:1;
 };
 
 /**
@@ -2243,7 +2282,8 @@ static inline int dt_declare_record_write(const struct lu_env *env,
 
        LASSERTF(dt != NULL, "dt is NULL when we want to write record\n");
        LASSERT(th != NULL);
-       LASSERT(dt->do_body_ops);
+       LASSERTF(dt->do_body_ops, DFID" doesn't exit\n",
+                PFID(lu_object_fid(&dt->do_lu)));
        LASSERT(dt->do_body_ops->dbo_declare_write);
        rc = dt->do_body_ops->dbo_declare_write(env, dt, buf, pos, th);
        return rc;
@@ -2358,6 +2398,15 @@ static inline int dt_write_locked(const struct lu_env *env,
         return dt->do_ops->do_write_locked(env, dt);
 }
 
+static inline bool dt_object_stale(struct dt_object *dt)
+{
+       LASSERT(dt);
+       LASSERT(dt->do_ops);
+       LASSERT(dt->do_ops->do_check_stale);
+
+       return dt->do_ops->do_check_stale(dt);
+}
+
 static inline int dt_declare_attr_get(const struct lu_env *env,
                                      struct dt_object *dt)
 {
@@ -2573,15 +2622,17 @@ static inline int dt_ladvise(const struct lu_env *env, struct dt_object *dt,
        return dt->do_body_ops->dbo_ladvise(env, dt, start, end, advice);
 }
 
-static inline int dt_declare_falloc(const struct lu_env *env,
-                                     struct dt_object *dt, struct thandle *th)
+static inline int dt_declare_fallocate(const struct lu_env *env,
+                                      struct dt_object *dt, __u64 start,
+                                      __u64 end, int mode, struct thandle *th)
 {
        LASSERT(dt);
        if (!dt->do_body_ops)
                return -EOPNOTSUPP;
        LASSERT(dt->do_body_ops);
        LASSERT(dt->do_body_ops->dbo_declare_fallocate);
-       return dt->do_body_ops->dbo_declare_fallocate(env, dt, th);
+       return dt->do_body_ops->dbo_declare_fallocate(env, dt, start, end,
+                                                     mode, th);
 }
 
 static inline int dt_falloc(const struct lu_env *env, struct dt_object *dt,
@@ -2607,6 +2658,17 @@ static inline int dt_fiemap_get(const struct lu_env *env, struct dt_object *d,
         return d->do_body_ops->dbo_fiemap_get(env, d, fm);
 }
 
+static inline loff_t dt_lseek(const struct lu_env *env, struct dt_object *d,
+                             loff_t offset, int whence)
+{
+       LASSERT(d);
+       if (d->do_body_ops == NULL)
+               return -EPROTO;
+       if (d->do_body_ops->dbo_lseek == NULL)
+               return -EOPNOTSUPP;
+       return d->do_body_ops->dbo_lseek(env, d, offset, whence);
+}
+
 static inline int dt_statfs_info(const struct lu_env *env,
                                 struct dt_device *dev,
                                struct obd_statfs *osfs,
@@ -2669,6 +2731,14 @@ static inline int dt_ro(const struct lu_env *env, struct dt_device *dev)
         return dev->dd_ops->dt_ro(env, dev);
 }
 
+static inline void dt_wait_quota_pending(struct dt_device *dev)
+{
+       LASSERT(dev);
+       LASSERT(dev->dd_ops);
+       if (dev->dd_ops->dt_wait_quota_pending)
+               dev->dd_ops->dt_wait_quota_pending(dev);
+}
+
 static inline int dt_declare_insert(const struct lu_env *env,
                                     struct dt_object *dt,
                                     const struct dt_rec *rec,