From patchwork Mon May 7 08:37:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10383577 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 B50A660159 for ; Mon, 7 May 2018 08:46:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB653286DF for ; Mon, 7 May 2018 08:46:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A088928B24; Mon, 7 May 2018 08:46:20 +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 46D66286DF for ; Mon, 7 May 2018 08:46:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752379AbeEGIqQ (ORCPT ); Mon, 7 May 2018 04:46:16 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:42167 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752154AbeEGIid (ORCPT ); Mon, 7 May 2018 04:38:33 -0400 Received: by mail-wr0-f196.google.com with SMTP id v5-v6so27852106wrf.9 for ; Mon, 07 May 2018 01:38:33 -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=uPogWDndRlHg3v0yCiWwIa3gQHTiykSy4jqYiVlNqIw=; b=swEDo36k0DKXu6zEZaCmWwF/DG+UPeuKJApwU8++gTKqa6LUIp6B+2flZNLjoL6dk+ uqrKtGZYju5Cp6LqB5MAfLI/zx6VH0SDRQQJ21FoHX2/mAEyBjqxf1B2nrJue032Lv8+ yPVnuoL1jWfi7AhoN6VivkfUEvAjHBTlRH9yRdPhPH/bCPhG4uB0WtJIoKznOL0TlhbR oGvKrPB8XrcpAEFm+DMFJcIGxSCMKSSRQMVmSY1gOMdMAt5km5Wsx3AEUXDLzEhJDjp2 58tjtRq774VFtPSMwhTps+ae+kkUcOkKYvIreaiNdbw4lTwCAHQ9yiWS+V6y0KYVY9Av SzEw== X-Gm-Message-State: ALQs6tANe/ENwHaRe1Yf7zhrWIJfGRGCLOr0YAffY6feLHTmmHNQvmDX sEeraROaNrEOE3QaIZwk+Uv7lw== X-Google-Smtp-Source: AB8JxZqjesSFAE79ZzsxLX5i0yQyAd08nzuUmizSBUXwlsDZsiCXHq3eu6rw5SLs6Ffkcz/Xtb784A== X-Received: by 2002:adf:87d4:: with SMTP id c20-v6mr28961597wrc.197.1525682312436; Mon, 07 May 2018 01:38:32 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (C2B0E321.catv.pool.telekom.hu. [194.176.227.33]) by smtp.gmail.com with ESMTPSA id h8-v6sm5908050wmc.16.2018.05.07.01.38.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 May 2018 01:38:31 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 17/35] ovl: add ovl_fallocate() Date: Mon, 7 May 2018 10:37:49 +0200 Message-Id: <20180507083807.28792-18-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180507083807.28792-1-mszeredi@redhat.com> References: <20180507083807.28792-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 b75ee0a3655e..3a85bbfa266a 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -279,6 +279,29 @@ static int ovl_mmap(struct file *file, struct vm_area_struct *vma) return ret; } +static 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_fdget(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, @@ -287,4 +310,5 @@ const struct file_operations ovl_file_operations = { .write_iter = ovl_write_iter, .fsync = ovl_fsync, .mmap = ovl_mmap, + .fallocate = ovl_fallocate, };