Fixed a bug where during replay mdt_mfd_open() calls mdt_handle2mfd()
without acquiring the med_open_lock.
We now take the med_open_lock before traversing med_open_head list.
This bug was noticed during the analysis of LU-3233.
Signed-off-by: Swapnil Pimpale <spimpale@ddn.com>
Change-Id: Ib879f65d41d35f266897e8961dac78e6c4f0d9ec
Reviewed-on: http://review.whamcloud.com/7272
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
/*
* Find the mfd pointed to by handle in global hash table.
* In case of replay the handle is obsoleted
/*
* Find the mfd pointed to by handle in global hash table.
* In case of replay the handle is obsoleted
- * but mfd can be found in mfd list by that handle
+ * but mfd can be found in mfd list by that handle.
+ * Callers need to be holding med_open_lock.
*/
struct mdt_file_data *mdt_handle2mfd(struct mdt_export_data *med,
const struct lustre_handle *handle,
*/
struct mdt_file_data *mdt_handle2mfd(struct mdt_export_data *med,
const struct lustre_handle *handle,
* restart replay, so there maybe some orphan
* mfd here, we should remove them */
LASSERT(info->mti_rr.rr_handle != NULL);
* restart replay, so there maybe some orphan
* mfd here, we should remove them */
LASSERT(info->mti_rr.rr_handle != NULL);
+ spin_lock(&med->med_open_lock);
old_mfd = mdt_handle2mfd(med, info->mti_rr.rr_handle, true);
if (old_mfd != NULL) {
CDEBUG(D_HA, "delete orphan mfd = %p, fid = "DFID", "
"cookie = "LPX64"\n", mfd,
PFID(mdt_object_fid(mfd->mfd_object)),
info->mti_rr.rr_handle->cookie);
old_mfd = mdt_handle2mfd(med, info->mti_rr.rr_handle, true);
if (old_mfd != NULL) {
CDEBUG(D_HA, "delete orphan mfd = %p, fid = "DFID", "
"cookie = "LPX64"\n", mfd,
PFID(mdt_object_fid(mfd->mfd_object)),
info->mti_rr.rr_handle->cookie);
- spin_lock(&med->med_open_lock);
class_handle_unhash(&old_mfd->mfd_handle);
cfs_list_del_init(&old_mfd->mfd_list);
spin_unlock(&med->med_open_lock);
class_handle_unhash(&old_mfd->mfd_handle);
cfs_list_del_init(&old_mfd->mfd_list);
spin_unlock(&med->med_open_lock);
mdt_mfd_close(info, old_mfd);
ma->ma_attr_flags &= ~MDS_RECOV_OPEN;
ma->ma_valid &= ~MA_FLAGS;
mdt_mfd_close(info, old_mfd);
ma->ma_attr_flags &= ~MDS_RECOV_OPEN;
ma->ma_valid &= ~MA_FLAGS;
+ } else {
+ spin_unlock(&med->med_open_lock);
+ CDEBUG(D_HA, "orphan mfd not found, fid = "DFID", "
+ "cookie = "LPX64"\n",
+ PFID(mdt_object_fid(mfd->mfd_object)),
+ info->mti_rr.rr_handle->cookie);
}
CDEBUG(D_HA, "Store old cookie "LPX64" in new mfd\n",
}
CDEBUG(D_HA, "Store old cookie "LPX64" in new mfd\n",