Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3470926pxb; Mon, 25 Jan 2021 17:54:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEijfKmg3uocVKs7zflB/ry+sjoH4Nr7Aybwai/TFlAEyhowj/zuKv+Tbj3D9gAVkly03f X-Received: by 2002:a50:fc97:: with SMTP id f23mr2888277edq.307.1611626086749; Mon, 25 Jan 2021 17:54:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611626086; cv=none; d=google.com; s=arc-20160816; b=kQs7qV/o4IhuEHRXvQ/nC1ZTHMhQxZI1LT91QYVg0elVPBMMVvToTyqJ1kR05kxAYA +179ZfLN4F4q6QDLh7EflfvBvIlK4DD2eQsc+xrhLzsuzl5UIJsbHgfVmTeLSJvWPrRg D9rmaEhYS3Y+c8R+7c95i1Bf3DUs4gf+T7Vm5A2UFIB5YPAJOz3dpqw9VSu1yBOzyiFt N/SQlNMCzpiCSHJnSE9YVnAKrKy2KeVUVY4fL+M4UEtu5SFlzPC/q1VWynlltY/qJpv5 2pstkkyq79hUaB+XARYIwyyTA3UHtM3cwUEe+ikPxH5NQBL0fMPeaD2rqc1rs1T5z/m0 9+7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iB3FOTkC0uwThb3VNvB3HWCSTcBSlNU3/HpxGPo/J4I=; b=HjYarty5JczfzazdkaDnQGJN/vZ11gjhC8oxmhx3vVPNB0ea+z6CL6fN1k2PvQtmRq x9az2s0kBV4gNjmGYuyO3EzgnaI0Izqr4NhAkELqrsVmfVH2VAEaFAWgLUTZyEgoBRhD R1MYfY2NdXrgwMwKCP+GIMZuZSEA+G8ng2jtiWc+wyld7DRp9N7j9zfSVhfokVxweII0 DH6gi5bwBpvS/wfArOftsyzwNnxAqov+DS/4bvEJcQ5wnpSz4HQVYG0NUHhGgXwkloya svPTTY8Dq+GBc/aq4HzZKum2XAqlpooIsA0tnXfwFyS08DrafuuTi3MFmyd8e9tvLS3w Qb0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@android.com header.s=20161025 header.b="tny51Hq/"; 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 g12si8162557edm.207.2021.01.25.17.54.23; Mon, 25 Jan 2021 17:54:46 -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="tny51Hq/"; 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 S1730913AbhAYQtk (ORCPT + 99 others); Mon, 25 Jan 2021 11:49:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730862AbhAYQqp (ORCPT ); Mon, 25 Jan 2021 11:46:45 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5EA5C0613D6 for ; Mon, 25 Jan 2021 08:46:04 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id 190so11659588wmz.0 for ; Mon, 25 Jan 2021 08:46:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=android.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=iB3FOTkC0uwThb3VNvB3HWCSTcBSlNU3/HpxGPo/J4I=; b=tny51Hq/UYPn60occVED9UjGBfecQ+4oPMD8Ktl/oXyi5U2j6D6eka7CGM/p46QE23 0hLn4J/os6qIlrb1zZTwJBCsnFjDY4ytl6Xyx5SBAE5DLKhcvRWnugqQcPmWBPuJz2pO 70PWjg34zgFTmhQZY1sCpKkqAldfxxDxdztLyo9+hsy/PgSVtd7wWam6BzPFwqjxFTWq MGdEgbK11tuSkhwBPYXB0ym22etODTWvVvHUiP/dOuq98xFCByAQaZp00ug+K03yoKs4 Sx0v5z2NXvHhDnwX3qbFR499GxIYr3jdXjeI+w81LZ+2Vry8yzG+7lunggfUDnpVaDy2 94eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=iB3FOTkC0uwThb3VNvB3HWCSTcBSlNU3/HpxGPo/J4I=; b=PqGLj9dDO7TgfJBvcCEbWFSyPBJKecnfQ9eVWbA92TtCjTDwozi35f72+LgJ/Htcrz yl1eUmY9ahBWbyOUEdHP2D0cbkjoY/hygJospcjyI83Gokzb13ElyDjYuWXEOVB2j6kN lC4G2tUJcIwomBWY6zBm9maUXo5TAnXiF9N2toOCpl1STbOD0TR5J50CONUUULcNausY Na+vCDgdrqQjjLXKmWlbuHhcmgMbX6Y3kgF89GB59HAvNpGoQVNAJSbaGLlQVRz6x5NL fIoKCZpWPDtY25AZ0Uvx5Yk/WKsxlFJBNgsrGuCIe4oGsQtrtq4fQSs1YZlf6SikBtg2 G4WQ== X-Gm-Message-State: AOAM530V4cyj/nwyrS42FDCCKgS5w2rhdU9+JY2bdfGqg/2ry4rI5Krs nwvmBfsNBTVZEBvLI4TyYFhD+g== X-Received: by 2002:a1c:e486:: with SMTP id b128mr956980wmh.136.1611593163573; Mon, 25 Jan 2021 08:46:03 -0800 (PST) Received: from google.com ([2a00:79e0:d:210:4cd4:5994:40fe:253d]) by smtp.gmail.com with ESMTPSA id n16sm22856690wrj.26.2021.01.25.08.46.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 08:46:03 -0800 (PST) Date: Mon, 25 Jan 2021 16:46:01 +0000 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: Re: [PATCH RESEND V12 1/8] fs: Generic function to convert iocb to rw flags Message-ID: References: <20210125153057.3623715-1-balsini@android.com> <20210125153057.3623715-2-balsini@android.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210125153057.3623715-2-balsini@android.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 25, 2021 at 03:30:50PM +0000, Alessio Balsini wrote: > 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 > For some reason lkml.org and lore.kernel.org are not showing this change as part of the thread. Let's see if replying to the email fixes the indexing. Regards, Alessio