Whamcloud - gitweb
LU-911 osd: support for legacy OST objects in ldiskfs osd
[fs/lustre-release.git] / lustre / mdc / mdc_lib.c
index 8e8b707..afbce57 100644 (file)
@@ -28,6 +28,8 @@
 /*
  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, Whamcloud, Inc.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -448,21 +450,19 @@ void mdc_rename_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
 }
 
 void mdc_getattr_pack(struct ptlrpc_request *req, __u64 valid, int flags,
-                      struct md_op_data *op_data)
+                      struct md_op_data *op_data, int ea_size)
 {
         struct mdt_body *b = req_capsule_client_get(&req->rq_pill,
                                                     &RMF_MDT_BODY);
 
-        b->fsuid = cfs_curproc_fsuid();
-        b->fsgid = cfs_curproc_fsgid();
-        b->capability = cfs_curproc_cap_pack();
         b->valid = valid;
         if (op_data->op_bias & MDS_CHECK_SPLIT)
                 b->valid |= OBD_MD_FLCKSPLIT;
         if (op_data->op_bias & MDS_CROSS_REF)
                 b->valid |= OBD_MD_FLCROSSREF;
+        b->eadatasize = ea_size;
         b->flags = flags;
-        b->suppgid = op_data->op_suppgids[0];
+        __mdc_pack_body(b, op_data->op_suppgids[0]);
 
         b->fid1 = op_data->op_fid1;
         b->fid2 = op_data->op_fid2;
@@ -503,21 +503,30 @@ static int mdc_req_avail(struct client_obd *cli, struct mdc_cache_waiter *mcw)
 /* We record requests in flight in cli->cl_r_in_flight here.
  * There is only one write rpc possible in mdc anyway. If this to change
  * in the future - the code may need to be revisited. */
-void mdc_enter_request(struct client_obd *cli)
+int mdc_enter_request(struct client_obd *cli)
 {
+        int rc = 0;
         struct mdc_cache_waiter mcw;
-        struct l_wait_info lwi = { 0 };
+        struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
 
         client_obd_list_lock(&cli->cl_loi_list_lock);
         if (cli->cl_r_in_flight >= cli->cl_max_rpcs_in_flight) {
                 cfs_list_add_tail(&mcw.mcw_entry, &cli->cl_cache_waiters);
                 cfs_waitq_init(&mcw.mcw_waitq);
                 client_obd_list_unlock(&cli->cl_loi_list_lock);
-                l_wait_event(mcw.mcw_waitq, mdc_req_avail(cli, &mcw), &lwi);
+                rc = l_wait_event(mcw.mcw_waitq, mdc_req_avail(cli, &mcw), &lwi);
+                if (rc) {
+                        client_obd_list_lock(&cli->cl_loi_list_lock);
+                        if (cfs_list_empty(&mcw.mcw_entry))
+                                cli->cl_r_in_flight--;
+                        cfs_list_del_init(&mcw.mcw_entry);
+                        client_obd_list_unlock(&cli->cl_loi_list_lock);
+                }
         } else {
                 cli->cl_r_in_flight++;
                 client_obd_list_unlock(&cli->cl_loi_list_lock);
         }
+        return rc;
 }
 
 void mdc_exit_request(struct client_obd *cli)
@@ -528,7 +537,6 @@ void mdc_exit_request(struct client_obd *cli)
         client_obd_list_lock(&cli->cl_loi_list_lock);
         cli->cl_r_in_flight--;
         cfs_list_for_each_safe(l, tmp, &cli->cl_cache_waiters) {
-                
                 if (cli->cl_r_in_flight >= cli->cl_max_rpcs_in_flight) {
                         /* No free request slots anymore */
                         break;
@@ -540,6 +548,6 @@ void mdc_exit_request(struct client_obd *cli)
                 cfs_waitq_signal(&mcw->mcw_waitq);
         }
         /* Empty waiting list? Decrease reqs in-flight number */
-        
+
         client_obd_list_unlock(&cli->cl_loi_list_lock);
 }