#define FSFILT_OP_LINK 9
#define FSFILT_OP_CANCEL_UNLINK 10
-struct obd_handle {
- void *orh_filt_handle;
- int orh_reserve;
-};
-
-/* very similar to obd_statfs(), but caller already holds obd_osfs_lock */
-static inline int fsfilt_statfs(struct obd_device *obd, struct super_block *sb,
- unsigned long max_age)
-{
- int rc = 0;
-
- CDEBUG(D_SUPER, "osfs %lu, max_age %lu\n", obd->obd_osfs_age, max_age);
- if (time_before(obd->obd_osfs_age, max_age)) {
- rc = obd->obd_fsops->fs_statfs(sb, &obd->obd_osfs);
- if (rc == 0) /* N.B. statfs can't really fail */
- obd->obd_osfs_age = jiffies;
- } else {
- CDEBUG(D_SUPER, "using cached obd_statfs data\n");
- }
-
- return rc;
-}
-
-static inline int fsfilt_reserve(struct obd_device *obd, struct super_block *sb,
- int reserve, struct obd_handle **h)
-{
- struct obd_handle *handle;
-
- OBD_ALLOC(handle, sizeof(*handle));
- if (!handle)
- return -ENOMEM;
-
- /* Perform space reservation if needed */
- if (reserve) {
- spin_lock(&obd->obd_osfs_lock);
- obd->obd_reserve_freespace_estimated -= reserve;
- if (obd->obd_reserve_freespace_estimated < 0) {
- int rc = fsfilt_statfs(obd, sb, jiffies - 1);
- if (rc) {
- CERROR("statfs failed during reservation\n");
- spin_unlock(&obd->obd_osfs_lock);
- OBD_FREE(handle, sizeof(*handle));
- return rc;
- }
- /* Some filesystems (e.g. reiserfs) report more space
- * available compared to what is really available
- * (reiserfs reserves 1996K for itself).
- */
- obd->obd_reserve_freespace_estimated =
- obd->obd_osfs.os_bfree-obd->obd_reserve_space;
- if (obd->obd_reserve_freespace_estimated < reserve) {
- spin_unlock(&obd->obd_osfs_lock);
- OBD_FREE(handle, sizeof(*handle));
- return -ENOSPC;
- }
- obd->obd_reserve_freespace_estimated -= reserve;
- }
- obd->obd_reserve_space += reserve;
- handle->orh_reserve = reserve;
- spin_unlock(&obd->obd_osfs_lock);
- }
- *h = handle;
- return 0;
-}
-
-static inline void fsfilt_release(struct obd_device *obd,
- struct obd_handle *handle)
-{
- struct obd_handle *h = handle;
-
- spin_lock(&obd->obd_osfs_lock);
- obd->obd_reserve_space -= h->orh_reserve;
- LASSERT(obd->obd_reserve_space >= 0);
- spin_unlock(&obd->obd_osfs_lock);
-
- OBD_FREE(h, sizeof(*h));
-}
-
static inline void *fsfilt_start_log(struct obd_device *obd,
struct inode *inode, int op,
struct obd_trans_info *oti, int logs)
{
unsigned long now = jiffies;
- struct obd_handle *parent_handle = oti ? oti->oti_handle : NULL, *h;
- int reserve = 0;
- int rc;
-
- if (obd->obd_fsops->fs_get_op_len)
- reserve = obd->obd_fsops->fs_get_op_len(op, NULL, logs);
-
- rc = fsfilt_reserve(obd, inode->i_sb, reserve, &h);
- if (rc)
- return ERR_PTR(rc);
-
- h->orh_filt_handle = obd->obd_fsops->fs_start(inode, op, parent_handle,
- logs);
- CDEBUG(D_HA, "started handle %p (%p)\n", h->orh_filt_handle,
- parent_handle);
- if (IS_ERR(h->orh_filt_handle)) {
- rc = PTR_ERR(h->orh_filt_handle);
- fsfilt_release(obd, h);
- RETURN(ERR_PTR(rc));
- }
+ void *parent_handle = oti ? oti->oti_handle : NULL;
+ void *handle = obd->obd_fsops->fs_start(inode, op, parent_handle, logs);
+ CDEBUG(D_HA, "started handle %p (%p)\n", handle, parent_handle);
if (oti != NULL) {
if (parent_handle == NULL) {
- oti->oti_handle = h;
- } else if (h->orh_filt_handle != parent_handle) {
+ oti->oti_handle = handle;
+ } else if (handle != parent_handle) {
CERROR("mismatch: parent %p, handle %p, oti %p\n",
- parent_handle->orh_filt_handle,
- h->orh_filt_handle, oti);
+ parent_handle, handle, oti);
LBUG();
}
}
if (time_after(jiffies, now + 15 * HZ))
CERROR("long journal start time %lus\n", (jiffies - now) / HZ);
- return h;
+ return handle;
}
-static inline void *fsfilt_start(struct obd_device *obd,
- struct inode *inode, int op,
- struct obd_trans_info *oti)
+static inline void *fsfilt_start(struct obd_device *obd, struct inode *inode,
+ int op, struct obd_trans_info *oti)
{
return fsfilt_start_log(obd, inode, op, oti, 0);
}
struct obd_trans_info *oti, int logs)
{
unsigned long now = jiffies;
- struct obd_handle *parent_handle = oti ? oti->oti_handle : NULL, *h;
- int reserve = 0;
- int rc;
-
- if (obd->obd_fsops->fs_get_op_len)
- reserve = obd->obd_fsops->fs_get_op_len(objcount, fso, logs);
-
- rc = fsfilt_reserve(obd, fso->fso_dentry->d_inode->i_sb, reserve, &h);
- if (rc)
- return ERR_PTR(rc);
-
- h->orh_filt_handle = obd->obd_fsops->fs_brw_start(objcount, fso,
- niocount, nb,
- parent_handle, logs);
- CDEBUG(D_HA, "started handle %p (%p)\n", h->orh_filt_handle,
- parent_handle);
+ void *parent_handle = oti ? oti->oti_handle : NULL;
+ void *handle = obd->obd_fsops->fs_brw_start(objcount, fso, niocount, nb,
+ parent_handle, logs);
+ CDEBUG(D_HA, "started handle %p (%p)\n", handle, parent_handle);
if (oti != NULL) {
if (parent_handle == NULL) {
- oti->oti_handle = h;
- } else if (h->orh_filt_handle !=
- parent_handle->orh_filt_handle) {
+ oti->oti_handle = handle;
+ } else if (handle != parent_handle) {
CERROR("mismatch: parent %p, handle %p, oti %p\n",
- parent_handle->orh_filt_handle,
- h->orh_filt_handle, oti);
+ parent_handle, handle, oti);
LBUG();
}
}
if (time_after(jiffies, now + 15 * HZ))
CERROR("long journal start time %lus\n", (jiffies - now) / HZ);
- return h;
+ return handle;
}
static inline void *fsfilt_brw_start(struct obd_device *obd, int objcount,
void *handle, int force_sync)
{
unsigned long now = jiffies;
- struct obd_handle *h = handle;
- int rc;
-
- rc = obd->obd_fsops->fs_commit(inode, h->orh_filt_handle, force_sync);
- CDEBUG(D_HA, "committing handle %p\n", h->orh_filt_handle);
+ int rc = obd->obd_fsops->fs_commit(inode, handle, force_sync);
+ CDEBUG(D_HA, "committing handle %p\n", handle);
if (time_after(jiffies, now + 15 * HZ))
CERROR("long journal start time %lus\n", (jiffies - now) / HZ);
- fsfilt_release(obd, h);
-
return rc;
}
void **wait_handle)
{
unsigned long now = jiffies;
- struct obd_handle *h = handle;
- int rc;
-
- rc = obd->obd_fsops->fs_commit_async(inode, h->orh_filt_handle,
- wait_handle);
+ int rc = obd->obd_fsops->fs_commit_async(inode, handle, wait_handle);
CDEBUG(D_HA, "committing handle %p (async)\n", *wait_handle);
if (time_after(jiffies, now + 15 * HZ))
CERROR("long journal start time %lus\n", (jiffies - now) / HZ);
- fsfilt_release(obd, h);
-
return rc;
}
void *handle, struct iattr *iattr,int do_trunc)
{
unsigned long now = jiffies;
- struct obd_handle *h = handle;
int rc;
- rc = obd->obd_fsops->fs_setattr(dentry, h->orh_filt_handle, iattr, do_trunc);
+ rc = obd->obd_fsops->fs_setattr(dentry, handle, iattr, do_trunc);
if (time_after(jiffies, now + 15 * HZ))
CERROR("long setattr time %lus\n", (jiffies - now) / HZ);
return rc;
static inline int fsfilt_set_md(struct obd_device *obd, struct inode *inode,
void *handle, void *md, int size)
{
- struct obd_handle *h = handle;
- return obd->obd_fsops->fs_set_md(inode, h->orh_filt_handle, md, size);
+ return obd->obd_fsops->fs_set_md(inode, handle, md, size);
}
static inline int fsfilt_get_md(struct obd_device *obd, struct inode *inode,
void *handle, fsfilt_cb_t cb_func,
void *cb_data)
{
- struct obd_handle *h = handle;
return obd->obd_fsops->fs_add_journal_cb(obd, last_rcvd,
- h->orh_filt_handle, cb_func,
- cb_data);
+ handle, cb_func, cb_data);
+}
+
+/* very similar to obd_statfs(), but caller already holds obd_osfs_lock */
+static inline int fsfilt_statfs(struct obd_device *obd, struct super_block *sb,
+ unsigned long max_age)
+{
+ int rc = 0;
+
+ CDEBUG(D_SUPER, "osfs %lu, max_age %lu\n", obd->obd_osfs_age, max_age);
+ if (time_before(obd->obd_osfs_age, max_age)) {
+ rc = obd->obd_fsops->fs_statfs(sb, &obd->obd_osfs);
+ if (rc == 0) /* N.B. statfs can't really fail */
+ obd->obd_osfs_age = jiffies;
+ } else {
+ CDEBUG(D_SUPER, "using cached obd_statfs data\n");
+ }
+
+ return rc;
}
static inline int fsfilt_sync(struct obd_device *obd, struct super_block *sb)