From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Mason Subject: Re: [PATCH 2 of 8] Change O_DIRECT to use placeholders instead of i_mutex/i_alloc_sem locking Date: Wed, 7 Feb 2007 15:22:28 -0500 Message-ID: <20070207202228.GE11967@think.oraclecorp.com> References: <5cd028318654931ba2e1.1170811967@opti.oraclecorp.com> <60760703-05BD-419C-A37D-2A084287D0F9@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org To: Zach Brown Return-path: Received: from agminet01.oracle.com ([141.146.126.228]:22153 "EHLO agminet01.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422767AbXBGUYC (ORCPT ); Wed, 7 Feb 2007 15:24:02 -0500 Content-Disposition: inline In-Reply-To: <60760703-05BD-419C-A37D-2A084287D0F9@oracle.com> Sender: linux-fsdevel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On Wed, Feb 07, 2007 at 03:11:02PM -0500, Zach Brown wrote: [ cleanups, sure ] > >+ if (inode->i_mapping->nrpages || > >+ mapping_mapped(inode->i_mapping)) > >+ dio->fspages_span = DIO_PAGES; > >+ else > >+ dio->fspages_span = ULONG_MAX; > > Couldn't the decision to use DIO_PAGES in the presence of a mapping > race with establishing a mapping? I fear we have to use DIO_PAGES > all the time, which at least has the benefit of getting rid of the > _span member of dio :). The test case Linus sent me boils down to this: fd = open(file) buffer = mmap(fd, 128 pages); close(fd); fd = open(file, O_DIRECT); write(fd, buffer, 66 pages); I think the deadlock is limited to cases where get_user_pages will get stuck in filemap_nopage waiting for placeholders inserted by this DIO. It looks like that can only happen when buffer is mapped at the start of the dio. Outside of some futuristic async syscall system, are there ways for the buffer to get mmaped during the DIO? -chris