From patchwork Thu Apr 12 15:08:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10338789 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 D63EB604D4 for ; Thu, 12 Apr 2018 15:19:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAC3626E90 for ; Thu, 12 Apr 2018 15:19:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF9B027968; Thu, 12 Apr 2018 15:19:30 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, 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 5A82126E90 for ; Thu, 12 Apr 2018 15:19:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753478AbeDLPIz (ORCPT ); Thu, 12 Apr 2018 11:08:55 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:51369 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753372AbeDLPIu (ORCPT ); Thu, 12 Apr 2018 11:08:50 -0400 Received: by mail-wm0-f65.google.com with SMTP id u189so12314255wmd.1 for ; Thu, 12 Apr 2018 08:08:49 -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=qNphsVHr8gX6j9/NFW2bGDK5UB2oHxjcPbwF6fLBWyE=; b=rNKTg/z+V8e2anG7zDoZH3dJCPpK1TdwjJlGx5ofN9JO8WzywGlhecZA/7TeLRVbG+ SPAjB0nhhn9gpQABOr7PEviUF4oOv1jPtavFmpyKGwXKp4nVIZhqPcanAZ/7iw38Sr4n XBUWGpjGvNlJ/+ohVhubFjbJw0vOPQtqYFQAtFEmZ+hTimarxRM53qMGDK0fFkfsr2HT YGppv71HWmyFTkHNK0OOZhvhJ/HsgjgwMTftX8KYXBfKBSvJnRI39ivzckFnZjBwRjrK q9HEyODYqwGVYC8jVIDncTzPvfxpAyI0H9T0p0HG6TP5G/niUoSwcrkxKTNwvceMG26N G0sg== X-Gm-Message-State: ALQs6tBBId7woRq5ALekA90qqtI2rYJQEUhgZOSahHc5Zt30ksiKNsyV FMWj0jK/v9ZQGSCZS3Tg2CzPFQ== X-Google-Smtp-Source: AIpwx4/PCFeHUSkYEkEBIlqthpoN8vG3e/CTuUPoBKxDgqIdS3tmQCnWzo3SBYV0NCJnWdeg4dsbNw== X-Received: by 10.28.124.13 with SMTP id x13mr962964wmc.71.1523545729114; Thu, 12 Apr 2018 08:08:49 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Apr 2018 08:08:48 -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 15/35] ovl: readd fallocate Date: Thu, 12 Apr 2018 17:08:06 +0200 Message-Id: <20180412150826.20988-16-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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Implement stacked fallocate. Signed-off-by: Miklos Szeredi --- fs/overlayfs/file.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index f1cc2fdc62c1..05e3e2f80b89 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -268,6 +268,29 @@ static int ovl_mmap(struct file *file, struct vm_area_struct *vma) return ret; } +long ovl_fallocate(struct file *file, int mode, loff_t offset, loff_t len) +{ + struct inode *inode = file_inode(file); + struct fd real; + const struct cred *old_cred; + int ret; + + ret = ovl_real_file(file, &real); + if (ret) + return ret; + + old_cred = ovl_override_creds(file_inode(file)->i_sb); + ret = vfs_fallocate(real.file, mode, offset, len); + revert_creds(old_cred); + + /* Update size */ + ovl_copyattr(ovl_inode_real(inode), inode); + + fdput(real); + + return ret; +} + const struct file_operations ovl_file_operations = { .open = ovl_open, .release = ovl_release, @@ -276,4 +299,5 @@ const struct file_operations ovl_file_operations = { .write_iter = ovl_write_iter, .fsync = ovl_fsync, .mmap = ovl_mmap, + .fallocate = ovl_fallocate, };