Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3134278pxb; Mon, 25 Jan 2021 07:49:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJymnbgCY0lhvK7dFRmgAO7qJrdDMsPgPk34dD8mhDBFym5G1+GR/ZclONLVdw86nTG61r8O X-Received: by 2002:a17:906:3b82:: with SMTP id u2mr816567ejf.66.1611589795918; Mon, 25 Jan 2021 07:49:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611589795; cv=none; d=google.com; s=arc-20160816; b=v3UePL6u+YoJoBU7l+3PWHXvF1u0AyVcJxtRVu0mKYLzLh0kYn/9qSa7HtZbJnPaO9 M700f4A2nt3Ts/AUGy4nnGkv1kTyvfytmpirIWtliiQS/RYc57RCngU01eyTC51aIWBi +HbLquMl2NygAdEbLefbpWx/ONhs6nX3aB+5sM8YAqXSyGKd+hXLF8edE8ShZMEGGUSZ iTQREWzsT51OYPuTifHfd62OwEtIl+PuUnuHkTUHWvvdz8jofRUFyOdldo0nYx4W3uNO 80bf6VN4WGDR0wkfJ23QFiKEvhV9pei1ItZewyvgi42sfwpLIEuKuQ5e7jBs28GQ3ZwE RL7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PmbAjVrlHcxm5n/bwgc2+WaEfTI9G00ILEGpn8g1B2s=; b=RMg4AeQvRFPiW6JCFz4B5+eVi0SJlQjSI7yalJBJy9QKaFiDkNCypG5LIIdHdC4Z39 vJa6ZEk4YlsHqnoOO4BeRCaijLg4dyff8wgt02g1MldAl2vIo8gELiPNG7nCoMRXRsJw RTwyrSEekGYp0FIvwwiJE5061IuQ1e24q8rm5SucE75papkgNS6UCCN1gh8UnhN1T3UM fOlBQDQPkiFkbvDm8yTDnPFol53E85NAAGtkuYyubUue++fsnjrJGI4/hDP77ibBCiY7 7OR5RnEnsrUim8UsTEfQ+wM+pT3tivQGvz+Hk9n/7HevQCkeVKteSDDxs5m3kSvlLCIN Ks9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=pIm9gqCv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=android.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v17si8294342eda.444.2021.01.25.07.49.25; Mon, 25 Jan 2021 07:49:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b=pIm9gqCv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=android.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730416AbhAYPrP (ORCPT + 99 others); Mon, 25 Jan 2021 10:47:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730284AbhAYPnR (ORCPT ); Mon, 25 Jan 2021 10:43:17 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1329C061A2B for ; Mon, 25 Jan 2021 07:31:09 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id g10so13075727wrx.1 for ; Mon, 25 Jan 2021 07:31:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PmbAjVrlHcxm5n/bwgc2+WaEfTI9G00ILEGpn8g1B2s=; b=pIm9gqCvzmGTZV5I8GJ9+T38akNqP4Kv15XEl58FJ71C/wUV1CO5KYx/nMnV+i2/Dl qR2HzLG4y6z8xn0KKJTNhw+HMKNivW1uUtcHd/LVwJU2m75Pa8XWF/gbDmrjTAHHSAQB pESLS8gsM5Zh1RQTbjNVUuQ8f0u3ZUcRXrdhanvhM1fE3iby45cDBitZOFJxTUgVjEtE slJ2S+nlFGi9dlw8duihGV4vSBlSBRqAXj9oVWCHXwFqB+T0nzSL3cNK00yvheytIjHv mryS+brTv1Gwdzcj6szMHZa3XFA9yisIsdG0ipRLdGZQfi4Qrm/qn8OcwJ9oRhgUJrmY k4YA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PmbAjVrlHcxm5n/bwgc2+WaEfTI9G00ILEGpn8g1B2s=; b=gMyjOetGn0ZA3f9OtmhwArUpoTANK/Uxg0QOmyk0vkXRmeJz/2REr/mHaJIZgKz6tK dwAClmiU4+CJ0bZjLFbHhrhqOJgM7RC1Ud4+F6GAAC3ovqiNedYwQ8igLjIqYXmNQJtA W2umr1vdeXwMk/gYOL2qH/S2Rh61wV9FacEw1rM83ZIaKFBv0WjkpTcFHQ4l/CaMAFB3 xWZjL2Qs0+Ne3QxHGR2E07FU7CYsR/GwoE/gZg6mcWj3fqpzaLkiqyVhfXvTlFcLBEAb 4yR7qrB9vztF5kc7M/7oYIQaD+AIAT4gyBKOb8AewEQ7ueFSwXqvnn6oxnByEVp0C7cL Kr5A== X-Gm-Message-State: AOAM531y3xbBxznydVgA7kQyolC4XfBp2KY1Dev29FVAKfFeHrC/v4OC ejb2HIHtDy3CymjQw3Tp1MXiUg== X-Received: by 2002:adf:fc8a:: with SMTP id g10mr1632693wrr.189.1611588668411; Mon, 25 Jan 2021 07:31:08 -0800 (PST) Received: from balsini.lon.corp.google.com ([2a00:79e0:d:210:4cd4:5994:40fe:253d]) by smtp.gmail.com with ESMTPSA id o14sm22611965wri.48.2021.01.25.07.31.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 07:31:08 -0800 (PST) From: Alessio Balsini To: Miklos Szeredi Cc: Akilesh Kailash , Amir Goldstein , Antonio SJ Musumeci , David Anderson , Giuseppe Scrivano , Jann Horn , Jens Axboe , Martijn Coenen , Palmer Dabbelt , Paul Lawrence , Peng Tao , Stefano Duo , Zimuzo Ezeozue , wuyan , fuse-devel@lists.sourceforge.net, kernel-team@android.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND V12 1/8] fs: Generic function to convert iocb to rw flags Date: Mon, 25 Jan 2021 15:30:50 +0000 Message-Id: <20210125153057.3623715-2-balsini@android.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog In-Reply-To: <20210125153057.3623715-1-balsini@android.com> References: <20210125153057.3623715-1-balsini@android.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org OverlayFS implements its own function to translate iocb flags into rw flags, so that they can be passed into another vfs call. With commit ce71bfea207b4 ("fs: align IOCB_* flags with RWF_* flags") Jens created a 1:1 matching between the iocb flags and rw flags, simplifying the conversion. Reduce the OverlayFS code by making the flag conversion function generic and reusable. Signed-off-by: Alessio Balsini --- fs/overlayfs/file.c | 23 +++++------------------ include/linux/fs.h | 5 +++++ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index bd9dd38347ae..56be2ffc5a14 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -15,6 +15,8 @@ #include #include "overlayfs.h" +#define OVL_IOCB_MASK (IOCB_DSYNC | IOCB_HIPRI | IOCB_NOWAIT | IOCB_SYNC) + struct ovl_aio_req { struct kiocb iocb; struct kiocb *orig_iocb; @@ -236,22 +238,6 @@ static void ovl_file_accessed(struct file *file) touch_atime(&file->f_path); } -static rwf_t ovl_iocb_to_rwf(int ifl) -{ - rwf_t flags = 0; - - if (ifl & IOCB_NOWAIT) - flags |= RWF_NOWAIT; - if (ifl & IOCB_HIPRI) - flags |= RWF_HIPRI; - if (ifl & IOCB_DSYNC) - flags |= RWF_DSYNC; - if (ifl & IOCB_SYNC) - flags |= RWF_SYNC; - - return flags; -} - static void ovl_aio_cleanup_handler(struct ovl_aio_req *aio_req) { struct kiocb *iocb = &aio_req->iocb; @@ -299,7 +285,8 @@ static ssize_t ovl_read_iter(struct kiocb *iocb, struct iov_iter *iter) old_cred = ovl_override_creds(file_inode(file)->i_sb); if (is_sync_kiocb(iocb)) { ret = vfs_iter_read(real.file, iter, &iocb->ki_pos, - ovl_iocb_to_rwf(iocb->ki_flags)); + iocb_to_rw_flags(iocb->ki_flags, + OVL_IOCB_MASK)); } else { struct ovl_aio_req *aio_req; @@ -356,7 +343,7 @@ static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) if (is_sync_kiocb(iocb)) { file_start_write(real.file); ret = vfs_iter_write(real.file, iter, &iocb->ki_pos, - ovl_iocb_to_rwf(ifl)); + iocb_to_rw_flags(ifl, OVL_IOCB_MASK)); file_end_write(real.file); /* Update size */ ovl_copyattr(ovl_inode_real(inode), inode); diff --git a/include/linux/fs.h b/include/linux/fs.h index fd47deea7c17..647c35423545 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3275,6 +3275,11 @@ static inline int kiocb_set_rw_flags(struct kiocb *ki, rwf_t flags) return 0; } +static inline rwf_t iocb_to_rw_flags(int ifl, int iocb_mask) +{ + return ifl & iocb_mask; +} + static inline ino_t parent_ino(struct dentry *dentry) { ino_t res; -- 2.30.0.280.ga3ce27912f-goog