Whamcloud - gitweb
LU-657 test: limit the write size in run_dd
[fs/lustre-release.git] / lustre / ofd / ofd_trans.c
index d9f26fe..3112a50 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
+ * Copyright (c) 2012, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -115,12 +115,16 @@ static int ofd_last_rcvd_update(struct ofd_thread_info *info,
        __u64                           *transno_p;
        loff_t                           off;
        int                              err;
+       bool                             lw_client = false;
 
        ENTRY;
 
        LASSERT(ofd);
        LASSERT(info->fti_exp);
 
+       if ((info->fti_exp->exp_connect_flags & OBD_CONNECT_LIGHTWEIGHT) != 0)
+               lw_client = true;
+
        fed = &info->fti_exp->exp_filter_data;
        LASSERT(fed);
        lcd = fed->fed_ted.ted_lcd;
@@ -129,12 +133,12 @@ static int ofd_last_rcvd_update(struct ofd_thread_info *info,
        if (lcd == NULL) {
                CWARN("commit transaction for disconnected client %s: rc %d\n",
                      info->fti_exp->exp_client_uuid.uuid, rc);
-               err = lut_server_data_write(info->fti_env, &ofd->ofd_lut, th);
+               err = tgt_server_data_write(info->fti_env, &ofd->ofd_lut, th);
                RETURN(err);
        }
        /* ofd connect may cause transaction before export has last_rcvd
         * slot */
-       if (fed->fed_ted.ted_lr_idx < 0)
+       if (fed->fed_ted.ted_lr_idx < 0 && !lw_client)
                RETURN(0);
        off = fed->fed_ted.ted_lr_off;
 
@@ -149,17 +153,38 @@ static int ofd_last_rcvd_update(struct ofd_thread_info *info,
         */
        if (info->fti_transno == 0 &&
            *transno_p == ofd->ofd_lut.lut_last_transno) {
-               cfs_spin_lock(&ofd->ofd_lut.lut_translock);
+               spin_lock(&ofd->ofd_lut.lut_translock);
                ofd->ofd_lut.lut_lsd.lsd_last_transno =
                                                ofd->ofd_lut.lut_last_transno;
-               cfs_spin_unlock(&ofd->ofd_lut.lut_translock);
-               lut_server_data_write(info->fti_env, &ofd->ofd_lut, th);
+               spin_unlock(&ofd->ofd_lut.lut_translock);
+               tgt_server_data_write(info->fti_env, &ofd->ofd_lut, th);
        }
 
        *transno_p = info->fti_transno;
-       LASSERT(fed->fed_ted.ted_lr_off > 0);
-       err = lut_client_data_write(info->fti_env, &ofd->ofd_lut, lcd,
+       if (lw_client) {
+               /* Although lightweight (LW) connections have no slot in
+                * last_rcvd, we still want to maintain the in-memory
+                * lsd_client_data structure in order to properly handle reply
+                * reconstruction. */
+               struct lu_target        *tg =&ofd->ofd_lut;
+               bool                     update = false;
+
+               err = 0;
+               /* All operations performed by LW clients are synchronous and
+                * we store the committed transno in the last_rcvd header */
+               spin_lock(&tg->lut_translock);
+               if (info->fti_transno > tg->lut_lsd.lsd_last_transno) {
+                       tg->lut_lsd.lsd_last_transno = info->fti_transno;
+                       update = true;
+               }
+               spin_unlock(&tg->lut_translock);
+               if (update)
+                       err = tgt_server_data_write(info->fti_env, tg, th);
+       } else {
+               LASSERT(fed->fed_ted.ted_lr_off > 0);
+               err = tgt_client_data_write(info->fti_env, &ofd->ofd_lut, lcd,
                                    &off, th);
+       }
 
        RETURN(err);
 }
@@ -191,7 +216,7 @@ int ofd_txn_stop_cb(const struct lu_env *env, struct thandle *txn,
                info->fti_has_trans = 1;
        }
 
-       cfs_spin_lock(&ofd->ofd_lut.lut_translock);
+       spin_lock(&ofd->ofd_lut.lut_translock);
        if (txn->th_result != 0) {
                if (info->fti_transno != 0) {
                        CERROR("Replay transno "LPU64" failed: rc %d\n",
@@ -205,7 +230,7 @@ int ofd_txn_stop_cb(const struct lu_env *env, struct thandle *txn,
                if (info->fti_transno > ofd->ofd_lut.lut_last_transno)
                        ofd->ofd_lut.lut_last_transno = info->fti_transno;
        }
-       cfs_spin_unlock(&ofd->ofd_lut.lut_translock);
+       spin_unlock(&ofd->ofd_lut.lut_translock);
 
        /** VBR: set new versions */
        if (txn->th_result == 0 && info->fti_obj != NULL) {
@@ -219,9 +244,9 @@ int ofd_txn_stop_cb(const struct lu_env *env, struct thandle *txn,
               info->fti_transno, ofd_obd(ofd)->obd_last_committed);
 
        /* if can't add callback, do sync write */
-       txn->th_sync = !!lut_last_commit_cb_add(txn, &ofd->ofd_lut,
-                                               info->fti_exp,
-                                               info->fti_transno);
+       txn->th_sync |= !!tgt_last_commit_cb_add(txn, &ofd->ofd_lut,
+                                                info->fti_exp,
+                                                info->fti_transno);
 
        return ofd_last_rcvd_update(info, txn);
 }