Skip to content

Commit b743d4c

Browse files
Andy Strohmanrisbhat
Andy Strohman
authored andcommitted
lustre: hold lock while walking changelog dev list
This patch came from the 2.10.5 branch of AmazonFSxLustreClient repo. The patch from that repo is: mdc: hold lock while walking changelog dev list (LU-12566) Prevent the following GPF which is causing stuck processes, when running mount and umount concurrently on the same host. general protection fault: 0000 [#1] SMP PTI ... RIP: 0010:mdc_changelog_cdev_finish+0x3f/0x1b9 [mdc] ... Call Trace: mdc_precleanup+0x2a/0x3c0 [mdc] Original patch was: LU-12566 mdc: hold lock while walking changelog dev list In mdc_changelog_cdev_finish() we need chlg_registered_dev_lock while walking and changing entries on the chlog_registered_devs and ced_obds lists in chlg_registered_dev_find_by_obd(). Move the calling of chlg_registered_dev_find_by_obd() under the mutex, and add assertions to the places where the lists are walked and changed that the mutex is held. Lustre-change: https://review.whamcloud.com/35668 Lustre-commit: a260c530801db7f58efa93b774f06b0ce72649a3 Fixes: 1d40214d96dd ("LU-7659 mdc: expose changelog through char devices") Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Change-Id: Ib62fdff87cde6a4bcfb9bea24a2ea72a933ebbe5 Signed-off-by: Minh Diep <mdiep@whamcloud.com> Reviewed-on: https://review.whamcloud.com/35835 Signed-off-by: Andy Strohman <astroh@amazon.com>
1 parent 10ee3f9 commit b743d4c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/staging/lustrefsx/lustre/mdc/mdc_changelog.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ chlg_registered_dev_find_by_name(const char *name)
612612
{
613613
struct chlg_registered_dev *dit;
614614

615+
LASSERT(mutex_is_locked(&chlg_registered_dev_lock));
615616
list_for_each_entry(dit, &chlg_registered_devices, ced_link)
616617
if (strcmp(name, dit->ced_name) == 0)
617618
return dit;
@@ -630,6 +631,7 @@ chlg_registered_dev_find_by_obd(const struct obd_device *obd)
630631
struct chlg_registered_dev *dit;
631632
struct obd_device *oit;
632633

634+
LASSERT(mutex_is_locked(&chlg_registered_dev_lock));
633635
list_for_each_entry(dit, &chlg_registered_devices, ced_link)
634636
list_for_each_entry(oit, &dit->ced_obds,
635637
u.cli.cl_chg_dev_linkage)
@@ -702,6 +704,7 @@ static void chlg_dev_clear(struct kref *kref)
702704
ced_refs);
703705
ENTRY;
704706

707+
LASSERT(mutex_is_locked(&chlg_registered_dev_lock));
705708
list_del(&entry->ced_link);
706709
misc_deregister(&entry->ced_misc);
707710
OBD_FREE_PTR(entry);
@@ -713,10 +716,11 @@ static void chlg_dev_clear(struct kref *kref)
713716
*/
714717
void mdc_changelog_cdev_finish(struct obd_device *obd)
715718
{
716-
struct chlg_registered_dev *dev = chlg_registered_dev_find_by_obd(obd);
717-
ENTRY;
719+
struct chlg_registered_dev *dev;
718720

721+
ENTRY;
719722
mutex_lock(&chlg_registered_dev_lock);
723+
dev = chlg_registered_dev_find_by_obd(obd);
720724
list_del_init(&obd->u.cli.cl_chg_dev_linkage);
721725
kref_put(&dev->ced_refs, chlg_dev_clear);
722726
mutex_unlock(&chlg_registered_dev_lock);

0 commit comments

Comments
 (0)