Btrfs: remove BUG_ON from get_restripe_target
Subsystems (2)
PATCH 1/1 Btrfs: remove BUG_ON from get_restripe_target
spin_is_locked always returns 0 on non-SMP systems, which causes btrfs to fail the mount. There is documentation pending as to why checking for spin_is_locked is a bad idea:
https://lkml.org/lkml/2012/3/27/413
As this was the only location in fs/btrfs/extent-tree.c that did lock-correctness checking in a BUG_ON, simply remove it.
--- fs/btrfs/extent-tree.c | 3 --- 1 file changed, 3 deletions(-)
fs/btrfs/extent-tree.c +0 -3
@@ -3158,9 +3158,6 @@ static u64 get_restripe_target(struct btrfs_fs_info *fs_info, u64 flags)struct btrfs_balance_control *bctl = fs_info->balance_ctl;u64 target =0 ; -BUG_ON (!mutex_is_locked (&fs_info->volume_mutex) && - !spin_is_locked (&fs_info->balance_lock)); -if (!bctl)return 0 ;
Signature · 1 line
1.7.10.rc3.3.g19a6c
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 23 lines · Bobby Powers
spin_is_lockedalways returns 0 on non-SMP systems, which causes btrfs to fail the mount. There is documentation pending as to why checking forspin_is_lockedis a bad idea:https://lkml.org/lkml/2012/3/27/413
As this was the only location in
fs/btrfs/extent-tree.cthat did lock-correctness checking in aBUG_ON, simply remove it.Signed-off-by Bobby Powers <[email protected]> CC: IlyaDryomov <[email protected]> CC: Chris Mason <[email protected]> CC: Andi Kleen <[email protected]> CC:
[email protected] CC: [email protected] ---fs/btrfs/extent-tree.c| 3 --- 1 file changed, 3 deletions(-)fs/btrfs/extent-tree.c index renamed from fs/btrfs/extent-tree.c +0
-0a844204..c98b073 100644 ---
a/fs/btrfs/extent-tree.c+++b/fs/btrfs/extent-tree.c@@ -3158,9 +3158,6 @@ static u64get_restripe_target(struct btrfs_fs_info *fs_info, u64 flags)structbtrfs_balance_control*bctl =fs_info->balance_ctl; u64 target = 0;fs/btrfs/extent-tree.c index renamed from fs/btrfs/extent-tree.c +0
-1- BUG_ON(!mutex_is_locked(&fs_info->volume_mutex) && -
Quoted 2 lines
!spin_is_locked(&fs_info->balance_lock)); - if (!bctl) return 0;
Why not replace both of these with lockdep_assert_held as Andi suggested in his doc?
- -Jeff
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQIcBAEBAgAGBQJPfOtVAAoJEB57S2MheeWyew4P/ju2FiKPWvFEhShP2BQzmPPL wYoYP9cEmuoJbr1FXnpVXRy3RJsS+Dv9IHyUt2l8WRddO5PeTC08fS3a1PsR6Lky dnDBpOTsvBhdUPClA+9cu9HtNZ488PKALTgNX7kocVYm+vd0vkE54Iv0OWRvIMEA 5nmm/r2MJwgQmTsFwAWojxfiSEJNzRSJ6GXZFbIfwGOaJIx7MmnPg4R3PKU1SZiF ogKIwocfsTA/T7eplK58+EqtQnfTGTKzAbaEQvX/w1ryRRXHqD2zdk2p+zSAtpN6 swnhu156Bb9t2EUPTv9KiYth0BoYhYy9ppdp2Wyh0hX3lYCAP1SrwBVIYCqpvdqr CuipFWmqbupW41IjQc6bjoIwaVlGNsqwDY3NNrjR+kb29k3+/3MT8QH1ZXLhlpTB cUixluE62J8QllW4u3Wa2mLMTqdolcWCCTdh4yUqE+8jxguXUKhoTni1vwApmkru PM158CLPdxWCnDe1TaGcRYcBoweWPl6UDaVj8W+LdSVcYsycZhwehvDg2amX6pdg 9QFUf25PbDzEVw99w3f2hMhRG5pERRheLqPcFUVbnqZYkZBACt9XtIYBINlREoYW ACjr9dJszluF9dEKWOmlKhsah3gAGJJoC5+QU8oR+vpxKdrI+8vQ+NYtVhCr0hVA CO/KEEcwNaobsCWiAbSr
=5Op/
-----END PGP SIGNATURE-----
Quoted 26 lines · Jeff Mahoney
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 22 lines · Bobby Powers
spin_is_lockedalways returns 0 on non-SMP systems, which causes btrfs to fail the mount. =A0There is documentation pending as to why checking forspin_is_lockedis a bad idea:https://lkml.org/lkml/2012/3/27/413
As this was the only location in
fs/btrfs/extent-tree.cthat did lock-correctness checking in aBUG_ON, simply remove it.Signed-off-by Bobby Powers <[email protected]> CC: IlyaDryomov <[email protected]> CC: Chris Mason <[email protected]> CC: Andi Kleen <[email protected]> CC:
[email protected] CC: [email protected] ---fs/btrfs/extent-tree.c| =A0 =A03 --- 1 file changed, 3 deletions(-)fs/btrfs/extent-tree.c index renamed from fs/btrfs/extent-tree.c +0
-0a844204..c98b073 100644 ---
a/fs/btrfs/extent-tree.c+++b/fs/btrfs/extent-tree.c@@ -3158,9 +3158,6 @@ static u64get_restripe_target(struct btrfs_fs_info *fs_info, u64 flags)structbtrfs_balance_control*bctl =3Dfs_info->balance_ctl; u64 target =3D 0;
Quoted 6 lines
Quoted 3 lines
- =A0 =A0
BUG_ON(!mutex_is_locked(&fs_info->volume_mutex) && - !spin_is_locked(&fs_info->balance_lock)); - if (!bctl) return 0;Why not replace both of these with
lockdep_assert_heldas Andi suggested in his doc?
The complication here is that the existing statement was asserting that _either_ volume_mutex was held _or_ balance_lock was held - lockdep_assert_held is defined as:
#define lockdep_assert_held(l) WARN_ON(debug_locks && !lockdep_is_held(=
l))
which doesn't map to the existing logic. Although I could be missing s= omething.
Sorry for the double email, forgot to turn off html mail initially.
yours,
Bobby
Quoted 9 lines
- -Jeff
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
Quoted 14 lines
iQIcBAEBAgAGBQJPfOtVAAoJEB57S2MheeWyew4P/ju2FiKPWvFEhShP2BQzmPPL wYoYP9cEmuoJbr1FXnpVXRy3RJsS+Dv9IHyUt2l8WRddO5PeTC08fS3a1PsR6Lky dnDBpOTsvBhdUPClA+9cu9HtNZ488PKALTgNX7kocVYm+vd0vkE54Iv0OWRvIMEA 5nmm/r2MJwgQmTsFwAWojxfiSEJNzRSJ6GXZFbIfwGOaJIx7MmnPg4R3PKU1SZiF ogKIwocfsTA/T7eplK58+EqtQnfTGTKzAbaEQvX/w1ryRRXHqD2zdk2p+zSAtpN6 swnhu156Bb9t2EUPTv9KiYth0BoYhYy9ppdp2Wyh0hX3lYCAP1SrwBVIYCqpvdqr CuipFWmqbupW41IjQc6bjoIwaVlGNsqwDY3NNrjR+kb29k3+/3MT8QH1ZXLhlpTB cUixluE62J8QllW4u3Wa2mLMTqdolcWCCTdh4yUqE+8jxguXUKhoTni1vwApmkru PM158CLPdxWCnDe1TaGcRYcBoweWPl6UDaVj8W+LdSVcYsycZhwehvDg2amX6pdg 9QFUf25PbDzEVw99w3f2hMhRG5pERRheLqPcFUVbnqZYkZBACt9XtIYBINlREoYW ACjr9dJszluF9dEKWOmlKhsah3gAGJJoC5+QU8oR+vpxKdrI+8vQ+NYtVhCr0hVA CO/KEEcwNaobsCWiAbSr
=3D5Op/
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Apr 4, 2012 at 9:19 PM, Bobby Powers <[email protected]> wr= ote:
Quoted 7 lines · Jeff Mahoney
Quoted 6 lines
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1Quoted 2 lines · Bobby Powers
spin_is_lockedalways returns 0 on non-SMP systems, which causes btrfs to fail the mount. =A0There is documentation pending as to wh=
y
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
checking for
spin_is_lockedis a bad idea:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
As this was the only location in
fs/btrfs/extent-tree.cthat did lock-correctness checking in aBUG_ON, simply remove it.Signed-off-by Bobby Powers <[email protected]> CC: IlyaDryomov <[email protected]> CC: Chris Mason <[email protected]> CC: Andi Kleen <[email protected]> CC:
[email protected] CC: [email protected] ---fs/btrfs/extent-tree.c| =A0 =A03 --- 1 file changed, 3 deletions(-=
)
Quoted 15 lines
Quoted 8 lines
Quoted 8 lines
fs/btrfs/extent-tree.c index renamed from fs/btrfs/extent-tree.c +0
-0a844204..c98b073 100644 ---
a/fs/btrfs/extent-tree.c+++b/fs/btrfs/extent-tree.c@@ -3158,9 +3158,6 @@ static u64get_restripe_target(struct btrfs_fs_info *fs_info, u64 flags)structbtrfs_balance_control*bctl =3Dfs_info->balance_ctl; u64 target =3D 0;Quoted 6 lines
Quoted 3 lines
- =A0 =A0
BUG_ON(!mutex_is_locked(&fs_info->volume_mutex) && - !spin_is_locked(&fs_info->balance_lock)); - if (!bctl) return 0;Why not replace both of these with
lockdep_assert_heldas Andi suggested in his doc?
Quoted 5 lines
The complication here is that the existing statement was asserting that _either_
volume_mutexwas held _or_balance_lockwas held -lockdep_assert_heldis defined as:#define
lockdep_assert_held(l)=A0WARN_ON(debug_locks && !lockdep_is_=
held(l))
Well, I guess it works fine if lockdep.h defines lockdep_is_held(l) for the !LOCKDEP case:
BUG_ON(debug_locks && !lockdep_is_held(&fs_info->volume_mutex) &=
&
!lockdep_is_held(&fs_info->balance_lock));Quoted 1 line
which doesn't map to the existing logic. =A0Although I could be missi=
ng something.
Quoted 29 lines
Sorry for the double email, forgot to turn off html mail initially.
yours,
BobbyQuoted 23 lines
- -Jeff
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/iQIcBAEBAgAGBQJPfOtVAAoJEB57S2MheeWyew4P/ju2FiKPWvFEhShP2BQzmPPL wYoYP9cEmuoJbr1FXnpVXRy3RJsS+Dv9IHyUt2l8WRddO5PeTC08fS3a1PsR6Lky dnDBpOTsvBhdUPClA+9cu9HtNZ488PKALTgNX7kocVYm+vd0vkE54Iv0OWRvIMEA 5nmm/r2MJwgQmTsFwAWojxfiSEJNzRSJ6GXZFbIfwGOaJIx7MmnPg4R3PKU1SZiF ogKIwocfsTA/T7eplK58+EqtQnfTGTKzAbaEQvX/w1ryRRXHqD2zdk2p+zSAtpN6 swnhu156Bb9t2EUPTv9KiYth0BoYhYy9ppdp2Wyh0hX3lYCAP1SrwBVIYCqpvdqr CuipFWmqbupW41IjQc6bjoIwaVlGNsqwDY3NNrjR+kb29k3+/3MT8QH1ZXLhlpTB cUixluE62J8QllW4u3Wa2mLMTqdolcWCCTdh4yUqE+8jxguXUKhoTni1vwApmkru PM158CLPdxWCnDe1TaGcRYcBoweWPl6UDaVj8W+LdSVcYsycZhwehvDg2amX6pdg 9QFUf25PbDzEVw99w3f2hMhRG5pERRheLqPcFUVbnqZYkZBACt9XtIYBINlREoYW ACjr9dJszluF9dEKWOmlKhsah3gAGJJoC5+QU8oR+vpxKdrI+8vQ+NYtVhCr0hVA CO/KEEcwNaobsCWiAbSr
=3D5Op/
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/1 Btrfs, lockdep: get_restripe_target: use lockdep in BUG_ON
In reply to Bobby Powersspin_is_locked always returns 0 on non-SMP systems, which causes btrfs to fail the mount. There is documentation pending as to why checking for spin_is_locked is a bad idea:
https://lkml.org/lkml/2012/3/27/413
The suggested lockdep_assert_held() is not appropriate in this case, as what get_restripe_target() is checking for is that either volume_mutex is held or balance_lock is held. Luckily lockdep_assert_held() is a simple macro:
WARN_ON(debug_locks && !lockdep_is_held(l))
We can mimic the structure in get_restripe_target(), but we need to make sure lockdep_is_held() is defined for the !LOCKDEP case.
--- fs/btrfs/extent-tree.c | 5 +++-- include/linux/lockdep.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)
fs/btrfs/extent-tree.c +3 -2
@@ -24,6 +24,7 @@#include <linux/kthread.h> #include <linux/slab.h> #include <linux/ratelimit.h> +#include <linux/lockdep.h> #include "compat.h" #include "hash.h" #include "ctree.h"
@@ -3158,8 +3159,8 @@ static u64 get_restripe_target(struct btrfs_fs_info *fs_info, u64 flags)struct btrfs_balance_control *bctl = fs_info->balance_ctl;u64 target =0 ; -BUG_ON (!mutex_is_locked (&fs_info->volume_mutex) && - !spin_is_locked (&fs_info->balance_lock)); +BUG_ON (debug_locks && !lockdep_is_held (&fs_info->volume_mutex) && + !lockdep_is_held (&fs_info->balance_lock));if (!bctl)return 0 ;
include/linux/lockdep.h +1 -0
@@ -392,6 +392,7 @@ struct lock_class_key { };#define lockdep_depth (tsk) (0) +#define lockdep_is_held (l) (0)#define lockdep_assert_held (l) do { } while (0)#define lockdep_recursing (tsk) (0)
Signature · 1 line
1.7.10.rc3.3.g19a6c
Re: [PATCH v2] Btrfs, lockdep: get_restripe_target: use lockdep in BUG_ON
On Wed, Apr 4, 2012 at 10:04 PM, Bobby Powers <[email protected]> w= rote:
Quoted 1 line
spin_is_lockedalways returns 0 on non-SMP systems, which causes btrf=
s
Quoted 1 line
to fail the mount. =A0There is documentation pending as to why checki=
ng
I guess I should be explicit in stating that this is a regression, so this patch or something else that addresses it should be pulled into 3.4.
fs/btrfs/extent-tree.c static u64 get_restripe_target(struct btrfs_fs_=
Quoted 39 lines
for
spin_is_lockedis a bad idea:https://lkml.org/lkml/2012/3/27/413
The suggested
lockdep_assert_held()is not appropriate in this case, as whatget_restripe_target()is checking for is that eithervolume_mutexis held orbalance_lockis held. =A0Luckilylockdep_assert_held()is a simple macro:
WARN_ON(debug_locks && !lockdep_is_held(l))We can mimic the structure in
get_restripe_target(), but we need to make surelockdep_is_held()is defined for the !LOCKDEP case.CC Ilya Dryomov <[email protected]>CC Chris Mason <[email protected]>CC Andi Kleen <[email protected]>CC Jeff Mahoney <[email protected]>CC Ingo Molnar <[email protected]>Signed-off-by Bobby Powers <[email protected]>---
=A0fs/btrfs/extent-tree.c =A0| =A0 =A05 +++-- =A0include/linux/lockdep.h | =A0 =A01 + =A02 files changed, 4 insertions(+), 2 deletions(-)fs/btrfs/extent-tree.c +0
-0@@ -24,6 +24,7 @@=A0#include <
linux/kthread.h>
=A0#include <linux/slab.h>
=A0#include <linux/ratelimit.h>
+#include <linux/lockdep.h>
=A0#include "compat.h"
=A0#include "hash.h"
=A0#include "ctree.h"fs/btrfs/extent-tree.c +0
-0@@ -3158,8 +3159,8 @@ static u64 get_restripe_target(struct btrfs_fs_=
info *fs_info, u64 flags)
Quoted 1 line
=A0 =A0 =A0 =A0struct
btrfs_balance_control*bctl =3D fs_info->balanc=
e_ctl;
Quoted 4 lines
=A0 =A0 =A0 =A0u64 target =3D 0;
- =A0 =A0 =A0 BUG_ON(!mutex_is_locked(&fs_info->volume_mutex) &&
- =A0 =A0 =A0 =A0 =A0 =A0 =A0!spin_is_locked(&fs_info->balance_lock))=
;
Quoted 1 line
+ =A0 =A0 =A0 BUG_ON(debug_locks && !lockdep_is_held(&fs_info->volume=
_mutex) &&
Quoted 1 line
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0!lockdep_is_held(&fs_info->balance_lock)=
);
Quoted 12 lines
=A0 =A0 =A0 =A0if (!bctl)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return 0;include/linux/lockdep.h +1
-0@@ -392,6 +392,7 @@ struct lock_class_key { }; =A0#define lockdep_depth(tsk) =A0 =A0 (0) +#define lockdep_is_held (l) =A0 =A0 (0)
Quoted 1 line
=A0#define
lockdep_assert_held(l)=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 do =
{ } while (0)
Quoted 5 lines
=A0#define
lockdep_recursing(tsk)=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (0) --
1.7.10.rc3.3.g19a6c
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" = in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2] Btrfs, lockdep: get_restripe_target: use lockdep in BUG_ON
Quoted 1 line · Bobby Powers
On Wed, Apr 4, 2012 at 10:04 PM, Bobby Powers <[email protected]>=
Quoted 1 line · wrote:
Quoted 1 line
spin_is_lockedalways returns 0 on non-SMP systems, which causes bt=
rfs
Quoted 1 line
Quoted 1 line
to fail the mount. =C2=A0There is documentation pending as to why c=
hecking
Quoted 4 lines
=20
I guess I should be explicit in stating that this is a regression, so this patch or something else that addresses it should be pulled into 3.4.
Yes, this is a regression and spin_is_locked() definitely has to go. I don't have a strong opinion on this assert, if there are objections to v2 I'm OK with ripping that BUG_ON entirely and replacing it with a comment (this function and its callers are WIP).
Thanks,
Ilya
Re: [PATCH v2] Btrfs, lockdep: get_restripe_target: use lockdep in BUG_ON
On Thu, Apr 5, 2012 at 11:51 AM, Ilya Dryomov <[email protected]> wrot= e:
Quoted 4 lines · Bobby Powers
Quoted 1 line
On Wed, Apr 4, 2012 at 10:04 PM, Bobby Powers <[email protected]=
Quoted 1 line · wrote:
Quoted 1 line
spin_is_lockedalways returns 0 on non-SMP systems, which causes b=
trfs
Quoted 1 line
Quoted 1 line
Quoted 1 line
to fail the mount. =A0There is documentation pending as to why che=
cking
Quoted 2 lines
Quoted 2 lines
I guess I should be explicit in stating that this is a regression, s=
o
Quoted 4 lines
Quoted 2 lines
this patch or something else that addresses it should be pulled into 3.4.
Yes, this is a regression and
spin_is_locked()definitely has to go. =
=A0I
Quoted 1 line
don't have a strong opinion on this assert, if there are objections t=
o
Quoted 3 lines
v2 I'm OK with ripping that
BUG_ONentirely and replacing it with a comment (this function and its callers are WIP).
I'm still hitting this BUG_ON after applying this patch on my single CPU AthlonXP x86 system.
I'm running a 3.3.1 kernel merged with the for-linus branch, and had this patch applied.
I am currently testing with the BUG_ON commented out. The btrfs partitions mount without error, and I haven't encountered any immediate issues.
Re: [PATCH v2] Btrfs, lockdep: get_restripe_target: use lockdep in BUG_ON
In reply to Bobby PowersQuoted 65 lines · Bobby Powers
spin_is_lockedalways returns 0 on non-SMP systems, which causes btrfs to fail the mount. There is documentation pending as to why checking forspin_is_lockedis a bad idea:https://lkml.org/lkml/2012/3/27/413
The suggested
lockdep_assert_held()is not appropriate in this case, as whatget_restripe_target()is checking for is that eithervolume_mutexis held orbalance_lockis held. Luckilylockdep_assert_held()is a simple macro:
WARN_ON(debug_locks && !lockdep_is_held(l))We can mimic the structure in
get_restripe_target(), but we need to make surelockdep_is_held()is defined for the !LOCKDEP case.CC Ilya Dryomov <[email protected]>CC Chris Mason <[email protected]>CC Andi Kleen <[email protected]>CC Jeff Mahoney <[email protected]>CC Ingo Molnar <[email protected]>Signed-off-by Bobby Powers <[email protected]>--- fs/btrfs/extent-tree.c | 5 +++-- include/linux/lockdep.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-)fs/btrfs/extent-tree.c +3
-2@@ -24,6 +24,7 @@#include <linux/kthread.h> #include <linux/slab.h> #include <linux/ratelimit.h> +#include <linux/lockdep.h> #include "compat.h" #include "hash.h" #include "ctree.h" @@ -3158,8 +3159,8 @@ static u64 get_restripe_target(struct btrfs_fs_info *fs_info, u64 flags)struct btrfs_balance_control *bctl = fs_info->balance_ctl;u64 target =0 ; -BUG_ON (!mutex_is_locked (&fs_info->volume_mutex) && - !spin_is_locked (&fs_info->balance_lock)); +BUG_ON (debug_locks && !lockdep_is_held (&fs_info->volume_mutex) && + !lockdep_is_held (&fs_info->balance_lock));if (!bctl)return 0 ;include/linux/lockdep.h +1
-0@@ -392,6 +392,7 @@ struct lock_class_key { };#define lockdep_depth (tsk) (0) +#define lockdep_is_held (l) (0)#define lockdep_assert_held (l) do { } while (0)#define lockdep_recursing (tsk) (0)Signature · 1 line
1.7.10.rc3.3.g19a6c
OK, Mitch's report prompted me to actually take a look. This patch is
wrong: by defining lockdep_is_held(l) to 0 in !LOCKDEP case you effectively mimic the behaviour of spin_is_locked() which is what getting us in the first place.
get_restripe_target() interface is WIP so I will replace BUG_ON with a comment and send a patch through btrfs tree.
Thanks,
Ilya
Re: [PATCH v2] Btrfs, lockdep: get_restripe_target: use lockdep in BUG_ON
On Fri, Apr 6, 2012 at 4:05 PM, Ilya Dryomov <[email protected]> wrote= :
Quoted 2 lines · Bobby Powers
Quoted 1 line
spin_is_lockedalways returns 0 on non-SMP systems, which causes btr=
fs
Quoted 1 line
Quoted 1 line
to fail the mount. =A0There is documentation pending as to why check=
ing
Quoted 26 lines
Quoted 26 lines
for
spin_is_lockedis a bad idea:https://lkml.org/lkml/2012/3/27/413
The suggested
lockdep_assert_held()is not appropriate in this case, as whatget_restripe_target()is checking for is that eithervolume_mutexis held orbalance_lockis held. =A0Luckilylockdep_assert_held()is a simple macro:
WARN_ON(debug_locks && !lockdep_is_held(l))We can mimic the structure in
get_restripe_target(), but we need to make surelockdep_is_held()is defined for the !LOCKDEP case.CC Ilya Dryomov <[email protected]>CC Chris Mason <[email protected]>CC Andi Kleen <[email protected]>CC Jeff Mahoney <[email protected]>CC Ingo Molnar <[email protected]>Signed-off-by Bobby Powers <[email protected]>---
=A0fs/btrfs/extent-tree.c =A0| =A0 =A05 +++-- =A0include/linux/lockdep.h | =A0 =A01 + =A02 files changed, 4 insertions(+), 2 deletions(-)
Quoted 13 lines
fs/btrfs/extent-tree.c static u64 get_restripe_target(struct btrfs_fs=
Quoted 13 lines
fs/btrfs/extent-tree.c +0
-0@@ -24,6 +24,7 @@=A0#include <
linux/kthread.h>
=A0#include <linux/slab.h>
=A0#include <linux/ratelimit.h>
+#include <linux/lockdep.h>
=A0#include "compat.h"
=A0#include "hash.h"
=A0#include "ctree.h"fs/btrfs/extent-tree.c +0
-0@@ -3158,8 +3159,8 @@ static u64 get_restripe_target(struct btrfs_fs=
_info *fs_info, u64 flags)
Quoted 1 line
Quoted 1 line
=A0 =A0 =A0 struct
btrfs_balance_control*bctl =3D fs_info->balance_=
ctl;
Quoted 5 lines
Quoted 5 lines
=A0 =A0 =A0 u64 target =3D 0;
- =A0 =A0 BUG_ON(!mutex_is_locked(&fs_info->volume_mutex) &&
- =A0 =A0 =A0 =A0 =A0 =A0!spin_is_locked(&fs_info->balance_lock));
+ =A0 =A0 BUG_ON(debug_locks && !lockdep_is_held(&fs_info->volume_mu=
tex) &&
Quoted 10 lines
Quoted 10 lines
+ =A0 =A0 =A0 =A0 =A0 =A0!lockdep_is_held(&fs_info->balance_lock));
=A0 =A0 =A0 if (!bctl)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0;include/linux/lockdep.h +0
-0@@ -392,6 +392,7 @@ struct lock_class_key { };
Quoted 4 lines
Quoted 4 lines
include/linux/lockdep.h +1
-0=A0#define lockdep_depth(tsk) =A0 (0) +#define lockdep_is_held (l) =A0 (0)=A0#define
lockdep_assert_held(l)=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 do { } while (0)
Quoted 2 lines
Quoted 2 lines
=A0#define
lockdep_recursing(tsk)=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
=A0 =A0 (0)
Quoted 4 lines
Quoted 2 lines
--
1.7.10.rc3.3.g19a6cOK, Mitch's report prompted me to actually take a look. =A0This patch=
is
Quoted 5 lines
wrong: by defining
lockdep_is_held(l)to 0 in !LOCKDEP case you effectively mimic the behaviour ofspin_is_locked()which is what getting us in the first place.
get_restripe_target()interface is WIP so I will replaceBUG_ONwith =
a
Quoted 1 line
comment and send a patch through btrfs tree.
Hah, good point...
Quoted 3 lines
Thanks,
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Ilya