Whamcloud - gitweb
LU-4712 llite: lock the inode to be migrated
[fs/lustre-release.git] / lustre / llite / llite_close.c
index f1a1415..7dd5e2c 100644 (file)
 
 #define DEBUG_SUBSYSTEM S_LLITE
 
-#include <lustre_lite.h>
 #include "llite_internal.h"
 
 /** records that a write is in flight */
-void vvp_write_pending(struct ccc_object *club, struct ccc_page *page)
+void vvp_write_pending(struct vvp_object *club, struct vvp_page *page)
 {
-       struct ll_inode_info *lli = ll_i2info(club->cob_inode);
+       struct ll_inode_info *lli = ll_i2info(club->vob_inode);
 
        ENTRY;
        spin_lock(&lli->lli_lock);
        lli->lli_flags |= LLIF_SOM_DIRTY;
-       if (page != NULL && cfs_list_empty(&page->cpg_pending_linkage))
-               cfs_list_add(&page->cpg_pending_linkage,
-                            &club->cob_pending_list);
+       if (page != NULL && list_empty(&page->vpg_pending_linkage))
+               list_add(&page->vpg_pending_linkage,
+                            &club->vob_pending_list);
        spin_unlock(&lli->lli_lock);
        EXIT;
 }
 
 /** records that a write has completed */
-void vvp_write_complete(struct ccc_object *club, struct ccc_page *page)
+void vvp_write_complete(struct vvp_object *club, struct vvp_page *page)
 {
-       struct ll_inode_info *lli = ll_i2info(club->cob_inode);
+       struct ll_inode_info *lli = ll_i2info(club->vob_inode);
        int rc = 0;
 
        ENTRY;
        spin_lock(&lli->lli_lock);
-       if (page != NULL && !cfs_list_empty(&page->cpg_pending_linkage)) {
-               cfs_list_del_init(&page->cpg_pending_linkage);
+       if (page != NULL && !list_empty(&page->vpg_pending_linkage)) {
+               list_del_init(&page->vpg_pending_linkage);
                rc = 1;
        }
        spin_unlock(&lli->lli_lock);
        if (rc)
-               ll_queue_done_writing(club->cob_inode, 0);
+               ll_queue_done_writing(club->vob_inode, 0);
        EXIT;
 }
 
@@ -84,38 +83,38 @@ void vvp_write_complete(struct ccc_object *club, struct ccc_page *page)
 void ll_queue_done_writing(struct inode *inode, unsigned long flags)
 {
        struct ll_inode_info *lli = ll_i2info(inode);
-       struct ccc_object *club = cl2ccc(ll_i2info(inode)->lli_clob);
+       struct vvp_object *club = cl2vvp(ll_i2info(inode)->lli_clob);
        ENTRY;
 
        spin_lock(&lli->lli_lock);
         lli->lli_flags |= flags;
 
         if ((lli->lli_flags & LLIF_DONE_WRITING) &&
-            cfs_list_empty(&club->cob_pending_list)) {
+           list_empty(&club->vob_pending_list)) {
                 struct ll_close_queue *lcq = ll_i2sbi(inode)->ll_lcq;
 
                 if (lli->lli_flags & LLIF_MDS_SIZE_LOCK)
-                        CWARN("ino %lu/%u(flags %u) som valid it just after "
-                              "recovery\n",
-                              inode->i_ino, inode->i_generation,
-                              lli->lli_flags);
-                /* DONE_WRITING is allowed and inode has no dirty page. */
+                       CWARN("%s: file "DFID"(flags %u) Size-on-MDS valid, "
+                             "done writing allowed and no diry pages\n",
+                             ll_get_fsname(inode->i_sb, NULL, 0),
+                             PFID(ll_inode2fid(inode)), lli->lli_flags);
+               /* DONE_WRITING is allowed and inode has no dirty page. */
                spin_lock(&lcq->lcq_lock);
 
-                LASSERT(cfs_list_empty(&lli->lli_close_list));
-                CDEBUG(D_INODE, "adding inode %lu/%u to close list\n",
-                       inode->i_ino, inode->i_generation);
-                cfs_list_add_tail(&lli->lli_close_list, &lcq->lcq_head);
+               LASSERT(list_empty(&lli->lli_close_list));
+               CDEBUG(D_INODE, "adding inode "DFID" to close list\n",
+                      PFID(ll_inode2fid(inode)));
+               list_add_tail(&lli->lli_close_list, &lcq->lcq_head);
 
-                /* Avoid a concurrent insertion into the close thread queue:
-                 * an inode is already in the close thread, open(), write(),
-                 * close() happen, epoch is closed as the inode is marked as
-                 * LLIF_EPOCH_PENDING. When pages are written inode should not
-                 * be inserted into the queue again, clear this flag to avoid
-                 * it. */
-                lli->lli_flags &= ~LLIF_DONE_WRITING;
+               /* Avoid a concurrent insertion into the close thread queue:
+                * an inode is already in the close thread, open(), write(),
+                * close() happen, epoch is closed as the inode is marked as
+                * LLIF_EPOCH_PENDING. When pages are written inode should not
+                * be inserted into the queue again, clear this flag to avoid
+                * it. */
+               lli->lli_flags &= ~LLIF_DONE_WRITING;
 
-                cfs_waitq_signal(&lcq->lcq_waitq);
+               wake_up(&lcq->lcq_waitq);
                spin_unlock(&lcq->lcq_lock);
        }
        spin_unlock(&lli->lli_lock);
@@ -131,9 +130,10 @@ void ll_done_writing_attr(struct inode *inode, struct md_op_data *op_data)
         op_data->op_flags |= MF_SOM_CHANGE;
         /* Check if Size-on-MDS attributes are valid. */
         if (lli->lli_flags & LLIF_MDS_SIZE_LOCK)
-                CERROR("ino %lu/%u(flags %u) som valid it just after "
-                       "recovery\n", inode->i_ino, inode->i_generation,
-                       lli->lli_flags);
+               CERROR("%s: inode "DFID"(flags %u) MDS holds lock on "
+                      "Size-on-MDS attributes\n",
+                      ll_get_fsname(inode->i_sb, NULL, 0),
+                      PFID(ll_inode2fid(inode)), lli->lli_flags);
 
         if (!cl_local_size(inode)) {
                 /* Send Size-on-MDS Attributes if valid. */
@@ -148,11 +148,11 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data,
                      struct obd_client_handle **och, unsigned long flags)
 {
        struct ll_inode_info *lli = ll_i2info(inode);
-       struct ccc_object *club = cl2ccc(ll_i2info(inode)->lli_clob);
+       struct vvp_object *club = cl2vvp(ll_i2info(inode)->lli_clob);
        ENTRY;
 
        spin_lock(&lli->lli_lock);
-       if (!(cfs_list_empty(&club->cob_pending_list))) {
+       if (!(list_empty(&club->vob_pending_list))) {
                if (!(lli->lli_flags & LLIF_EPOCH_PENDING)) {
                        LASSERT(*och != NULL);
                        LASSERT(lli->lli_pending_och == NULL);
@@ -204,7 +204,7 @@ void ll_ioepoch_close(struct inode *inode, struct md_op_data *op_data,
                }
        }
 
-       LASSERT(cfs_list_empty(&club->cob_pending_list));
+       LASSERT(list_empty(&club->vob_pending_list));
        lli->lli_flags &= ~LLIF_SOM_DIRTY;
        spin_unlock(&lli->lli_lock);
        ll_done_writing_attr(inode, op_data);
@@ -229,9 +229,10 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data)
 
         LASSERT(op_data != NULL);
         if (lli->lli_flags & LLIF_MDS_SIZE_LOCK)
-                CERROR("ino %lu/%u(flags %u) som valid it just after "
-                       "recovery\n", inode->i_ino, inode->i_generation,
-                       lli->lli_flags);
+               CERROR("%s: inode "DFID"(flags %u) MDS holds lock on "
+                      "Size-on-MDS attributes\n",
+                      ll_get_fsname(inode->i_sb, NULL, 0),
+                      PFID(ll_inode2fid(inode)), lli->lli_flags);
 
         OBDO_ALLOC(oa);
         if (!oa) {
@@ -249,10 +250,11 @@ int ll_som_update(struct inode *inode, struct md_op_data *op_data)
                 if (rc) {
                         oa->o_valid = 0;
                        if (rc != -ENOENT)
-                                CERROR("inode_getattr failed (%d): unable to "
-                                       "send a Size-on-MDS attribute update "
-                                       "for inode %lu/%u\n", rc, inode->i_ino,
-                                       inode->i_generation);
+                               CERROR("%s: inode_getattr failed - unable to "
+                                      "send a Size-on-MDS attribute update "
+                                      "for inode "DFID": rc = %d\n",
+                                      ll_get_fsname(inode->i_sb, NULL, 0),
+                                      PFID(ll_inode2fid(inode)), rc);
                 } else {
                         CDEBUG(D_INODE, "Size-on-MDS update on "DFID"\n",
                                PFID(&lli->lli_fid));
@@ -315,8 +317,9 @@ static void ll_done_writing(struct inode *inode)
                  * OSTs and send setattr to back to MDS. */
                 rc = ll_som_update(inode, op_data);
         } else if (rc) {
-                CERROR("inode %lu mdc done_writing failed: rc = %d\n",
-                       inode->i_ino, rc);
+               CERROR("%s: inode "DFID" mdc done_writing failed: rc = %d\n",
+                      ll_get_fsname(inode->i_sb, NULL, 0),
+                      PFID(ll_inode2fid(inode)), rc);
         }
 out:
         ll_finish_md_op_data(op_data);
@@ -333,12 +336,12 @@ static struct ll_inode_info *ll_close_next_lli(struct ll_close_queue *lcq)
 
        spin_lock(&lcq->lcq_lock);
 
-        if (!cfs_list_empty(&lcq->lcq_head)) {
-                lli = cfs_list_entry(lcq->lcq_head.next, struct ll_inode_info,
-                                     lli_close_list);
-                cfs_list_del_init(&lli->lli_close_list);
-        } else if (cfs_atomic_read(&lcq->lcq_stop))
-                lli = ERR_PTR(-EALREADY);
+       if (!list_empty(&lcq->lcq_head)) {
+               lli = list_entry(lcq->lcq_head.next, struct ll_inode_info,
+                                lli_close_list);
+               list_del_init(&lli->lli_close_list);
+       } else if (atomic_read(&lcq->lcq_stop))
+               lli = ERR_PTR(-EALREADY);
 
        spin_unlock(&lcq->lcq_lock);
        return lli;
@@ -363,8 +366,8 @@ static int ll_close_thread(void *arg)
                         break;
 
                 inode = ll_info2i(lli);
-                CDEBUG(D_INFO, "done_writting for inode %lu/%u\n",
-                       inode->i_ino, inode->i_generation);
+               CDEBUG(D_INFO, "done_writting for inode "DFID"\n",
+                      PFID(ll_inode2fid(inode)));
                 ll_done_writing(inode);
                 iput(inode);
         }
@@ -377,7 +380,7 @@ static int ll_close_thread(void *arg)
 int ll_close_thread_start(struct ll_close_queue **lcq_ret)
 {
        struct ll_close_queue *lcq;
-       cfs_task_t *task;
+       struct task_struct *task;
 
        if (OBD_FAIL_CHECK(OBD_FAIL_LDLM_CLOSE_THREAD))
                return -EINTR;
@@ -387,8 +390,8 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret)
                return -ENOMEM;
 
        spin_lock_init(&lcq->lcq_lock);
-       CFS_INIT_LIST_HEAD(&lcq->lcq_head);
-       cfs_waitq_init(&lcq->lcq_waitq);
+       INIT_LIST_HEAD(&lcq->lcq_head);
+       init_waitqueue_head(&lcq->lcq_waitq);
        init_completion(&lcq->lcq_comp);
 
        task = kthread_run(ll_close_thread, lcq, "ll_close");
@@ -405,8 +408,8 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret)
 void ll_close_thread_shutdown(struct ll_close_queue *lcq)
 {
        init_completion(&lcq->lcq_comp);
-       cfs_atomic_inc(&lcq->lcq_stop);
-       cfs_waitq_signal(&lcq->lcq_waitq);
+       atomic_inc(&lcq->lcq_stop);
+       wake_up(&lcq->lcq_waitq);
        wait_for_completion(&lcq->lcq_comp);
        OBD_FREE(lcq, sizeof(*lcq));
 }