Received: by 10.192.165.156 with SMTP id m28csp2090833imm; Thu, 12 Apr 2018 08:27:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+mzqKEdK72PJNR3GGGfJmeNVkB1ziTPLX1nUg4viocPry5S1DHbreJs1kJSMYC+F2HnuYv X-Received: by 10.99.116.74 with SMTP id e10mr1029293pgn.169.1523546866916; Thu, 12 Apr 2018 08:27:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523546866; cv=none; d=google.com; s=arc-20160816; b=yVn+o6lL1ZQXBTNuw2DnoBCyAQCM4PPfFAoRTwoLMUs06DN5UgMenE84/n5eulBLMs uLgYSolAColV4SD7Ru/Kg7ZS5zx+lD7DvCHS87CF4FRXiEXaQoSS1mCz/VfpsHs/sRZH 1WzxpnOvSE0hJ3iBhGd/8/yJmUYB9Xa8OnLltLOH096Qhk+p0lxNC9trSOUOyONpNlk6 DlGS0M0Etyivv6W3YEvv8YUL7JpPP3Z/w8AdXFYD3nWQclzLQk9Iud0u90KfPBkMFqz/ HzuGxddYr6FPMxhFBtML0GP1HMGGzzYB3AMDiBm+rp6NhRsrMxKgKvEF1HAi8KSrRv/E ObdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=6xlVJNVlQUYTNJipT+77HXz6tcjc4xGV3DouaTBb2BA=; b=u/fVnIWfc+hwgJvrS030Kyl5KY2qfzLvTnNc0dvvgtQ9b4Hqxsn/TdNO18fNIAe6fY XB7gYnc7MfwOPSFAX95hG3pukMl5HsA0QCFIPoJ1HpQAxN/Yh3auhpeFsa7RAZo/rA3o TZtd57+RIPi/9liIhEIxNGLX/yDgiLa95wNz17YC2OLtUmIi4YXqFMfrBf20E2ItBFwI NzoqDarDFUsuOFfR9dspoP/Y7VF2HSrt6/AdSz5iaZ6pKAB51rdmxk+2rCEBNF+CUEWc Ts79YL6BwJNRfjgC+o+07x5Cr0NzC1fFkbkcjUpgCW6zdByouxvSZ7j/XPfThyCDH7ur CG9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o26si2431472pgd.418.2018.04.12.08.27.09; Thu, 12 Apr 2018 08:27:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754227AbeDLPVp (ORCPT + 99 others); Thu, 12 Apr 2018 11:21:45 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:45392 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753223AbeDLPIq (ORCPT ); Thu, 12 Apr 2018 11:08:46 -0400 Received: by mail-wr0-f194.google.com with SMTP id u11so5450090wri.12 for ; Thu, 12 Apr 2018 08:08:46 -0700 (PDT) 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; bh=6xlVJNVlQUYTNJipT+77HXz6tcjc4xGV3DouaTBb2BA=; b=qs3rZ5doUnhDBmMX1fA6q7QVxW6YYlWG1atDyXl74a2Ytv/K3XtzIqdMFouj7+AefF IRMp56WTSp82aETtlyDdIr2EwMmeFJ0sniD7H1gTU2r9dQwfxMvPsSE0ES9YiaYDKdz8 eDQ41XrTlz2iY0YDCx7stZxiizBYl6FKN3senmtPE3qa1xyyCDkXJq0J8InRZteFPY7S MvuiPO3Y4NSo3UH4SkD/Czkwr0at8sk+6WzE9uEn/vHQMsr2T5B8hQveV5ZR2zPTwDd1 qx5lqVoZB/z84GQXqu0HpomkjTIZ6QOSimks2zlg8+zM4svoz+v/soqjCWyYN2nRRnQj CYNA== X-Gm-Message-State: ALQs6tDNguUAHPsbRDfvHfhirur/1YSR4lTqFEVwm4kfw0gAN2iC9+2T JVJl+5Vg8+WHjolm3uQ2mBWpsw== X-Received: by 10.223.225.71 with SMTP id f7mr1048302wri.172.1523545725711; Thu, 12 Apr 2018 08:08:45 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-176-63-54-97.catv.broadband.hu. [176.63.54.97]) by smtp.gmail.com with ESMTPSA id p197sm2621783wme.43.2018.04.12.08.08.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Apr 2018 08:08:45 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 12/35] ovl: readd write_iter Date: Thu, 12 Apr 2018 17:08:03 +0200 Message-Id: <20180412150826.20988-13-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180412150826.20988-1-mszeredi@redhat.com> References: <20180412150826.20988-1-mszeredi@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Implement stacked writes. Signed-off-by: Miklos Szeredi --- fs/overlayfs/file.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index a19429c5965d..b98204c1c19c 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -184,9 +184,48 @@ static ssize_t ovl_read_iter(struct kiocb *iocb, struct iov_iter *iter) return ret; } +static ssize_t ovl_write_iter(struct kiocb *iocb, struct iov_iter *iter) +{ + struct file *file = iocb->ki_filp; + struct inode *inode = file_inode(file); + struct fd real; + const struct cred *old_cred; + ssize_t ret; + + if (!iov_iter_count(iter)) + return 0; + + inode_lock(inode); + /* Update mode */ + ovl_copyattr(ovl_inode_real(inode), inode); + ret = file_remove_privs(file); + if (ret) + goto out_unlock; + + ret = ovl_real_file(file, &real); + if (ret) + goto out_unlock; + + old_cred = ovl_override_creds(file_inode(file)->i_sb); + ret = vfs_iter_write(real.file, iter, &iocb->ki_pos, + ovl_iocb_to_rwf(iocb)); + revert_creds(old_cred); + + /* Update size */ + ovl_copyattr(ovl_inode_real(inode), inode); + + fdput(real); + +out_unlock: + inode_unlock(inode); + + return ret; +} + const struct file_operations ovl_file_operations = { .open = ovl_open, .release = ovl_release, .llseek = ovl_llseek, .read_iter = ovl_read_iter, + .write_iter = ovl_write_iter, }; -- 2.14.3