From patchwork Sun Mar 11 12:41:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10274725 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 7B4F1601A0 for ; Sun, 11 Mar 2018 12:41:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 698CD28DEE for ; Sun, 11 Mar 2018 12:41:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B58828DF4; Sun, 11 Mar 2018 12:41:39 +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,FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 D49AE28DEE for ; Sun, 11 Mar 2018 12:41:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932153AbeCKMlg (ORCPT ); Sun, 11 Mar 2018 08:41:36 -0400 Received: from mout.gmx.net ([212.227.15.19]:57845 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932126AbeCKMlf (ORCPT ); Sun, 11 Mar 2018 08:41:35 -0400 Received: from juanniu018037.ss.mogujie.org ([122.225.81.134]) by mail.gmx.com (mrgmx003 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LxPNC-1ebwvK1u8o-016xpb; Sun, 11 Mar 2018 13:41:29 +0100 From: Chengguang Xu To: zyan@redhat.com, idryomov@gmail.com Cc: ceph-devel@vger.kernel.org, Chengguang Xu Subject: [PATCH v2] ceph: sync metadata when having I_DIRTY_DATASYNC flag in fdatasync Date: Sun, 11 Mar 2018 20:41:14 +0800 Message-Id: <1520772074-202412-1-git-send-email-cgxu519@gmx.com> X-Mailer: git-send-email 1.8.3.1 X-Provags-ID: V03:K0:DOv/RczxbdWyPp+eUEOV/tUPDGXTka19FDvdGyo/HtTDCiuFRiD jHWgbOuJb3iVN/8IYBERjL9F8ePZrFqt86EURsbbr/0/oqwUjfFfg5UlQ4/xgWRxW8rGkJX uN+QfCLAbln/L1T0cujigk/78jucMndmzEtVmwZyP7mON+SbNQYedXna8+E2oGH8UzJwa7R hOw+qNw7G5btMNTe1ccmQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:VeM5AoO74Dg=:08/4xdse/woWflt2hmZCYi 4ckB0C1h8sa2SYXaDlkU6M+1N4sCIQo/QKwp7j4opIATliNEhncS7ALGZkGSL52+4+KYq0nF/ /O1tqeDu6c0ABfSKMP65CxJWghlRHhionOOMUX/MyGSN2OL0/x48VdMmDvD84sFznWhIlBcfL UvfS+hXeSZTIQdlYIFPYIRGgoSCg3UsvCvodKC7vsp9YyQAbvu3gNYUhJh6puIcQSIE4VFZfy xwiRCGDG+q7mH6MnRlso6lJqEmDOFkkuDh1MN3JEU8WMinZ/z6q/MM97ci0DpaJjcdhS87IhW uVPzS9w/IpJYD7/QZE3kDUPwclSmaStv0/pyUcQvaA2BeeTkjLR5fe1A+6spJWgjSGpvJDjdD Anz13rP0oriAmOgjNXPnuPhaJjBh28wRJdC+82UNlg7cnk2Kwhspc/58oe3Np9qpDt5U4HpdU WGl/nouB6QvdOVecS1I/6+8XUfxAouDjoZKUGtGZ9Vuz9ZYbY/BuzUUE3CXu4UhDHioPgaj/p TIOoLAcngtRmlLx08nZy0WA3Xd4WxVUub0iHogmOPvU8DdQ8H2bLUpzvNrGgLVS1sFxnnl3JC 35B8xZ3lPnvfP1yxyPoC2qOJU57F7O683cl8eXFOJTqduu62iZye0ALkVQkzdfMqMYmKH0mJP ykyKV9NXWr8ZTVNsk36dGq0fuqLnDl+cbMG5Bu6QjfJqfCZhWuiUb2u283eV4wF+7j37pf44m ZJiSpgmFmzjt8YwhmXWUBpz+KjXV6fhdovkSYDUI+HBfGmOohyDKnDR9Kitd9ExuTfDLzPjbx zwv0WwvGG1T18W2g8MRunDZdoOECg== 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 Add more condition checks for syncing metadata in fsync/fdatasync. 1) if inode is clean then skip metadata sync. 2) if inode is marked I_DIRTY_DATASYNC flag, then should sync metadata even in fdatasync. Signed-off-by: Chengguang Xu --- Changes since v1: - if inode is clean then skip metadata sync. fs/ceph/caps.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 0e5bd3e..d5e4e49 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -2170,7 +2170,10 @@ int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync) if (ret < 0) goto out; - if (datasync) + if (!(inode->i_state & I_DIRTY_ALL)) + goto out; + + if (datasync && !(inode->i_state & I_DIRTY_DATASYNC)) goto out; inode_lock(inode);