From patchwork Fri Jan 27 21:15:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Moyer X-Patchwork-Id: 138331 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 55963B6F6F for ; Sat, 28 Jan 2012 08:16:02 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753479Ab2A0VP6 (ORCPT ); Fri, 27 Jan 2012 16:15:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33570 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753072Ab2A0VP4 (ORCPT ); Fri, 27 Jan 2012 16:15:56 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0RLFsY5009856 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 27 Jan 2012 16:15:54 -0500 Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.16.60.26]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0RLFsQv026761 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 27 Jan 2012 16:15:54 -0500 Received: from segfault.boston.devel.redhat.com (localhost.localdomain [127.0.0.1]) by segfault.boston.devel.redhat.com (8.14.4/8.14.4) with ESMTP id q0RLFrKM012896; Fri, 27 Jan 2012 16:15:53 -0500 Received: (from jmoyer@localhost) by segfault.boston.devel.redhat.com (8.14.4/8.14.4/Submit) id q0RLFrCV012895; Fri, 27 Jan 2012 16:15:53 -0500 From: Jeff Moyer To: linux-ext4@vger.kernel.org, xfs@oss.sgi.com, linux-fsdevel@vger.kernel.org Cc: Jeff Moyer Subject: [PATCH 3/3] filemap: don't call generic_write_sync for -EIOCBQUEUED Date: Fri, 27 Jan 2012 16:15:49 -0500 Message-Id: <1327698949-12616-4-git-send-email-jmoyer@redhat.com> In-Reply-To: <1327698949-12616-1-git-send-email-jmoyer@redhat.com> References: <1327698949-12616-1-git-send-email-jmoyer@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hi, As it stands, generic_file_aio_write will call into generic_write_sync when -EIOCBQUEUED is returned from __generic_file_aio_write. EIOCBQUEUED indicates that an I/O was submitted but NOT completed. Thus, we will flush the disk cache, potentially before the write(s) even make it to the disk! Up until now, this has been the best we could do, as file systems didn't bother to flush the disk cache after an O_SYNC AIO+DIO write. After applying the prior two patches to xfs and ext4, at least the major two file systems do the right thing. So, let's go ahead and fix this backwards logic. Signed-off-by: Jeff Moyer --- mm/filemap.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index c4ee2e9..004442f 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2634,7 +2634,7 @@ ssize_t generic_file_aio_write(struct kiocb *iocb, const struct iovec *iov, ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); mutex_unlock(&inode->i_mutex); - if (ret > 0 || ret == -EIOCBQUEUED) { + if (ret > 0) { ssize_t err; err = generic_write_sync(file, pos, ret);