+ if (dt_object_remote(cathandle->lgh_obj)) {
+ /* For remote operation, if we put the llog object
+ * creation in the current transaction, then the
+ * llog object will not be created on the remote
+ * target until the transaction stop, if other
+ * operations start before the transaction stop,
+ * and use the same llog object, will be dependent
+ * on the success of this transaction. So let's
+ * create the llog object synchronously here to
+ * remove the dependency. */
+create_again:
+ down_read_nested(&cathandle->lgh_lock, LLOGH_CAT);
+ loghandle = cathandle->u.chd.chd_current_log;
+ down_write_nested(&loghandle->lgh_lock, LLOGH_LOG);
+ if (cathandle->lgh_stale) {
+ up_write(&loghandle->lgh_lock);
+ up_read(&cathandle->lgh_lock);
+ GOTO(out, rc = -EIO);
+ }
+ if (!llog_exist(loghandle)) {
+ rc = llog_cat_new_log(env, cathandle, loghandle,
+ NULL);
+ if (rc == -ESTALE)
+ cathandle->lgh_stale = 1;
+ }
+ up_write(&loghandle->lgh_lock);
+ up_read(&cathandle->lgh_lock);
+ if (rc == -ESTALE) {
+ rc = llog_cat_update_header(env, cathandle);
+ if (rc != 0)
+ GOTO(out, rc);
+ goto create_again;
+ } else if (rc < 0) {
+ GOTO(out, rc);
+ }
+ } else {
+ rc = llog_declare_create(env,
+ cathandle->u.chd.chd_current_log, th);
+ if (rc)
+ GOTO(out, rc);
+ llog_declare_write_rec(env, cathandle,
+ &lirec->lid_hdr, -1, th);
+ }