From: adilger Date: Wed, 17 Mar 2004 11:46:23 +0000 (+0000) Subject: Revert the reservation part of the bug 2059 changes. This seems to have X-Git-Tag: v1_8_0_110~486^6~75 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=df72f03280a4cd2738cf7dfc86f05921e673fcc8;p=fs%2Flustre-release.git Revert the reservation part of the bug 2059 changes. This seems to have been causing problems on the OSTs and wasn't the primary reason for applying this patch to 1.2. b=2059 --- diff --git a/lustre/include/linux/lustre_fsfilt.h b/lustre/include/linux/lustre_fsfilt.h index 6fd4527..40e9914 100644 --- a/lustre/include/linux/lustre_fsfilt.h +++ b/lustre/include/linux/lustre_fsfilt.h @@ -93,128 +93,31 @@ extern void fsfilt_put_ops(struct fsfilt_operations *fs_ops); #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); } @@ -226,38 +129,24 @@ static inline void *fsfilt_brw_start_log(struct obd_device *obd, 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, @@ -272,17 +161,12 @@ static inline int fsfilt_commit(struct obd_device *obd, struct inode *inode, 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; } @@ -291,18 +175,12 @@ static inline int fsfilt_commit_async(struct obd_device *obd, 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; } @@ -321,9 +199,8 @@ static inline int fsfilt_setattr(struct obd_device *obd, struct dentry *dentry, 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; @@ -339,8 +216,7 @@ static inline int fsfilt_iocontrol(struct obd_device *obd, struct inode *inode, 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, @@ -360,10 +236,26 @@ static inline int fsfilt_add_journal_cb(struct obd_device *obd, __u64 last_rcvd, 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) diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index 561bfe4..d25ca30 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -518,14 +518,6 @@ struct obd_device { struct lprocfs_stats *obd_stats; struct proc_dir_entry *obd_svc_procroot; struct lprocfs_stats *obd_svc_stats; - /* Fields used for fsfilt reservations. */ - int obd_reserve_space; /* protected by obd_osfs_lock */ - /* This field contains cached statfs(2) amount of free blocks, - each time reservation is made, we substract reserved amount from this - field until zero is reached. Then we call statfs(2) again. This - allows to minimize statfs(2) calls on filesystems with lots of free - space. */ - long obd_reserve_freespace_estimated; }; #define OBD_OPT_FORCE 0x0001 diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index 956f8fb..41f2258 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -125,7 +125,6 @@ int class_attach(struct lustre_cfg *lcfg) spin_lock_init(&obd->obd_osfs_lock); obd->obd_osfs_age = jiffies - 1000 * HZ; init_waitqueue_head(&obd->obd_refcount_waitq); - obd->obd_reserve_freespace_estimated = -1; /* XXX belongs in setup not attach */ /* recovery data */ @@ -234,9 +233,6 @@ int class_detach(struct obd_device *obd, struct lustre_cfg *lcfg) CERROR("OBD device %d not attached\n", obd->obd_minor); RETURN(-ENODEV); } - if (obd->obd_reserve_space != 0) - CERROR("Reserved space on class_detach is %d\n", - obd->obd_reserve_space); if (OBP(obd, detach)) err = OBP(obd,detach)(obd); diff --git a/lustre/obdfilter/filter_io.c b/lustre/obdfilter/filter_io.c index 3dce898..b9e6600 100644 --- a/lustre/obdfilter/filter_io.c +++ b/lustre/obdfilter/filter_io.c @@ -151,7 +151,7 @@ static void filter_grant_incoming(struct obd_export *exp, struct obdo *oa) EXIT; } -#define GRANT_FOR_LLOG(obd) (obd->obd_reserve_space) +#define GRANT_FOR_LLOG(obd) 16 /* Figure out how much space is available between what we've granted * and what remains in the filesystem. Compensate for ext3 indirect