mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Tony Luck <tony.luck@intel.com>
Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>,
	Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	corbet@lwn.net
Subject: Re: Remove BKL from FAT/VFAT/MSDOS (v1) (was Re: Fw: Regression caused by bf726e "semaphore: fix,")
Date: Thu, 29 May 2008 14:37:13 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.1.10.0805291413490.3873@woody.linux-foundation.org> (raw)
In-Reply-To: <12c511ca0805291345u4885bd1ycc83bbaa75acfc47@mail.gmail.com>



On Thu, 29 May 2008, Tony Luck wrote:
> 
> This causes a lockup when overwriting an existing file
> on a vfat filesystem.  E.g. for me (where there already
> exists a vmlinux.gz file in the target directory):

Thanks, that was something I didn't test. I just tested various simple 
file create/delete/read/write.

> Looking at fat_setattr() I see it calls lock_super() at the start and releases
> it at the end.  In between is the call to inode_setattr() ... which calls
> down through inode_setattr() and vmtruncate() to fat_truncate() ...
> which calls lock_super() again. Deadlock.

Yup.

And as far as I can tell there is absolutely nothing in fat_setattr() that 
we actually want to protect - it calls things like fat_cont_expand(), but 
that just calls down to the generic VFS layer that uses the pagecache 
functions, and those need to handle the locking correctly for other 
reasons (totally unrelated to setattr - they get called without locking 
for regular writes, after all).

So it looks like the correct fix is to just remove the lock_super() in 
fat_setattr() entirely (along with the "sb" variable that is then no 
longer used).

It *also* turns out that we should remove the lock_super() from 
fat_truncate: all the truncate paths already hold the inode mutex from the 
VFS layer, so the inode data structures themselves would be serialized for 
other reasons. And it only protects the call to "fat_free()", which in 
turn calls the FAT cluster routines ("fatent") that already are protected 
by the fatent spinlock.

More importantly, if it's a filesystem marked DIRSYNC, it will call 
"fat_sync_inode()", which takes the superblock lock (and needs it, because 
it's called frm the VFS layer too) and would deadlock there.

So the end result of that is all the "lock_kernel()" calls in 
fs/fat/file.c should actually just go away - not be replaced by 
lock_super() at alL!

Jonathan, do you want an updated replacement patch, or an incremental one, 
or will you just do that trivial fix yourself?

			Linus

  reply	other threads:[~2008-05-29 21:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20080510121020.f33c83f7.akpm@linux-foundation.org>
     [not found] ` <20080511073338.GA17137@elte.hu>
     [not found]   ` <20080511075522.GA18214@elte.hu>
     [not found]     ` <Pine.LNX.4.64.0805111150250.32758@titan.stealer.net>
     [not found]       ` <20080511125731.GA28174@elte.hu>
     [not found]         ` <alpine.LFD.1.10.0805110941540.3330@woody.linux-foundation.org>
     [not found]           ` <20080511111210.77858eb4.akpm@linux-foundation.org>
     [not found]             ` <alpine.LFD.1.10.0805111221070.3188@woody.linux-foundation.org>
     [not found]               ` <alpine.LFD.1.10.0805111243250.3188@woody.linux-foundation.org>
     [not found]                 ` <20080511235112.GA16101@elte.hu>
     [not found]                   ` <alpine.LFD.1.10.0805120155490.3514@apollo.tec.linutronix.de>
     [not found]                     ` <alpine.LFD.1.10.0805120723440.3188@woody.linux-foundation.org>
     [not found]                       ` <alpine.LFD.1.10.0805121659470.3514@apollo.tec.linutronix.de>
     [not found]                         ` <alpine.LFD.1.10.0805121324410.3019@woody.linux-foundation.org>
     [not found]                           ` <alpine.LFD.1.10.0805161025510.3255@apollo.tec.linutronix.de>
     [not found]                             ` <alpine.LFD.1.10.0805160906580.2941@woody.linux-foundation.org>
     [not found]                               ` <alpine.LFD.1.10.0805160950180.2941@woody.linux-foundation.org>
2008-05-16 22:36                                 ` Linus Torvalds
2008-05-16 22:58                                   ` Linus Torvalds
2008-05-17  0:25                                   ` OGAWA Hirofumi
2008-05-17  1:31                                     ` Linus Torvalds
2008-05-29 20:45                                       ` Tony Luck
2008-05-29 21:37                                         ` Linus Torvalds [this message]
2008-05-29 23:13                                           ` Jonathan Corbet
2008-05-29 23:17                                             ` Linus Torvalds

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=alpine.LFD.1.10.0805291413490.3873@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    /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

all inboxes | Powered by JetHome®