Whamcloud - gitweb
LU-2237 tests: new test for re-recreating last_rcvd
[fs/lustre-release.git] / lustre / mdc / mdc_lib.c
index 1b6757d..9d09ab6 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -28,6 +26,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/
@@ -152,6 +152,7 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
         rec->cr_suppgid2 = op_data->op_suppgids[1];
         set_mrc_cr_flags(rec, op_data->op_flags & MF_SOM_LOCAL_FLAGS);
         rec->cr_bias     = op_data->op_bias;
+        rec->cr_umask    = cfs_curproc_umask();
 
         mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
 
@@ -166,9 +167,10 @@ void mdc_create_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
 
 static __u64 mds_pack_open_flags(__u32 flags, __u32 mode)
 {
-        __u64 cr_flags = (flags & (FMODE_READ | FMODE_WRITE |
-                                   MDS_OPEN_HAS_EA | MDS_OPEN_HAS_OBJS | 
-                                   MDS_OPEN_OWNEROVERRIDE | MDS_OPEN_LOCK));
+       __u64 cr_flags = (flags & (FMODE_READ | FMODE_WRITE |
+                                  MDS_OPEN_HAS_EA | MDS_OPEN_HAS_OBJS |
+                                  MDS_OPEN_OWNEROVERRIDE | MDS_OPEN_LOCK |
+                                  MDS_OPEN_BY_FID));
         if (flags & O_CREAT)
                 cr_flags |= MDS_OPEN_CREAT;
         if (flags & O_EXCL)
@@ -222,6 +224,7 @@ void mdc_open_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
         rec->cr_suppgid1 = op_data->op_suppgids[0];
         rec->cr_suppgid2 = op_data->op_suppgids[1];
         rec->cr_bias     = op_data->op_bias;
+        rec->cr_umask    = cfs_curproc_umask();
 
         mdc_pack_capa(req, &RMF_CAPA1, op_data->op_capa1);
         /* the next buffer is child capa, which is used for replay,
@@ -326,7 +329,7 @@ void mdc_setattr_pack(struct ptlrpc_request *req, struct md_op_data *op_data,
         struct mdt_rec_setattr *rec;
         struct mdt_ioepoch *epoch;
         struct lov_user_md *lum = NULL;
-        
+
         CLASSERT(sizeof(struct mdt_rec_reint) ==sizeof(struct mdt_rec_setattr));
         rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
         mdc_setattr_pack_rec(rec, op_data);
@@ -501,21 +504,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)