Whamcloud - gitweb
LU-7593 target: take ted_lcd_lock after transaction started
[fs/lustre-release.git] / lustre / target / tgt_lastrcvd.c
index 3e4bd00..c3811cd 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -517,7 +513,6 @@ static int tgt_client_data_update(const struct lu_env *env,
                RETURN(PTR_ERR(th));
 
        tti_buf_lcd(tti);
-       mutex_lock(&ted->ted_lcd_lock);
        rc = dt_declare_record_write(env, tgt->lut_last_rcvd,
                                     &tti->tti_buf,
                                     ted->ted_lr_off, th);
@@ -527,6 +522,9 @@ static int tgt_client_data_update(const struct lu_env *env,
        rc = dt_trans_start_local(env, tgt->lut_bottom, th);
        if (rc)
                GOTO(out, rc);
+
+       mutex_lock(&ted->ted_lcd_lock);
+
        /*
         * Until this operations will be committed the sync is needed
         * for this export. This should be done _after_ starting the
@@ -545,9 +543,11 @@ static int tgt_client_data_update(const struct lu_env *env,
 
        tti->tti_off = ted->ted_lr_off;
        rc = tgt_client_data_write(env, tgt, ted->ted_lcd, &tti->tti_off, th);
+
+       mutex_unlock(&ted->ted_lcd_lock);
+
        EXIT;
 out:
-       mutex_unlock(&ted->ted_lcd_lock);
        dt_trans_stop(env, tgt->lut_bottom, th);
        CDEBUG(D_INFO, "%s: update last_rcvd client data for UUID = %s, "
               "last_transno = %llu: rc = %d\n", tgt->lut_obd->obd_name,
@@ -1745,13 +1745,10 @@ int tgt_txn_start_cb(const struct lu_env *env, struct thandle *th,
                 * because a replay slot has not been assigned.  This should be
                 * replaced by dmu_tx_hold_append() when available.
                 */
-               tti->tti_off = atomic_read(&tgt->lut_num_clients) * 8 *
-                               sizeof(struct lsd_reply_data);
                tti->tti_buf.lb_buf = NULL;
                tti->tti_buf.lb_len = sizeof(struct lsd_reply_data);
                dto = dt_object_locate(tgt->lut_reply_data, th->th_dev);
-               rc = dt_declare_record_write(env, dto, &tti->tti_buf,
-                                            tti->tti_off, th);
+               rc = dt_declare_record_write(env, dto, &tti->tti_buf, -1, th);
                if (rc)
                        return rc;
        } else {