From 97ef95c2f5f8898661163f72b22856b9a93a7b3b Mon Sep 17 00:00:00 2001 From: dmilos Date: Tue, 16 Sep 2003 22:41:56 +0000 Subject: [PATCH] Merge latest b_llp_hp changes onto b_flock --- .../patches/vfs-pdirops-2.4.18-chaos.patch | 12 +- .../patches/vfs-pdirops-2.4.20-rh.patch | 18 +- lustre/osc/osc_create.c | 259 +++++++-------------- 3 files changed, 96 insertions(+), 193 deletions(-) diff --git a/lustre/kernel_patches/patches/vfs-pdirops-2.4.18-chaos.patch b/lustre/kernel_patches/patches/vfs-pdirops-2.4.18-chaos.patch index a9cc225..61e4033 100644 --- a/lustre/kernel_patches/patches/vfs-pdirops-2.4.18-chaos.patch +++ b/lustre/kernel_patches/patches/vfs-pdirops-2.4.18-chaos.patch @@ -144,9 +144,9 @@ path_release(&nd); out: @@ -1619,14 +1649,14 @@ asmlinkage long sys_rmdir(const char * p - if (error != -EOPNOTSUPP) - goto exit1; - } + if (error != -EOPNOTSUPP) + goto exit1; + } - down(&nd.dentry->d_inode->i_sem); + nd.lock = lock_dir(nd.dentry->d_inode, &nd.last); dentry = lookup_hash_it(&nd.last, nd.dentry, NULL); @@ -161,9 +161,9 @@ path_release(&nd); exit: @@ -1685,7 +1715,7 @@ asmlinkage long sys_unlink(const char * - if (error != -EOPNOTSUPP) - goto exit1; - } + if (error != -EOPNOTSUPP) + goto exit1; + } - down(&nd.dentry->d_inode->i_sem); + nd.lock = lock_dir(nd.dentry->d_inode, &nd.last); dentry = lookup_hash_it(&nd.last, nd.dentry, NULL); diff --git a/lustre/kernel_patches/patches/vfs-pdirops-2.4.20-rh.patch b/lustre/kernel_patches/patches/vfs-pdirops-2.4.20-rh.patch index c9228a8..6ab7a21 100644 --- a/lustre/kernel_patches/patches/vfs-pdirops-2.4.20-rh.patch +++ b/lustre/kernel_patches/patches/vfs-pdirops-2.4.20-rh.patch @@ -44,14 +44,14 @@ Index: linux-2.4.20-rh/fs/namei.c /* In order to reduce some races, while at the same time doing additional * checking and hopefully speeding things up, we copy filenames to the * kernel data space before using them.. -@@ -302,10 +332,10 @@ - { +@@ -303,10 +333,11 @@ struct dentry * result; struct inode *dir = parent->d_inode; + int counter = 0; + void *lock; again: -- + counter++; - down(&dir->i_sem); + lock = lock_dir(dir, name); /* @@ -146,9 +146,9 @@ Index: linux-2.4.20-rh/fs/namei.c path_release(&nd); out: @@ -1642,14 +1672,14 @@ - if (error != -EOPNOTSUPP) - goto exit1; - } + if (error != -EOPNOTSUPP) + goto exit1; + } - down(&nd.dentry->d_inode->i_sem); + nd.lock = lock_dir(nd.dentry->d_inode, &nd.last); dentry = lookup_hash_it(&nd.last, nd.dentry, NULL); @@ -163,9 +163,9 @@ Index: linux-2.4.20-rh/fs/namei.c path_release(&nd); exit: @@ -1708,7 +1738,7 @@ - if (error != -EOPNOTSUPP) - goto exit1; - } + if (error != -EOPNOTSUPP) + goto exit1; + } - down(&nd.dentry->d_inode->i_sem); + nd.lock = lock_dir(nd.dentry->d_inode, &nd.last); dentry = lookup_hash_it(&nd.last, nd.dentry, NULL); diff --git a/lustre/osc/osc_create.c b/lustre/osc/osc_create.c index 3fb9d08..da1a4f5 100644 --- a/lustre/osc/osc_create.c +++ b/lustre/osc/osc_create.c @@ -47,12 +47,6 @@ # include #endif -#include -#include /* for mds_objid */ -#include -#include -#include - #ifndef __CYGWIN__ # include # include @@ -60,32 +54,80 @@ # include #endif -#include -#include /* for OBD_FAIL_CHECK */ -#include /* for ll_i2info */ -#include /* for PTL_MD_MAX_IOV */ -#include +#include #include "osc_internal.h" -struct osc_created { - wait_queue_head_t osccd_waitq; /* the daemon sleeps on this */ - wait_queue_head_t osccd_ctl_waitq; /* insmod rmmod sleep on this */ - spinlock_t osccd_lock; - int osccd_flags; - struct task_struct *osccd_thread; - struct list_head osccd_queue_list_head; - struct list_head osccd_work_list_head; -}; +#define OSCC_FLAG_RECOVERING 1 +#define OSCC_FLAG_CREATING 2 + +static int osc_interpret_create(struct ptlrpc_request *request, void *data, + int rc) +{ + struct osc_creator *oscc; + struct ost_body *body; + ENTRY; + + body = lustre_swab_repbuf(request, 0, sizeof(*body), + lustre_swab_ost_body); + if (body == NULL) + RETURN(-EPROTO); + + oscc = request->rq_async_args.pointer_arg[0]; + spin_lock(&oscc->oscc_lock); + oscc->oscc_status = rc; + oscc->oscc_last_id = body->oa.o_id; + oscc->oscc_flags &= ~OSCC_FLAG_CREATING; + spin_unlock(&oscc->oscc_lock); + + CDEBUG(D_INFO, "preallocated through id "LPU64" (last used "LPU64")\n", + oscc->oscc_last_id, oscc->oscc_next_id); + + wake_up(&oscc->oscc_waitq); + RETURN(0); +} +static int oscc_internal_create(struct osc_creator *oscc) +{ + struct ptlrpc_request *request; + struct ost_body *body; + int size = sizeof(*body); + ENTRY; -#define OSCCD_STOPPING 0x1 -#define OSCCD_STOPPED 0x2 -#define OSCCD_RUNNING 0x4 -#define OSCCD_KICKED 0x8 -#define OSCCD_PRECREATED 0x10 + spin_lock(&oscc->oscc_lock); + if (oscc->oscc_flags & OSCC_FLAG_CREATING) { + spin_unlock(&oscc->oscc_lock); + RETURN(0); + } + oscc->oscc_flags |= OSCC_FLAG_CREATING; + spin_unlock(&oscc->oscc_lock); + request = ptlrpc_prep_req(class_exp2cliimp(oscc->oscc_exp), OST_CREATE, + 1, &size, NULL); + if (request == NULL) { + spin_lock(&oscc->oscc_lock); + oscc->oscc_flags &= ~OSCC_FLAG_CREATING; + spin_unlock(&oscc->oscc_lock); + RETURN(-ENOMEM); + } -static struct osc_created osc_created; + request->rq_request_portal = OST_CREATE_PORTAL; //XXX FIXME bug 249 + body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof(*body)); + + spin_lock(&oscc->oscc_lock); + body->oa.o_id = oscc->oscc_last_id + oscc->oscc_grow_count; + body->oa.o_valid |= OBD_MD_FLID; + CDEBUG(D_INFO, "preallocating through id "LPU64" (last used "LPU64")\n", + body->oa.o_id, oscc->oscc_next_id); + spin_unlock(&oscc->oscc_lock); + + request->rq_replen = lustre_msg_size(1, &size); + + request->rq_async_args.pointer_arg[0] = oscc; + request->rq_interpret_reply = osc_interpret_create; + osc_rpcd_add_req(request); + + RETURN(0); +} static int oscc_has_objects(struct osc_creator *oscc, int count) { @@ -93,35 +135,27 @@ static int oscc_has_objects(struct osc_creator *oscc, int count) spin_lock(&oscc->oscc_lock); rc = ((__s64)(oscc->oscc_last_id - oscc->oscc_next_id) >= count); spin_unlock(&oscc->oscc_lock); + + if (rc == 0) + oscc_internal_create(oscc); + return rc; } -static int oscc_precreate(struct osc_creator *oscc, struct osc_created *osccd, - int wait) +static int oscc_precreate(struct osc_creator *oscc, int wait) { - int rc = 0; struct l_wait_info lwi = { 0 }; + int rc = 0; ENTRY; if (oscc_has_objects(oscc, oscc->oscc_kick_barrier)) RETURN(0); - spin_lock(&osccd->osccd_lock); - spin_lock(&oscc->oscc_lock); - if (list_empty(&oscc->oscc_list)) { - list_add(&oscc->oscc_list, &osccd->osccd_queue_list_head); - osccd->osccd_flags |= OSCCD_KICKED; - wake_up(&osccd->osccd_waitq); - } - spin_unlock(&oscc->oscc_lock); - spin_unlock(&osccd->osccd_lock); - /* an MDS using this call may time out on this. This is a - * recovery style wait. - */ + * recovery style wait. */ if (wait) - rc = l_wait_event(oscc->oscc_waitq, oscc_has_objects(oscc, 1), - &lwi); + rc = l_wait_event(oscc->oscc_waitq, + oscc_has_objects(oscc, 1), &lwi); if (rc || !wait) RETURN(rc); @@ -136,10 +170,8 @@ int osc_create(struct obd_export *exp, struct obdo *oa, { struct lov_stripe_md *lsm; struct osc_creator *oscc = &exp->u.eu_osc_data.oed_oscc; - struct osc_created *osccd = oscc->oscc_osccd; int try_again = 1, rc = 0; ENTRY; - LASSERT(oa); LASSERT(ea); @@ -160,12 +192,10 @@ int osc_create(struct obd_export *exp, struct obdo *oa, RETURN(0); rc = osc_real_create(oscc->oscc_exp, oa, ea, NULL); - spin_lock(&osccd->osccd_lock); spin_lock(&oscc->oscc_lock); oscc->oscc_status = rc; oscc->oscc_last_id = oscc->oscc_next_id - 1; spin_unlock(&oscc->oscc_lock); - spin_unlock(&osccd->osccd_lock); RETURN(rc); } @@ -181,7 +211,7 @@ int osc_create(struct obd_export *exp, struct obdo *oa, try_again = 0; } spin_unlock(&oscc->oscc_lock); - rc = oscc_precreate(oscc, osccd, try_again); + rc = oscc_precreate(oscc, try_again); } if (rc == 0) @@ -191,93 +221,6 @@ int osc_create(struct obd_export *exp, struct obdo *oa, RETURN(rc); } -void osccd_do_create(struct osc_created *osccd) -{ - struct list_head *tmp; - - next: - spin_lock(&osccd->osccd_lock); - list_for_each (tmp, &osccd->osccd_queue_list_head) { - int rc; - struct osc_creator *oscc = list_entry(tmp, struct osc_creator, - oscc_list); - list_del_init(&oscc->oscc_list); - list_add(&oscc->oscc_list, &osccd->osccd_work_list_head); - spin_lock(&oscc->oscc_lock); - oscc->oscc_oa.o_id = oscc->oscc_last_id + oscc->oscc_grow_count; - oscc->oscc_oa.o_valid |= OBD_MD_FLID; - spin_unlock(&oscc->oscc_lock); - spin_unlock(&osccd->osccd_lock); - - rc = osc_real_create(oscc->oscc_exp, &oscc->oscc_oa, - &oscc->oscc_ea, NULL); - - /* This is not used and leaked, so might as well free - * it now.*/ - if (rc == 0 && oscc->oscc_ea != NULL) - obd_free_memmd(oscc->oscc_exp, &oscc->oscc_ea); - - spin_lock(&osccd->osccd_lock); - spin_lock(&oscc->oscc_lock); - list_del_init(&oscc->oscc_list); - oscc->oscc_status = rc; - oscc->oscc_last_id = oscc->oscc_oa.o_id; - spin_unlock(&oscc->oscc_lock); - spin_unlock(&osccd->osccd_lock); - - CDEBUG(D_INFO, "preallocated through id "LPU64" (last used " - LPU64")\n", oscc->oscc_last_id, oscc->oscc_next_id); - wake_up(&oscc->oscc_waitq); - goto next; - } - spin_unlock(&osccd->osccd_lock); -} - -static int osccd_main(void *arg) -{ - struct osc_created *osccd = (struct osc_created *)arg; - unsigned long flags; - ENTRY; - - lock_kernel(); - kportal_daemonize("lustre_created"); - - SIGNAL_MASK_LOCK(current, flags); - sigfillset(¤t->blocked); - RECALC_SIGPENDING; - SIGNAL_MASK_UNLOCK(current, flags); - - unlock_kernel(); - - /* Record that the thread is running */ - osccd->osccd_flags = OSCCD_RUNNING; - wake_up(&osccd->osccd_ctl_waitq); - - /* And now, loop forever on requests */ - while (1) { - struct l_wait_info lwi = { 0 }; - l_wait_event(osccd->osccd_waitq, - osccd->osccd_flags & (OSCCD_STOPPING|OSCCD_KICKED), - &lwi); - - spin_lock(&osccd->osccd_lock); - if (osccd->osccd_flags & OSCCD_STOPPING) { - spin_unlock(&osccd->osccd_lock); - EXIT; - break; - } - osccd->osccd_flags &= ~OSCCD_KICKED; - spin_unlock(&osccd->osccd_lock); - osccd_do_create(osccd); - } - - osccd->osccd_thread = NULL; - osccd->osccd_flags = OSCCD_STOPPED; - wake_up(&osccd->osccd_ctl_waitq); - CDEBUG(D_NET, "commit callback daemon exiting %d\n", current->pid); - RETURN(0); -} - void oscc_init(struct lustre_handle *exph) { struct obd_export *exp = class_conn2export(exph); @@ -292,52 +235,12 @@ void oscc_init(struct lustre_handle *exph) init_waitqueue_head(&oed->oed_oscc.oscc_waitq); spin_lock_init(&oed->oed_oscc.oscc_lock); oed->oed_oscc.oscc_exp = exp; - oed->oed_oscc.oscc_osccd = &osc_created; - oed->oed_oscc.oscc_kick_barrier = 50; - oed->oed_oscc.oscc_grow_count = 100; - oed->oed_oscc.oscc_initial_create_count = 100; + oed->oed_oscc.oscc_kick_barrier = 1000; + oed->oed_oscc.oscc_grow_count = 2000; + oed->oed_oscc.oscc_initial_create_count = 2000; oed->oed_oscc.oscc_next_id = 2; oed->oed_oscc.oscc_last_id = 1; /* XXX the export handle should give the oscc the last object */ /* oed->oed_oscc.oscc_last_id = exph->....; */ } - -int osccd_setup(void) -{ - struct osc_created *osccd = &osc_created; - int rc; - struct l_wait_info lwi = { 0 }; - ENTRY; - - INIT_LIST_HEAD(&osccd->osccd_queue_list_head); - INIT_LIST_HEAD(&osccd->osccd_work_list_head); - init_waitqueue_head(&osccd->osccd_ctl_waitq); - init_waitqueue_head(&osccd->osccd_waitq); - spin_lock_init(&osccd->osccd_lock); - rc = kernel_thread(osccd_main, osccd, - CLONE_VM | CLONE_FS | CLONE_FILES); - if (rc < 0) { - CERROR("cannot start thread\n"); - RETURN(rc); - } - l_wait_event(osccd->osccd_ctl_waitq, osccd->osccd_flags & OSCCD_RUNNING, - &lwi); - RETURN(0); -} - -int osccd_cleanup(void) -{ - struct osc_created *osccd = &osc_created; - struct l_wait_info lwi = { 0 }; - ENTRY; - - spin_lock(&osccd->osccd_lock); - osccd->osccd_flags = OSCCD_STOPPING; - spin_unlock(&osccd->osccd_lock); - - wake_up(&osccd->osccd_waitq); - l_wait_event(osccd->osccd_ctl_waitq, - osccd->osccd_flags & OSCCD_STOPPED, &lwi); - RETURN(0); -} -- 1.8.3.1