Whamcloud - gitweb
Add new ->l_weigh_ast() call-back to ldlm_lock. It is called by
authornikita <nikita>
Sat, 18 Oct 2008 17:07:21 +0000 (17:07 +0000)
committernikita <nikita>
Sat, 18 Oct 2008 17:07:21 +0000 (17:07 +0000)
ldlm_cancel_shrink_policy() to estimate lock "value", instead of hard-coded
`number of pages' logic.
b=16450

lustre/ChangeLog
lustre/include/lustre_dlm.h
lustre/ldlm/ldlm_request.c
lustre/liblustre/dir.c
lustre/liblustre/super.c
lustre/llite/dir.c
lustre/llite/file.c
lustre/mdc/mdc_locks.c
lustre/mdt/mdt_reint.c
lustre/mgc/mgc_request.c

index 38ef6a5..2e86b3b 100644 (file)
@@ -1540,11 +1540,6 @@ Bugzilla   : 16450
 Description: Kill unused ldlm_handle2lock_ns() function.
 Details    : Kill unused ldlm_handle2lock_ns() function.
 
 Description: Kill unused ldlm_handle2lock_ns() function.
 Details    : Kill unused ldlm_handle2lock_ns() function.
 
-Severity   : minor
-Bugzilla   : 16450
-Description: Kill unused ldlm_handle2lock_ns() function.
-Details    : Kill unused ldlm_handle2lock_ns() function.
-
 Severity   : normal
 Bugzilla   : 16450
 Description: Add lu_ref support to ldlm_lock
 Severity   : normal
 Bugzilla   : 16450
 Description: Add lu_ref support to ldlm_lock
@@ -1573,6 +1568,13 @@ Details    : Introduce ldlm_lock_addref_try() function (used by CLIO) that
             attempts to addref a lock that might be being canceled
             concurrently.
 
             attempts to addref a lock that might be being canceled
             concurrently.
 
+Severity   : normal
+Bugzilla   : 16450
+Description: Add ldlm_weigh_callback().
+Details    : Add new ->l_weigh_ast() call-back to ldlm_lock. It is called 
+        by ldlm_cancel_shrink_policy() to estimate lock "value", instead of
+        hard-coded `number of pages' logic.
+
 --------------------------------------------------------------------------------
 
 2007-08-10         Cluster File Systems, Inc. <info@clusterfs.com>
 --------------------------------------------------------------------------------
 
 2007-08-10         Cluster File Systems, Inc. <info@clusterfs.com>
index be73ac0..368ee21 100644 (file)
@@ -440,7 +440,7 @@ struct ldlm_namespace {
         /**
          * Lower limit to number of pages in lock to keep it in cache.
          */
         /**
          * Lower limit to number of pages in lock to keep it in cache.
          */
-        unsigned int           ns_shrink_thumb;
+        unsigned long          ns_shrink_thumb;
 
         /**
          * Next debug dump, jiffies.
 
         /**
          * Next debug dump, jiffies.
@@ -525,6 +525,7 @@ typedef int (*ldlm_blocking_callback)(struct ldlm_lock *lock,
 typedef int (*ldlm_completion_callback)(struct ldlm_lock *lock, int flags,
                                         void *data);
 typedef int (*ldlm_glimpse_callback)(struct ldlm_lock *lock, void *data);
 typedef int (*ldlm_completion_callback)(struct ldlm_lock *lock, int flags,
                                         void *data);
 typedef int (*ldlm_glimpse_callback)(struct ldlm_lock *lock, void *data);
+typedef unsigned long (*ldlm_weigh_callback)(struct ldlm_lock *lock);
 
 /* Interval node data for each LDLM_EXTENT lock */
 struct ldlm_interval {
 
 /* Interval node data for each LDLM_EXTENT lock */
 struct ldlm_interval {
@@ -598,6 +599,7 @@ struct ldlm_lock {
          * Lock glimpse handler.
          */
         ldlm_glimpse_callback    l_glimpse_ast;
          * Lock glimpse handler.
          */
         ldlm_glimpse_callback    l_glimpse_ast;
+        ldlm_weigh_callback      l_weigh_ast;
 
         /**
          * Lock export.
 
         /**
          * Lock export.
@@ -755,6 +757,7 @@ struct ldlm_enqueue_info {
         void *ei_cb_bl;  /* blocking lock callback */
         void *ei_cb_cp;  /* lock completion callback */
         void *ei_cb_gl;  /* lock glimpse callback */
         void *ei_cb_bl;  /* blocking lock callback */
         void *ei_cb_cp;  /* lock completion callback */
         void *ei_cb_gl;  /* lock glimpse callback */
+        void *ei_cb_wg;  /* lock weigh callback */
         void *ei_cbdata; /* Data to be passed into callbacks. */
         short ei_async:1; /* async request */
 };
         void *ei_cbdata; /* Data to be passed into callbacks. */
         short ei_async:1; /* async request */
 };
index 0d15a15..045b779 100644 (file)
@@ -1290,6 +1290,13 @@ static ldlm_policy_res_t ldlm_cancel_shrink_policy(struct ldlm_namespace *ns,
                 return LDLM_POLICY_KEEP_LOCK;
 
         if (lock->l_resource->lr_type == LDLM_EXTENT) {
                 return LDLM_POLICY_KEEP_LOCK;
 
         if (lock->l_resource->lr_type == LDLM_EXTENT) {
+                if (lock->l_weigh_ast) {
+                        /*
+                         * For liblustre, l_weigh_ast should return 0 since it
+                         * don't cache pages
+                         */
+                        page_nr = lock->l_weigh_ast(lock);
+                } else {
                 struct ldlm_extent *l_extent;
 
                 /* 
                 struct ldlm_extent *l_extent;
 
                 /* 
@@ -1297,22 +1304,9 @@ static ldlm_policy_res_t ldlm_cancel_shrink_policy(struct ldlm_namespace *ns,
                  * their extent. 
                  */
                 l_extent = &lock->l_policy_data.l_extent;
                  * their extent. 
                  */
                 l_extent = &lock->l_policy_data.l_extent;
-                page_nr = (l_extent->end - l_extent->start);
+                        page_nr = l_extent->end - l_extent->start;
                 do_div(page_nr, CFS_PAGE_SIZE);
                 do_div(page_nr, CFS_PAGE_SIZE);
-
-#ifdef __KERNEL__
-                /* 
-                 * XXX: In fact this is evil hack, we can't access inode
-                 * here. For doing it right we need somehow to have number
-                 * of covered by lock. This should be fixed later when 10718 
-                 * is landed. 
-                 */
-                if (lock->l_ast_data != NULL) {
-                        struct inode *inode = lock->l_ast_data;
-                        if (page_nr > inode->i_mapping->nrpages)
-                                page_nr = inode->i_mapping->nrpages;
                 }
                 }
-#endif
                 lock_cost = 1 + page_nr;
         } else {
                 /* 
                 lock_cost = 1 + page_nr;
         } else {
                 /* 
index b45bc89..57960a2 100644 (file)
@@ -94,7 +94,8 @@ static int llu_dir_do_readpage(struct inode *inode, struct page *page)
                            &lli->lli_fid, LDLM_IBITS, &policy, LCK_CR, &lockh);
         if (!rc) {
                 struct ldlm_enqueue_info einfo = {LDLM_IBITS, LCK_CR,
                            &lli->lli_fid, LDLM_IBITS, &policy, LCK_CR, &lockh);
         if (!rc) {
                 struct ldlm_enqueue_info einfo = {LDLM_IBITS, LCK_CR,
-                        llu_md_blocking_ast, ldlm_completion_ast, NULL, inode};
+                        llu_md_blocking_ast, ldlm_completion_ast, NULL, NULL,
+                        inode};
 
                 llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, 0,
                                     LUSTRE_OPC_ANY);
 
                 llu_prep_md_op_data(&op_data, inode, NULL, NULL, 0, 0,
                                     LUSTRE_OPC_ANY);
index f5b1b4e..ccc19b2 100644 (file)
@@ -1393,7 +1393,7 @@ static int llu_file_flock(struct inode *ino,
                            fid_ver(&lli->lli_fid),
                            LDLM_FLOCK} };
         struct ldlm_enqueue_info einfo = { LDLM_FLOCK, 0, NULL,
                            fid_ver(&lli->lli_fid),
                            LDLM_FLOCK} };
         struct ldlm_enqueue_info einfo = { LDLM_FLOCK, 0, NULL,
-                ldlm_flock_completion_ast, NULL, file_lock };
+                ldlm_flock_completion_ast, NULL, NULL, file_lock };
 
         struct lustre_handle lockh = {0};
         ldlm_policy_data_t flock;
 
         struct lustre_handle lockh = {0};
         ldlm_policy_data_t flock;
@@ -1773,7 +1773,7 @@ static int llu_lov_setstripe_ea_info(struct inode *ino, int flags,
         struct lov_stripe_md *lsm;
         struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags};
         struct ldlm_enqueue_info einfo = { LDLM_IBITS, LCK_CR,
         struct lov_stripe_md *lsm;
         struct lookup_intent oit = {.it_op = IT_OPEN, .it_flags = flags};
         struct ldlm_enqueue_info einfo = { LDLM_IBITS, LCK_CR,
-                llu_md_blocking_ast, ldlm_completion_ast, NULL, NULL };
+                llu_md_blocking_ast, ldlm_completion_ast, NULL, NULL, NULL };
 
         struct ptlrpc_request *req = NULL;
         struct lustre_md md;
 
         struct ptlrpc_request *req = NULL;
         struct lustre_md md;
index 930bd26..b38e429 100644 (file)
@@ -281,7 +281,8 @@ struct page *ll_get_dir_page(struct inode *dir, __u64 hash, int exact,
                            ll_inode2fid(dir), LDLM_IBITS, &policy, mode, &lockh);
         if (!rc) {
                 struct ldlm_enqueue_info einfo = { LDLM_IBITS, mode,
                            ll_inode2fid(dir), LDLM_IBITS, &policy, mode, &lockh);
         if (!rc) {
                 struct ldlm_enqueue_info einfo = { LDLM_IBITS, mode,
-                       ll_md_blocking_ast, ldlm_completion_ast, NULL, dir };
+                       ll_md_blocking_ast, ldlm_completion_ast,
+                       NULL, NULL, dir };
                 struct lookup_intent it = { .it_op = IT_READDIR };
                 struct ptlrpc_request *request;
                 struct md_op_data *op_data;
                 struct lookup_intent it = { .it_op = IT_READDIR };
                 struct ptlrpc_request *request;
                 struct md_op_data *op_data;
index 75bf059..63f790a 100644 (file)
@@ -2343,7 +2343,7 @@ static int join_file(struct inode *head_inode, struct file *head_filp,
         struct lookup_intent oit = {.it_op = IT_OPEN,
                                    .it_flags = head_filp->f_flags|O_JOIN_FILE};
         struct ldlm_enqueue_info einfo = { LDLM_IBITS, LCK_CW,
         struct lookup_intent oit = {.it_op = IT_OPEN,
                                    .it_flags = head_filp->f_flags|O_JOIN_FILE};
         struct ldlm_enqueue_info einfo = { LDLM_IBITS, LCK_CW,
-                ll_md_blocking_ast, ldlm_completion_ast, NULL, NULL };
+                ll_md_blocking_ast, ldlm_completion_ast, NULL, NULL, NULL };
 
         struct lustre_handle lockh;
         struct md_op_data *op_data;
 
         struct lustre_handle lockh;
         struct md_op_data *op_data;
index 1c47ca0..a21992c 100644 (file)
@@ -914,7 +914,7 @@ int mdc_intent_lock(struct obd_export *exp, struct md_op_data *op_data,
         if (!it_disposition(it, DISP_ENQ_COMPLETE)) {
                 struct ldlm_enqueue_info einfo =
                         { LDLM_IBITS, it_to_lock_mode(it), cb_blocking,
         if (!it_disposition(it, DISP_ENQ_COMPLETE)) {
                 struct ldlm_enqueue_info einfo =
                         { LDLM_IBITS, it_to_lock_mode(it), cb_blocking,
-                          ldlm_completion_ast, NULL, NULL };
+                          ldlm_completion_ast, NULL, NULL, NULL };
 
                 /* For case if upper layer did not alloc fid, do it now. */
                 if (!fid_is_sane(&op_data->op_fid2) && it->it_op & IT_CREAT) {
 
                 /* For case if upper layer did not alloc fid, do it now. */
                 if (!fid_is_sane(&op_data->op_fid2) && it->it_op & IT_CREAT) {
index fefcf74..222c9ba 100644 (file)
@@ -754,7 +754,7 @@ static int mdt_rename_lock(struct mdt_thread_info *info,
                                             NULL, lh);
         } else {
                 struct ldlm_enqueue_info einfo = { LDLM_IBITS, LCK_EX,
                                             NULL, lh);
         } else {
                 struct ldlm_enqueue_info einfo = { LDLM_IBITS, LCK_EX,
-                        ldlm_blocking_ast, ldlm_completion_ast, NULL, NULL };
+                     ldlm_blocking_ast, ldlm_completion_ast, NULL, NULL, NULL };
                 int flags = 0;
 
                 /*
                 int flags = 0;
 
                 /*
index 9985007..a78460c 100644 (file)
@@ -661,7 +661,7 @@ static int mgc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm,
 {
         struct config_llog_data *cld = (struct config_llog_data *)data;
         struct ldlm_enqueue_info einfo = { type, mode, mgc_blocking_ast,
 {
         struct config_llog_data *cld = (struct config_llog_data *)data;
         struct ldlm_enqueue_info einfo = { type, mode, mgc_blocking_ast,
-                ldlm_completion_ast, NULL, data};
+                         ldlm_completion_ast, NULL, NULL, data};
 
         int rc;
         ENTRY;
 
         int rc;
         ENTRY;