From: adilger Date: Wed, 17 Mar 2004 05:37:49 +0000 (+0000) Subject: Reduce number of credits for an UNLINK op (update quota files at most once). X-Git-Tag: v1_8_0_110~486^6~79 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=be6a6b04f8bc315a6f3cf50305903897b564bda4;p=fs%2Flustre-release.git Reduce number of credits for an UNLINK op (update quota files at most once). Limit our transaction requests to the maximum transaction size regardless. Handle error case in journal start. b=2059 --- diff --git a/lustre/include/linux/lustre_fsfilt.h b/lustre/include/linux/lustre_fsfilt.h index 551f62b..6fd4527 100644 --- a/lustre/include/linux/lustre_fsfilt.h +++ b/lustre/include/linux/lustre_fsfilt.h @@ -93,7 +93,7 @@ extern void fsfilt_put_ops(struct fsfilt_operations *fs_ops); #define FSFILT_OP_LINK 9 #define FSFILT_OP_CANCEL_UNLINK 10 -struct obd_reservation_handle { +struct obd_handle { void *orh_filt_handle; int orh_reserve; }; @@ -117,9 +117,9 @@ static inline int fsfilt_statfs(struct obd_device *obd, struct super_block *sb, } static inline int fsfilt_reserve(struct obd_device *obd, struct super_block *sb, - int reserve, struct obd_reservation_handle **h) + int reserve, struct obd_handle **h) { - struct obd_reservation_handle *handle; + struct obd_handle *handle; OBD_ALLOC(handle, sizeof(*handle)); if (!handle) @@ -158,13 +158,25 @@ static inline int fsfilt_reserve(struct obd_device *obd, struct super_block *sb, 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_reservation_handle *parent_handle = oti?oti->oti_handle:NULL; - struct obd_reservation_handle *h; + struct obd_handle *parent_handle = oti ? oti->oti_handle : NULL, *h; int reserve = 0; int rc; @@ -179,6 +191,11 @@ static inline void *fsfilt_start_log(struct obd_device *obd, 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)); + } if (oti != NULL) { if (parent_handle == NULL) { @@ -206,16 +223,15 @@ static inline void *fsfilt_brw_start_log(struct obd_device *obd, int objcount, struct fsfilt_objinfo *fso, int niocount, struct niobuf_local *nb, - struct obd_trans_info *oti,int numlogs) + struct obd_trans_info *oti, int logs) { unsigned long now = jiffies; - struct obd_reservation_handle *parent_handle = oti?oti->oti_handle:NULL; - struct obd_reservation_handle *h; + 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, numlogs); + 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) @@ -223,7 +239,7 @@ static inline void *fsfilt_brw_start_log(struct obd_device *obd, h->orh_filt_handle = obd->obd_fsops->fs_brw_start(objcount, fso, niocount, nb, - parent_handle, numlogs); + parent_handle, logs); CDEBUG(D_HA, "started handle %p (%p)\n", h->orh_filt_handle, parent_handle); @@ -256,7 +272,7 @@ static inline int fsfilt_commit(struct obd_device *obd, struct inode *inode, void *handle, int force_sync) { unsigned long now = jiffies; - struct obd_reservation_handle *h = handle; + struct obd_handle *h = handle; int rc; rc = obd->obd_fsops->fs_commit(inode, h->orh_filt_handle, force_sync); @@ -265,22 +281,17 @@ static inline int fsfilt_commit(struct obd_device *obd, struct inode *inode, if (time_after(jiffies, now + 15 * HZ)) CERROR("long journal start time %lus\n", (jiffies - now) / HZ); - 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)); + fsfilt_release(obd, h); return rc; } static inline int fsfilt_commit_async(struct obd_device *obd, - struct inode *inode, - void *handle, - void **wait_handle) + struct inode *inode, void *handle, + void **wait_handle) { unsigned long now = jiffies; - struct obd_reservation_handle *h = handle; + struct obd_handle *h = handle; int rc; rc = obd->obd_fsops->fs_commit_async(inode, h->orh_filt_handle, @@ -290,17 +301,13 @@ static inline int fsfilt_commit_async(struct obd_device *obd, if (time_after(jiffies, now + 15 * HZ)) CERROR("long journal start time %lus\n", (jiffies - now) / HZ); - 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)); + fsfilt_release(obd, h); return rc; } -static inline int fsfilt_commit_wait(struct obd_device *obd, struct inode *inode, - void *handle) +static inline int fsfilt_commit_wait(struct obd_device *obd, + struct inode *inode, void *handle) { unsigned long now = jiffies; int rc = obd->obd_fsops->fs_commit_wait(inode, handle); @@ -314,7 +321,7 @@ 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_reservation_handle *h = handle; + struct obd_handle *h = handle; int rc; rc = obd->obd_fsops->fs_setattr(dentry, h->orh_filt_handle, iattr, do_trunc); if (time_after(jiffies, now + 15 * HZ)) @@ -332,7 +339,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_reservation_handle *h = handle; + struct obd_handle *h = handle; return obd->obd_fsops->fs_set_md(inode, h->orh_filt_handle, md, size); } @@ -353,7 +360,7 @@ 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_reservation_handle *h = handle; + struct obd_handle *h = handle; return obd->obd_fsops->fs_add_journal_cb(obd, last_rcvd, h->orh_filt_handle, cb_func, cb_data); diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c index 5c19b0c..224afd4 100644 --- a/lustre/lvfs/fsfilt_ext3.c +++ b/lustre/lvfs/fsfilt_ext3.c @@ -74,7 +74,8 @@ static void *fsfilt_ext3_start(struct inode *inode, int op, void *desc_private, int logs) { /* For updates to the last recieved file */ - int nblocks = EXT3_DATA_TRANS_BLOCKS; + int nblocks = EXT3_SINGLEDATA_TRANS_BLOCKS; + journal_t *journal; void *handle; if (current->journal_info) { @@ -86,21 +87,24 @@ static void *fsfilt_ext3_start(struct inode *inode, int op, void *desc_private, switch(op) { case FSFILT_OP_RMDIR: case FSFILT_OP_UNLINK: + /* delete one file + create/update logs for each stripe */ nblocks += EXT3_DELETE_TRANS_BLOCKS; nblocks += (EXT3_INDEX_EXTRA_TRANS_BLOCKS + - EXT3_DATA_TRANS_BLOCKS) * logs; + EXT3_SINGLEDATA_TRANS_BLOCKS) * logs; break; case FSFILT_OP_RENAME: /* modify additional directory */ - nblocks += EXT3_DATA_TRANS_BLOCKS; + nblocks += EXT3_SINGLEDATA_TRANS_BLOCKS; /* no break */ case FSFILT_OP_SYMLINK: /* additional block + block bitmap + GDT for long symlink */ nblocks += 3; /* no break */ case FSFILT_OP_CREATE: + /* create/update logs for each stripe */ nblocks += (EXT3_INDEX_EXTRA_TRANS_BLOCKS + - EXT3_DATA_TRANS_BLOCKS) * logs; + EXT3_SINGLEDATA_TRANS_BLOCKS) * logs; + /* no break */ case FSFILT_OP_MKDIR: case FSFILT_OP_MKNOD: /* modify one inode + block bitmap + GDT */ @@ -108,7 +112,8 @@ static void *fsfilt_ext3_start(struct inode *inode, int op, void *desc_private, /* no break */ case FSFILT_OP_LINK: /* modify parent directory */ - nblocks += EXT3_INDEX_EXTRA_TRANS_BLOCKS+EXT3_DATA_TRANS_BLOCKS; + nblocks += EXT3_INDEX_EXTRA_TRANS_BLOCKS + + EXT3_DATA_TRANS_BLOCKS; break; case FSFILT_OP_SETATTR: /* Setattr on inode */ @@ -125,6 +130,12 @@ static void *fsfilt_ext3_start(struct inode *inode, int op, void *desc_private, } LASSERT(current->journal_info == desc_private); + journal = EXT3_SB(inode->i_sb)->s_journal; + if (nblocks > journal->j_max_transaction_buffers) { + CERROR("too many credits %d for op %ux%u using %d instead\n", + nblocks, op, logs, journal->j_max_transaction_buffers); + nblocks = journal->j_max_transaction_buffers; + } journal_start: lock_kernel(); @@ -133,6 +144,9 @@ static void *fsfilt_ext3_start(struct inode *inode, int op, void *desc_private, if (!IS_ERR(handle)) LASSERT(current->journal_info == handle); + else + CERROR("error starting handle for op %u (%u credits): rc %ld\n", + op, nblocks, PTR_ERR(handle)); return handle; } @@ -853,7 +867,6 @@ static int fsfilt_ext3_get_op_len(int op, struct fsfilt_objinfo *fso, int logs) case FSFILT_OP_UNLINK: return 3 * logs; } - } else { int i; int needed = 0; diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index bbc33bb..5e098ae 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -590,9 +590,9 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa, handle = fsfilt_start(exp->exp_obd, mds->mds_objects_dir->d_inode, FSFILT_OP_RENAME, NULL); - if (IS_ERR(handle)) + if (IS_ERR(handle)) GOTO(out_dput, rc = PTR_ERR(handle)); - + lock_kernel(); rc = vfs_rename(mds->mds_objects_dir->d_inode, filp->f_dentry, mds->mds_objects_dir->d_inode, new_child); diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index 820bc0e..8b8bae0 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -791,14 +791,14 @@ int mds_open(struct mds_update_record *rec, int offset, * opened this file and is only replaying the RPC, so we open the * inode by fid (at some large expense in security). */ if (lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) { - DEBUG_REQ(D_HA, req, "open replay, disp: "LPX64"\n", + DEBUG_REQ(D_HA, req, "open replay, disp: "LPX64"\n", rep->lock_policy_res1); LASSERT(rec->ur_fid2->id); - + rc = mds_open_by_fid(req, rec->ur_fid2, body, rec->ur_flags, rec, rep); - if (rc != -ENOENT) + if (rc != -ENOENT) RETURN(rc); /* We didn't find the correct inode on disk either, so we * need to re-create it via a regular replay. */ diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index e91d1bf5..e36921a 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -1881,7 +1881,7 @@ static int filter_precreate(struct obd_device *obd, struct obdo *oa, } else { CERROR("Serious error: objid %*s already " "exists; is this filesystem corrupt?\n", - dchild->d_name.len, dchild->d_name.name); + dchild->d_name.len, dchild->d_name.name); } GOTO(cleanup, rc = -EEXIST); }