[LU-5453] mdt_attr_set() uses EX lock for slave 0, PW for master and other slaves Created: 05/Aug/14  Updated: 24/Apr/17  Resolved: 26/Feb/15

Status: Resolved
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.7.0
Fix Version/s: Lustre 2.7.0

Type: Bug Priority: Minor
Reporter: John Hammond Assignee: John Hammond
Resolution: Fixed Votes: 0
Labels: dne2, mdt

Severity: 3
Rank (Obsolete): 15176

 Description   

In the striped directory case of mdt_attr_set() we use a EX lock on slave 0 while we use a PW lock on the master inode and the other slaves:

mdt_attr_set()
	__u64 lockpart = MDS_INODELOCK_UPDATE;

	if (ma->ma_attr.la_valid & (LA_MODE|LA_UID|LA_GID))
		lockpart |= MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM;

        lh = &info->mti_lh[MDT_LH_PARENT];
	mdt_lock_reg_init(lh, LCK_PW);

        rc = mdt_object_lock(info, mo, lh, lockpart, MDT_LOCAL_LOCK);
        if (rc != 0)
        	RETURN(rc);

        s0_lh = &info->mti_lh[MDT_LH_LOCAL];
        mdt_lock_reg_init(s0_lh, LCK_EX);
        rc = mdt_lock_slaves(info, mo, LCK_PW, lockpart, s0_lh, &s0_obj, einfo);
        if (rc != 0)
        	GOTO(out_unlock, rc);

Because the locking order is master, slave0, then other slaves this seems prone to causing deadlocks.



 Comments   
Comment by John Hammond [ 06/Aug/14 ]

Please see http://review.whamcloud.com/11353.

Comment by Oleg Drokin [ 07/Aug/14 ]

I think for all intents and purposes EX and PW locs are the same, everything else conflicts with them? So it's a pure cosmetic issue I would think

Comment by John Hammond [ 07/Aug/14 ]

LCK_CR?

Comment by Di Wang [ 11/Aug/14 ]

I agree all of slave lock mode should keep consistency with the master. Could you please explain what deadlock issue you concerned here? The lock order will always be master, then slave (from 0 to n), and each slave can only belong to 1 master.

Comment by John Hammond [ 11/Aug/14 ]

> Could you please explain what deadlock issue you concerned here?

Nothing concrete. I just meant that even with a defined order for objects the ordering of lock modes (weak mode, strong mode, weak mode) seems like trouble.

Comment by Andreas Dilger [ 26/Feb/15 ]

Di, is this still an issue with the new striped directory layout where the master object has separate shard objects 0..N?

Comment by Andreas Dilger [ 26/Feb/15 ]

It looks like this was fixed as part of http://review.whamcloud.com/11353 anyway, which landed in 2.7.0.

Comment by Gerrit Updater [ 24/Apr/17 ]

Wang Shilong (wshilong@ddn.com) uploaded a new patch: https://review.whamcloud.com/26790
Subject: LU-5453 mdt: mdt_reint_setattr() and mdt_attr_set() fixes
Project: fs/lustre-release
Branch: b2_5
Current Patch Set: 1
Commit: 139d70f1587e9058c76f1cbcbd268e8d6d9c6faf

Generated at Sat Feb 10 01:51:37 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.