Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / liblustre / rw.c
index 5de64a6..fb41272 100644 (file)
 #include <fcntl.h>
 #include <sys/uio.h>
 
-#include <fs.h>
+#ifdef HAVE_XTIO_H
+#include <xtio.h>
+#endif
 #include <sysio.h>
 #include <mount.h>
 #include <inode.h>
+#ifdef HAVE_FILE_H
 #include <file.h>
+#endif
 
 #undef LIST_HEAD
 
@@ -95,7 +99,7 @@ static int llu_lock_to_stripe_offset(struct inode *inode, struct ldlm_lock *lock
         rc = obd_get_info(exp, sizeof(key), &key, &vallen, &stripe);
         if (rc != 0) {
                 CERROR("obd_get_info: rc = %d\n", rc);
-                LBUG();
+                RETURN(rc);
         }
         LASSERT(stripe < lsm->lsm_stripe_count);
         RETURN(stripe);
@@ -143,10 +147,15 @@ static int llu_extent_lock_callback(struct ldlm_lock *lock,
                 lsm = lli->lli_smd;
 
                 stripe = llu_lock_to_stripe_offset(inode, lock);
-                l_lock(&lock->l_resource->lr_namespace->ns_lock);
+                if (stripe < 0) {
+                        CERROR("lock on inode without such object\n");
+                        break;
+                }
+#warning "fix l_lock() using here!"
+//                l_lock(&lock->l_resource->lr_namespace->ns_lock);
                 kms = ldlm_extent_shift_kms(lock,
                                             lsm->lsm_oinfo[stripe].loi_kms);
-                l_unlock(&lock->l_resource->lr_namespace->ns_lock);
+//                l_unlock(&lock->l_resource->lr_namespace->ns_lock);
                 if (lsm->lsm_oinfo[stripe].loi_kms != kms)
                         LDLM_DEBUG(lock, "updating kms from "LPU64" to "LPU64,
                                    lsm->lsm_oinfo[stripe].loi_kms, kms);
@@ -180,8 +189,13 @@ static int llu_glimpse_callback(struct ldlm_lock *lock, void *reqp)
                 GOTO(iput, rc = -ELDLM_NO_LOCK_DATA);
 
         /* First, find out which stripe index this lock corresponds to. */
-        if (lli->lli_smd->lsm_stripe_count > 1)
+        if (lli->lli_smd->lsm_stripe_count > 1) {
                 stripe = llu_lock_to_stripe_offset(inode, lock);
+                if (stripe < 0) {
+                        CWARN("lock on inode without such object\n");
+                        GOTO(iput, rc = -ELDLM_NO_LOCK_DATA);
+                }
+        }
 
         rc = lustre_pack_reply(req, 1, &size, NULL);
         if (rc) {
@@ -308,14 +322,6 @@ struct ll_async_page {
         struct inode   *llap_inode;
 };
 
-static struct ll_async_page *llap_from_cookie(void *cookie)
-{
-        struct ll_async_page *llap = cookie;
-        if (llap->llap_magic != LLAP_MAGIC)
-                return ERR_PTR(-EINVAL);
-        return llap;
-};
-
 static void llu_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
 {
         struct ll_async_page *llap;
@@ -324,12 +330,7 @@ static void llu_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
         obd_valid valid_flags;
         ENTRY;
 
-        llap = llap_from_cookie(data);
-        if (IS_ERR(llap)) {
-                EXIT;
-                return;
-        }
-
+        llap = LLAP_FROM_COOKIE(data);
         inode = llap->llap_inode;
         lsm = llu_i2info(inode)->lli_smd;
 
@@ -349,12 +350,7 @@ static void llu_ap_completion(void *data, int cmd, struct obdo *oa, int rc)
         struct ll_async_page *llap;
         struct page *page;
 
-        llap = llap_from_cookie(data);
-        if (IS_ERR(llap)) {
-                EXIT;
-                return;
-        }
-
+        llap = LLAP_FROM_COOKIE(data);
         llap->llap_queued = 0;
         page = llap->llap_page;
 
@@ -507,9 +503,6 @@ void put_io_group(struct llu_io_group *group)
         OBD_FREE(group, LLU_IO_GROUP_SIZE(group->lig_maxpages));
 }
 
-void lov_increase_kms(struct obd_export *exp, struct lov_stripe_md *lsm,
-                      obd_off size);
-
 static
 ssize_t llu_file_prwv(const struct iovec *iovec, int iovlen,
                         _SYSIO_OFF_T pos, ssize_t len,
@@ -618,7 +611,7 @@ ssize_t llu_file_prwv(const struct iovec *iovec, int iovlen,
                         pos += ret;
                         if (!is_read) {
                                 LASSERT(ret == count);
-                                lov_increase_kms(exp, lsm, pos);
+                                obd_adjust_kms(exp, lsm, pos, 0);
                                 /* file size grow immediately */
                                 if (pos > lli->lli_st_size)
                                         lli->lli_st_size = pos;