Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp851975pxf; Wed, 24 Mar 2021 18:32:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzsY3KI+bVXAhwFfpVTo5/c+DaYv6mqv8gzaPG5yZaKm5KUt+OGmM6Jh0FGRQD/KWCqWJkG X-Received: by 2002:a17:906:ac6:: with SMTP id z6mr6576364ejf.505.1616635939103; Wed, 24 Mar 2021 18:32:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616635939; cv=none; d=google.com; s=arc-20160816; b=GUVM+vn9Ss5uj8roHw89C4Ubofavz7wifZqW+aatvPOZKfa0/9nI59yhF0dhNm2hzU Pm1m4mjpzfj25o/41BT7AX3qzxg/P5/F5Kogb7mIge7Ok7+VIuAqcxGgN1f+W8U6d9F/ Yke3fJBecYrnIP+fvopsGf+jvUAebnOhfjm1D+pD4FWUwHoPJ4nNtQsMH67PsyIg0bZc fv9fJsPkgEH8d5L30vKjCQBdJ6FyzPTdXpllXJTvkbnwq6AO+pLJvfat5TdBq8d3N3Kj 1VXXO4Y97tEcGbuYll4oMNlerxhg2i4t4ZX2O0g455ss+ljYlqkt2k8nj1QnZ1XmqsnX PI/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:abuse-reports-to:tuid:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=20BQzowfl+EV17KeE5cKNXjASBnGS5dOlznN0EaUK4A=; b=JEaUFmJZNTT6OCPy2DiEUZaY69HkceefxCOhfxh04aH7jfNklm88DJTvZKiAodGFrd ljWKa2ysA4GFxnFWuq9dM2SfK3CMLGi2aaszjJpirQroaUCTOmLE2FsmQ4JCKs4ZKLEM MVl5+FjgtdRVA9QvbSuaKTK2tXe3Gv/cTuiXsoZyMy4hB3qMY/yEhx2UCo6ihTozq5j4 fGXPJbYYJMBMhM1FXMbe89p3tnzTqVAxJIvW+W9m7xJauYDm9CpQQp8dh+iCCxGQAtZP VxYfxnasteZidunvfm+08HgZ3FNfi5d0GiG5VSUFWsWlh3qvZIyZ0ibGuBsLNiVMy60/ G78g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n20si3034674ejz.327.2021.03.24.18.31.55; Wed, 24 Mar 2021 18:32:19 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233039AbhCXHuJ (ORCPT + 99 others); Wed, 24 Mar 2021 03:50:09 -0400 Received: from relay.corp-email.com ([222.73.234.233]:32718 "EHLO relay.corp-email.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232939AbhCXHtc (ORCPT ); Wed, 24 Mar 2021 03:49:32 -0400 X-Greylist: delayed 365 seconds by postgrey-1.27 at vger.kernel.org; Wed, 24 Mar 2021 03:49:31 EDT Received: from ([183.47.25.45]) by relay.corp-email.com ((LNX1044)) with ASMTP (SSL) id RAP00019; Wed, 24 Mar 2021 15:43:19 +0800 Received: from GCY-EXS-15.TCL.com (10.74.128.165) by GCY-EXS-09.TCL.com (10.74.128.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 24 Mar 2021 15:43:15 +0800 Received: from [172.16.34.11] (172.16.34.11) by GCY-EXS-15.TCL.com (10.74.128.165) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 24 Mar 2021 15:43:13 +0800 Subject: Re: [PATCH RESEND V12 1/8] fs: Generic function to convert iocb to rw flags To: Alessio Balsini , 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 , , , , References: <24bb27b5804fb64238f2f9c1f3c860d5@sslemail.net> From: Rokudo Yan Message-ID: Date: Wed, 24 Mar 2021 15:43:12 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [172.16.34.11] X-ClientProxiedBy: GCY-EXS-04.TCL.com (10.74.128.154) To GCY-EXS-15.TCL.com (10.74.128.165) tUid: 2021324154319ee4718069e689e9be20fa256228811a6 X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/26/21 12:46 AM, Alessio Balsini wrote: > 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 > Hi, Alessio This change imply IOCB_* and RWF_* flags are properly aligned, which is not true for kernel version 5.4/4.19/4.14. As the patch ("fs: align IOCB_* flags with RWF_* flags") is not back-ported to these stable kernel branches. The issue was found when applying these patches to kernel-5.4(files open with passthrough enabled can't do append write). I think the issue exists in AOSP common kernel too. Could you please fix this? https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ce71bfea207b4d7c21d36f24ec37618ffcea1da8 https://android-review.googlesource.com/c/kernel/common/+/1556243 Thanks yanwu