Linux filesystem development
 help / color / mirror / Atom feed
From: Bob Peterson <rpeterso@redhat.com>
To: linux-fsdevel <linux-fsdevel@vger.kernel.org>, tj <tj@kernel.org>
Cc: Andreas Gruenbacher <agruenba@redhat.com>
Subject: locking (or LOCKDEP) problem with mark_buffer_dirty()
Date: Thu, 14 Jan 2021 10:25:56 -0500 (EST)	[thread overview]
Message-ID: <1403463545.44592876.1610637956402.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <330231792.44586135.1610635888053.JavaMail.zimbra@redhat.com>

Hi Tejun and linux-fsdevel,

I have a question about function mark_buffer_dirty and LOCKDEP.

Background: Func mark_buffer_dirty() has a calling sequence that looks kind
of like this (simplified):

mark_buffer_dirty()
   __set_page_dirty()
      account_page_dirtied()
         inode_to_wb() which contains:
#ifdef CONFIG_LOCKDEP
	WARN_ON_ONCE(debug_locks &&
		     (!lockdep_is_held(&inode->i_lock) &&
		      !lockdep_is_held(&inode->i_mapping->i_pages.xa_lock) &&
		      !lockdep_is_held(&inode->i_wb->list_lock)));
#endif
   ...
   __mark_inode_dirty()
      spin_lock(&inode->i_lock);
      ...
      spin_unlock(&inode->i_lock);
   ...      

The LOCKDEP checks were added with Tejun Heo's 2015 patch, aaa2cacf8184e2a92accb8e443b1608d65f9a13f.

Since mark_buffer_dirty()'s call to __mark_inode_dirty() locks the inode->i_lock,
functions must not call mark_buffer_dirty() with inode->i_lock locked: or deadlock.

If they're not doing anything with the xarrays or the i_wb list (i.e. holding the
other two locks), they get these LOCKDEP warnings.

So either:
(a) the LOCKDEP warnings are not valid in all cases -or-
(b) mark_buffer_dirty() should be grabbing inode->i_lock at some point like __mark_inode_dirty() does.

My question is: which is it, a or b? TIA.

(My situation is that the gfs2 file system gets these LOCKDEP warnings
when it calls mark_buffer_dirty() [obviously only if LOCKDEP is set], and it's
not appropriate to lock xa_lock or i_wb->list_lock, and we cannot lock i_lock
for the reasons stated above).

Regards,

Bob Peterson
GFS2 File System


       reply	other threads:[~2021-01-14 15:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <330231792.44586135.1610635888053.JavaMail.zimbra@redhat.com>
2021-01-14 15:25 ` Bob Peterson [this message]
2021-01-15 22:18   ` locking (or LOCKDEP) problem with mark_buffer_dirty() Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1403463545.44592876.1610637956402.JavaMail.zimbra@redhat.com \
    --to=rpeterso@redhat.com \
    --cc=agruenba@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox