from_kgid(&init_user_ns, current_fsgid()),
cfs_curproc_cap_pack(), rdev, &request);
ll_finish_md_op_data(op_data);
- if (err) {
- /* If the client doesn't know where to create a subdirectory (or
- * in case of a race that sends the RPC to the wrong MDS), the
- * MDS will return -EREMOTE and the client will fetch the layout
- * for the directory, either from the local xattr cache or the
- * MDS, then create the directory on the right MDT. */
- if (err == -EREMOTE) {
- struct lmv_user_md *lum;
- int rc;
-
- ptlrpc_req_finished(request);
- request = NULL;
-
- OBD_ALLOC_PTR(lum);
- if (lum == NULL)
- GOTO(err_exit, err = -ENOMEM);
-
- rc = ll_getxattr_common(dir, XATTR_NAME_DEFAULT_LMV,
- lum, sizeof(*lum),
- OBD_MD_FLXATTR);
- if (rc < 0) {
- OBD_FREE_PTR(lum);
- if (rc == -ENODATA)
- GOTO(err_exit, err);
- else
- GOTO(err_exit, rc);
- }
+ if (err < 0 && err != -EREMOTE)
+ GOTO(err_exit, err);
- ll_i2info(dir)->lli_def_stripe_offset =
- le32_to_cpu(lum->lum_stripe_offset);
- OBD_FREE_PTR(lum);
- goto again;
+ /* If the client doesn't know where to create a subdirectory (or
+ * in case of a race that sends the RPC to the wrong MDS), the
+ * MDS will return -EREMOTE and the client will fetch the layout
+ * of the directory, then create the directory on the right MDT. */
+ if (unlikely(err == -EREMOTE)) {
+ struct ll_inode_info *lli = ll_i2info(dir);
+ struct lmv_user_md *lum;
+ int lumsize;
+ int err2;
+
+ ptlrpc_req_finished(request);
+ request = NULL;
+
+ err2 = ll_dir_getstripe(dir, (void **)&lum, &lumsize, &request,
+ OBD_MD_DEFAULT_MEA);
+ if (err2 == 0) {
+ /* Update stripe_offset and retry */
+ lli->lli_def_stripe_offset = lum->lum_stripe_offset;
+ } else if (err2 == -ENODATA &&
+ lli->lli_def_stripe_offset != -1) {
+ /* If there are no default stripe EA on the MDT, but the
+ * client has default stripe, then it probably means
+ * default stripe EA has just been deleted. */
+ lli->lli_def_stripe_offset = -1;
+ } else {
+ GOTO(err_exit, err);
}
- GOTO(err_exit, err);
+
+ ptlrpc_req_finished(request);
+ request = NULL;
+ goto again;
}
ll_update_times(request, dir);