From patchwork Tue May 29 14:43:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10436151 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 249FF601C7 for ; Tue, 29 May 2018 15:16:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1646328587 for ; Tue, 29 May 2018 15:16:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 091B0287F9; Tue, 29 May 2018 15:16:29 +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=unavailable 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 A5C2028587 for ; Tue, 29 May 2018 15:16:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935539AbeE2Ons (ORCPT ); Tue, 29 May 2018 10:43:48 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:35449 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935022AbeE2Onn (ORCPT ); Tue, 29 May 2018 10:43:43 -0400 Received: by mail-wr0-f195.google.com with SMTP id i14-v6so25968561wre.2 for ; Tue, 29 May 2018 07:43:43 -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=FdHYVT+fV4XafqK1kj0xhJHcXKB0VGScbEFzTB/kuqc=; b=mhtxI8lc8HkK8s3eNKfGeU0AMw59YDQ7B7j6IDuVaflNnLcQj+HGfl4smNex//bHWB a/+pcnbs00YsUbfmTnB7M0tWBdIxGu9bpF2rXM2M88YkaBfl7XS8HHg8Fhz+CX9vQS9m +6DJnZ94KrMmip1YY2PtRPSs20hd24oZmA92A2wL2rTzp4wRBz3Vnw5EkUJY7aA5xm+U 2W/Qky6oqZIv/VhIibrnx6OvWmCi4tTQz+OMjxSQKieR4HDgTihfzDjwAK6ejXJKO2SA eeKyWf1uzp4pXL6kY4GsyMAz1gkJffWFNVBlJ33gQ5wkQR1OaB8xS+WGYF0AmrcQa0/3 fnJg== X-Gm-Message-State: ALKqPwf7zbNCd3fH1hpqGK8+vrSvLq0j/6xDR2VJKFrHwIcheFz9uR/5 hw372f56wxbq5T/Mw2cEMWnJUA== X-Google-Smtp-Source: AB8JxZqX2aj39kaH6el8JtaORxW25rYxmonxVCd7SY5hshouVRxfV6ZWwJpizAajFoHH4J73dbGgdg== X-Received: by 2002:adf:e392:: with SMTP id e18-v6mr14144652wrm.94.1527605022403; Tue, 29 May 2018 07:43:42 -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 t198-v6sm18834422wmt.23.2018.05.29.07.43.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 May 2018 07:43:41 -0700 (PDT) From: Miklos Szeredi To: linux-unionfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/39] vfs: dedpue: return loff_t Date: Tue, 29 May 2018 16:43:01 +0200 Message-Id: <20180529144339.16538-2-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180529144339.16538-1-mszeredi@redhat.com> References: <20180529144339.16538-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 f_op->dedupe_file_range() gets a u64 length to dedup and returns an ssize_t actual length deduped. This breaks badly on 32bit archs since the returned length will be truncated and possibly overflow into the sign bit (xfs and ocfs2 are affected, btrfs limits actual length to 16MiB). Returning loff_t should be good, since clone_verify_area() makes sure that the supplied length doesn't overflow. Signed-off-by: Miklos Szeredi --- fs/btrfs/ctree.h | 4 ++-- fs/btrfs/ioctl.c | 6 +++--- fs/ocfs2/file.c | 10 +++++----- fs/read_write.c | 2 +- fs/xfs/xfs_file.c | 2 +- include/linux/fs.h | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0d422c9908b8..990e011c9f0c 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3271,8 +3271,8 @@ void btrfs_get_block_group_info(struct list_head *groups_list, struct btrfs_ioctl_space_info *space); void update_ioctl_balance_args(struct btrfs_fs_info *fs_info, int lock, struct btrfs_ioctl_balance_args *bargs); -ssize_t btrfs_dedupe_file_range(struct file *src_file, u64 loff, u64 olen, - struct file *dst_file, u64 dst_loff); +loff_t btrfs_dedupe_file_range(struct file *src_file, u64 loff, u64 olen, + struct file *dst_file, u64 dst_loff); /* file.c */ int __init btrfs_auto_defrag_init(void); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 632e26d6f7ce..1b5cc5fd4868 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3194,13 +3194,13 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen, #define BTRFS_MAX_DEDUPE_LEN SZ_16M -ssize_t btrfs_dedupe_file_range(struct file *src_file, u64 loff, u64 olen, - struct file *dst_file, u64 dst_loff) +loff_t btrfs_dedupe_file_range(struct file *src_file, u64 loff, u64 olen, + struct file *dst_file, u64 dst_loff) { struct inode *src = file_inode(src_file); struct inode *dst = file_inode(dst_file); u64 bs = BTRFS_I(src)->root->fs_info->sb->s_blocksize; - ssize_t res; + int res; if (olen > BTRFS_MAX_DEDUPE_LEN) olen = BTRFS_MAX_DEDUPE_LEN; diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 6ee94bc23f5b..4a81d82ab7f6 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2537,11 +2537,11 @@ static int ocfs2_file_clone_range(struct file *file_in, len, false); } -static ssize_t ocfs2_file_dedupe_range(struct file *src_file, - u64 loff, - u64 len, - struct file *dst_file, - u64 dst_loff) +static loff_t ocfs2_file_dedupe_range(struct file *src_file, + u64 loff, + u64 len, + struct file *dst_file, + u64 dst_loff) { int error; diff --git a/fs/read_write.c b/fs/read_write.c index c4eabbfc90df..c41e2a1eb7c7 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1976,7 +1976,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) u16 count = same->dest_count; struct file *dst_file; loff_t dst_off; - ssize_t deduped; + loff_t deduped; if (!(file->f_mode & FMODE_READ)) return -EINVAL; diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index e70fb8ccecea..cf51d47efdb6 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -872,7 +872,7 @@ xfs_file_clone_range( len, false); } -STATIC ssize_t +STATIC loff_t xfs_file_dedupe_range( struct file *src_file, u64 loff, diff --git a/include/linux/fs.h b/include/linux/fs.h index 4f637a9b213d..8e49defc7aab 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1738,7 +1738,7 @@ struct file_operations { loff_t, size_t, unsigned int); int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, u64); - ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *, + loff_t (*dedupe_file_range)(struct file *, u64, u64, struct file *, u64); } __randomize_layout;