From patchwork Thu Sep 1 01:01:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 9308181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6F7D7601C0 for ; Thu, 1 Sep 2016 01:01:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FCA7290A7 for ; Thu, 1 Sep 2016 01:01:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5172529109; Thu, 1 Sep 2016 01:01:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACF9D290A7 for ; Thu, 1 Sep 2016 01:01:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754643AbcIABBh (ORCPT ); Wed, 31 Aug 2016 21:01:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:40423 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753885AbcIABBg (ORCPT ); Wed, 31 Aug 2016 21:01:36 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9AEDEAAF1; Thu, 1 Sep 2016 01:01:34 +0000 (UTC) From: NeilBrown To: Jeff Layton , "Yan\, Zheng" , Sage Weil , Ilya Dryomov Date: Thu, 01 Sep 2016 11:01:26 +1000 Cc: ceph-devel@vger.kernel.org Subject: Re: [PATCH 1/2] cephfs: ignore error from invalidate_inode_pages2_range() in direct write. In-Reply-To: <1472651257.5795.5.camel@redhat.com> References: <874m61eje0.fsf@notabene.neil.brown.name> <871t15ej9y.fsf@notabene.neil.brown.name> <1472651257.5795.5.camel@redhat.com> User-Agent: Notmuch/0.22 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-suse-linux-gnu) Message-ID: <87pooocu1l.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Wed, Aug 31 2016, Jeff Layton wrote: > > Good catch. Even better might be to just declare a int ret2 and not > clobber "ret" at all. Like the following? Must better, yes. > > Clearly, mixing buffered and direct I/O is gross, but I suppose you > could hit the occasional problem here with a real workload > occasionally. > > Should this go to stable? The patch seems safe enough. Hardly seems worth it, but certainly safe enough. > > Reviewed-by: Jeff Layton Thanks, NeilBrown From: NeilBrown Subject: [PATCH] cephfs: ignore error from invalidate_inode_pages2_range() in direct write. This call can fail if there are dirty pages. The preceding call to filemap_write_and_wait_range() will normally remove dirty pages, but as inode_lock() is not held over calls to ceph_direct_read_write(), it could race with non-direct writes and pages could be dirtied immediately after filemap_write_and_wait_range() returns If there are dirty pages, they will be removed by the subsequent call to truncate_inode_pages_range(), so having them here is not a problem. If the 'ret' value is left holding an error, then in the async IO case (aio_req is not NULL) the loop that would normally call ceph_osdc_start_request() will see the error in 'ret' and abort all requests. This doesn't seem like correct behaviour. So use separate 'ret2' instead of overloading 'ret' Signed-off-by: NeilBrown Reviewed-by: Jeff Layton --- fs/ceph/file.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 0f5375d8e030..395c7fcb1cea 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -902,10 +902,10 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter, return ret; if (write) { - ret = invalidate_inode_pages2_range(inode->i_mapping, + int ret2 = invalidate_inode_pages2_range(inode->i_mapping, pos >> PAGE_SHIFT, (pos + count) >> PAGE_SHIFT); - if (ret < 0) + if (ret2 < 0) dout("invalidate_inode_pages2_range returned %d\n", ret); flags = CEPH_OSD_FLAG_ORDERSNAP |