2021-02-11 09:56:29

by Alexander Lochmann

[permalink] [raw]
Subject: [PATCH v2] Updated locking documentation for journal_t

Some members of transaction_t are allowed to be read without
any lock being held if consistency doesn't matter.
Based on LockDoc's findings, we extended the locking
documentation of those members.
Each one of them is marked with a short comment:
"no lock for quick racy checks".

Signed-off-by: Alexander Lochmann <[email protected]>
Signed-off-by: Horst Schirmeier <[email protected]>
Reviewed-by: Jan Kara <[email protected]>
---
include/linux/jbd2.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 18f77d9b1745..4dca33a063dd 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -768,7 +768,7 @@ enum passtype {PASS_SCAN, PASS_REVOKE, PASS_REPLAY};
struct journal_s
{
/**
- * @j_flags: General journaling state flags [j_state_lock]
+ * @j_flags: General journaling state flags [j_state_lock, no lock for
quick racy checks]
*/
unsigned long j_flags;

@@ -808,7 +808,7 @@ struct journal_s
/**
* @j_barrier_count:
*
- * Number of processes waiting to create a barrier lock [j_state_lock]
+ * Number of processes waiting to create a barrier lock [j_state_lock,
no lock for quick racy checks]
*/
int j_barrier_count;

@@ -821,7 +821,7 @@ struct journal_s
* @j_running_transaction:
*
* Transactions: The current running transaction...
- * [j_state_lock] [caller holding open handle]
+ * [j_state_lock, no lock for quick racy checks] [caller holding open
handle]
*/
transaction_t *j_running_transaction;

@@ -1033,7 +1033,7 @@ struct journal_s
* @j_commit_sequence:
*
* Sequence number of the most recently committed transaction
- * [j_state_lock].
+ * [j_state_lock, no lock for quick racy checks].
*/
tid_t j_commit_sequence;

@@ -1041,7 +1041,7 @@ struct journal_s
* @j_commit_request:
*
* Sequence number of the most recent transaction wanting commit
- * [j_state_lock]
+ * [j_state_lock, no lock for quick racy checks]
*/
tid_t j_commit_request;

--
2.20.1




Attachments:
OpenPGP_signature (855.00 B)
OpenPGP digital signature

2021-03-17 20:59:26

by Alexander Lochmann

[permalink] [raw]
Subject: Re: [PATCH v2] Updated locking documentation for journal_t

Does this patch look good to you?
Might it be ready to be merged?

- Alex

On 11.02.21 10:51, Alexander Lochmann wrote:
> Some members of transaction_t are allowed to be read without
> any lock being held if consistency doesn't matter.
> Based on LockDoc's findings, we extended the locking
> documentation of those members.
> Each one of them is marked with a short comment:
> "no lock for quick racy checks".
>
> Signed-off-by: Alexander Lochmann <[email protected]>
> Signed-off-by: Horst Schirmeier <[email protected]>
> Reviewed-by: Jan Kara <[email protected]>
> ---
>  include/linux/jbd2.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
> index 18f77d9b1745..4dca33a063dd 100644
> --- a/include/linux/jbd2.h
> +++ b/include/linux/jbd2.h
> @@ -768,7 +768,7 @@ enum passtype {PASS_SCAN, PASS_REVOKE, PASS_REPLAY};
>  struct journal_s
>  {
>      /**
> -     * @j_flags: General journaling state flags [j_state_lock]
> +     * @j_flags: General journaling state flags [j_state_lock, no lock
> for quick racy checks]
>       */
>      unsigned long        j_flags;
>
> @@ -808,7 +808,7 @@ struct journal_s
>      /**
>       * @j_barrier_count:
>       *
> -     * Number of processes waiting to create a barrier lock [j_state_lock]
> +     * Number of processes waiting to create a barrier lock
> [j_state_lock, no lock for quick racy checks]
>       */
>      int            j_barrier_count;
>
> @@ -821,7 +821,7 @@ struct journal_s
>       * @j_running_transaction:
>       *
>       * Transactions: The current running transaction...
> -     * [j_state_lock] [caller holding open handle]
> +     * [j_state_lock, no lock for quick racy checks] [caller holding
> open handle]
>       */
>      transaction_t        *j_running_transaction;
>
> @@ -1033,7 +1033,7 @@ struct journal_s
>       * @j_commit_sequence:
>       *
>       * Sequence number of the most recently committed transaction
> -     * [j_state_lock].
> +     * [j_state_lock, no lock for quick racy checks].
>       */
>      tid_t            j_commit_sequence;
>
> @@ -1041,7 +1041,7 @@ struct journal_s
>       * @j_commit_request:
>       *
>       * Sequence number of the most recent transaction wanting commit
> -     * [j_state_lock]
> +     * [j_state_lock, no lock for quick racy checks]
>       */
>      tid_t            j_commit_request;
>

--
Technische Universität Dortmund
Alexander Lochmann PGP key: 0xBC3EF6FD
Otto-Hahn-Str. 16 phone: +49.231.7556141
D-44227 Dortmund fax: +49.231.7556116
http://ess.cs.tu-dortmund.de/Staff/al

2021-04-02 15:41:32

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH v2] Updated locking documentation for journal_t

On Thu, Feb 11, 2021 at 10:51:55AM +0100, Alexander Lochmann wrote:
> Some members of transaction_t are allowed to be read without
> any lock being held if consistency doesn't matter.
> Based on LockDoc's findings, we extended the locking
> documentation of those members.
> Each one of them is marked with a short comment:
> "no lock for quick racy checks".
>
> Signed-off-by: Alexander Lochmann <[email protected]>
> Signed-off-by: Horst Schirmeier <[email protected]>
> Reviewed-by: Jan Kara <[email protected]>

Thanks, applied. I had to fix up the patch, which was mailer-damaged,
and I also reflowed the comments.

- Ted