OBD_INCOMPAT_COMMON_LR)
#define OFD_MAX_GROUPS 256
+/* per-client-per-object persistent state (LRU) */
+struct ofd_mod_data {
+ cfs_list_t fmd_list; /* linked to fed_mod_list */
+ struct lu_fid fmd_fid; /* FID being written to */
+ __u64 fmd_mactime_xid; /* xid highest {m,a,c}time setattr */
+ cfs_time_t fmd_expire; /* time when the fmd should expire */
+ int fmd_refcount; /* reference counter - list holds 1 */
+};
+
+#define OFD_FMD_MAX_NUM_DEFAULT 128
+#define OFD_FMD_MAX_AGE_DEFAULT ((obd_timeout + 10) * CFS_HZ)
+
+enum {
+ LPROC_OFD_READ_BYTES = 0,
+ LPROC_OFD_WRITE_BYTES = 1,
+ LPROC_OFD_LAST,
+};
+
struct ofd_device {
struct dt_device ofd_dt_dev;
struct dt_device *ofd_osd;
struct dt_object *ofd_lastid_obj[OFD_MAX_GROUPS];
cfs_spinlock_t ofd_objid_lock;
+ /* protect all statfs-related counters */
+ cfs_spinlock_t ofd_osfs_lock;
+ /* statfs optimization: we cache a bit */
+ struct obd_statfs ofd_osfs;
+ __u64 ofd_osfs_age;
+ int ofd_blockbits;
+ /* writes which might be be accounted twice in ofd_osfs.os_bavail */
+ obd_size ofd_osfs_unstable;
+
+ /* counters used during statfs update, protected by ofd_osfs_lock.
+ * record when some statfs refresh are in progress */
+ int ofd_statfs_inflight;
+ /* track writes completed while statfs refresh is underway.
+ * tracking is only effective when ofd_statfs_inflight > 1 */
+ obd_size ofd_osfs_inflight;
+
+ /* grants: all values in bytes */
+ /* grant lock to protect all grant counters */
+ cfs_spinlock_t ofd_grant_lock;
+ /* total amount of dirty data reported by clients in incoming obdo */
+ obd_size ofd_tot_dirty;
+ /* sum of filesystem space granted to clients for async writes */
+ obd_size ofd_tot_granted;
+ /* grant used by I/Os in progress (between prepare and commit) */
+ obd_size ofd_tot_pending;
+ /* free space threshold over which we stop granting space to clients
+ * ofd_grant_ratio is stored as a fixed-point fraction using
+ * OFD_GRANT_RATIO_SHIFT of the remaining free space, not in percentage
+ * values */
+ int ofd_grant_ratio;
+ /* number of clients using grants */
+ int ofd_tot_granted_clients;
+
+ /* ofd mod data: ofd_device wide values */
+ int ofd_fmd_max_num; /* per ofd ofd_mod_data */
+ cfs_duration_t ofd_fmd_max_age; /* time to fmd expiry */
+
+ cfs_spinlock_t ofd_flags_lock;
+ unsigned long ofd_raid_degraded:1,
+ /* sync journal on writes */
+ ofd_syncjournal:1,
+ /* sync on lock cancel */
+ ofd_sync_lock_cancel:2,
+ /* shall we grant space to clients not
+ * supporting OBD_CONNECT_GRANT_PARAM? */
+ ofd_grant_compat_disable:1;
+
struct lu_site ofd_site;
};
struct dt_object_format fti_dof;
struct lu_buf fti_buf;
loff_t fti_off;
-};
-static inline int ofd_export_stats_init(struct ofd_device *ofd,
- struct obd_export *exp, void *data)
-{
- return 0;
-}
+ /* Space used by the I/O, used by grant code */
+ unsigned long fti_used;
+};
extern void target_recovery_fini(struct obd_device *obd);
extern void target_recovery_init(struct lu_target *lut, svc_handler_t handler);
/* ofd_obd.c */
extern struct obd_ops ofd_obd_ops;
+int ofd_statfs_internal(const struct lu_env *env, struct ofd_device *ofd,
+ struct obd_statfs *osfs, __u64 max_age,
+ int *from_cache);
/* ofd_fs.c */
obd_id ofd_last_id(struct ofd_device *ofd, obd_seq seq);
/* lproc_ofd.c */
void lprocfs_ofd_init_vars(struct lprocfs_static_vars *lvars);
+int lproc_ofd_attach_seqstat(struct obd_device *dev);
+extern struct file_operations ofd_per_nid_stats_fops;
+
+/* ofd_grants.c */
+#define OFD_GRANT_RATIO_SHIFT 8
+static inline __u64 ofd_grant_reserved(struct ofd_device *ofd, obd_size bavail)
+{
+ return (bavail * ofd->ofd_grant_ratio) >> OFD_GRANT_RATIO_SHIFT;
+}
+
+static inline int ofd_grant_ratio_conv(int percentage)
+{
+ return (percentage << OFD_GRANT_RATIO_SHIFT) / 100;
+}
+
+static inline int ofd_grant_param_supp(struct obd_export *exp)
+{
+ return !!(exp->exp_connect_flags & OBD_CONNECT_GRANT_PARAM);
+}
+
+/* Blocksize used for client not supporting OBD_CONNECT_GRANT_PARAM.
+ * That's 4KB=2^12 which is the biggest block size known to work whatever
+ * the client's page size is. */
+#define COMPAT_BSIZE_SHIFT 12
+static inline int ofd_grant_compat(struct obd_export *exp,
+ struct ofd_device *ofd)
+{
+ /* Clients which don't support OBD_CONNECT_GRANT_PARAM cannot handle
+ * a block size > page size and consume CFS_PAGE_SIZE of grant when
+ * dirtying a page regardless of the block size */
+ return !!(ofd_obd(ofd)->obd_self_export != exp &&
+ ofd->ofd_blockbits > COMPAT_BSIZE_SHIFT &&
+ !ofd_grant_param_supp(exp));
+}
+
+static inline int ofd_grant_prohibit(struct obd_export *exp,
+ struct ofd_device *ofd)
+{
+ /* When ofd_grant_compat_disable is set, we don't grant any space to
+ * clients not supporting OBD_CONNECT_GRANT_PARAM.
+ * Otherwise, space granted to such a client is inflated since it
+ * consumes CFS_PAGE_SIZE of grant space per block */
+ return !!(ofd_grant_compat(exp, ofd) && ofd->ofd_grant_compat_disable);
+}
+
+void ofd_grant_sanity_check(struct obd_device *obd, const char *func);
+long ofd_grant_connect(const struct lu_env *env, struct obd_export *exp,
+ obd_size want);
+void ofd_grant_discard(struct obd_export *exp);
+void ofd_grant_prepare_read(const struct lu_env *env, struct obd_export *exp,
+ struct obdo *oa);
+void ofd_grant_prepare_write(const struct lu_env *env, struct obd_export *exp,
+ struct obdo *oa, struct niobuf_remote *rnb,
+ int niocount);
+void ofd_grant_commit(const struct lu_env *env, struct obd_export *exp, int rc);
+int ofd_grant_create(const struct lu_env *env, struct obd_export *exp, int *nr);
+
+/* ofd_fmd.c */
+int ofd_fmd_init(void);
+void ofd_fmd_exit(void);
+struct ofd_mod_data *ofd_fmd_find(struct obd_export *exp,
+ struct lu_fid *fid);
+struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp,
+ struct lu_fid *fid);
+void ofd_fmd_put(struct obd_export *exp, struct ofd_mod_data *fmd);
+void ofd_fmd_expire(struct obd_export *exp);
+void ofd_fmd_cleanup(struct obd_export *exp);
+#ifdef DO_FMD_DROP
+void ofd_fmd_drop(struct obd_export *exp, struct lu_fid *fid);
+#else
+#define ofd_fmd_drop(exp, fid) do {} while (0)
+#endif
static inline struct ofd_thread_info * ofd_info(const struct lu_env *env)
{
return info;
}
+/* sync on lock cancel is useless when we force a journal flush,
+ * and if we enable async journal commit, we should also turn on
+ * sync on lock cancel if it is not enabled already. */
+static inline void ofd_slc_set(struct ofd_device *ofd)
+{
+ if (ofd->ofd_syncjournal == 1)
+ ofd->ofd_sync_lock_cancel = NEVER_SYNC_ON_CANCEL;
+ else if (ofd->ofd_sync_lock_cancel == NEVER_SYNC_ON_CANCEL)
+ ofd->ofd_sync_lock_cancel = ALWAYS_SYNC_ON_CANCEL;
+}
+
+/* niobuf_local has no rnb_ prefix in master */
+#define rnb_offset offset
+#define rnb_flags flags
+#define rnb_len len
+
#endif /* _OFD_INTERNAL_H */