From patchwork Tue Jun 5 15:46:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10448533 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 B79B8600CA for ; Tue, 5 Jun 2018 15:44:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9CB229464 for ; Tue, 5 Jun 2018 15:44:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E2DC29892; Tue, 5 Jun 2018 15:44:36 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 3227C29464 for ; Tue, 5 Jun 2018 15:44:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751981AbeFEPoU (ORCPT ); Tue, 5 Jun 2018 11:44:20 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35086 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751836AbeFEPoT (ORCPT ); Tue, 5 Jun 2018 11:44:19 -0400 Received: by mail-pf0-f196.google.com with SMTP id c22-v6so1096446pfi.2; Tue, 05 Jun 2018 08:44:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=G5nqoxFWVyQziI069nw10ERBbQaw6t0neVTf+IaDHrM=; b=mm+pLZ22S/O3h4Ce2hlMAnRGwPIHZgbcNniQY1hZ5nRsITGN/e1bu4m8pNnkeCeNMv uJEEUkoixGe4V5DNdXI9PUhca7rfk1Kyue22WR3oK6D9bM9VXGHx+DDtdgo0eA2x+qw9 1fiSKRuUVsFGg2jGe/iBJRof0tWsKHwGp7OoVbVsnvyiPh1esyOJrIMt6NqMAzIRAlIs z3ROZvlYl0i53WWhE5+Tax1Q/6qhjDheXbwpoTGWcNcrzJowwLvexN4Qk6Dvo2d/gA+s bkQ/ALl7b6XpGVqtyzwHSCJqa0B4m7MaqyubtNVZubkEYeag7JsD3jss5p8lPIRQOU23 1VVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=G5nqoxFWVyQziI069nw10ERBbQaw6t0neVTf+IaDHrM=; b=oJ+5Rz8c+b4CttZS2pZ2HLYFWBoeOkNsB4OTiX0S6fGK9sM75KXEnV3MOPaTSEOHaV RcnlxBzS+XgRfim61F5F0vpOfbLH/oPfJS0nohj3HZDyl4LiB00otvEBjXEq3lDA1cgl f7MRuW/3OCn0nV3J66lfnygBltNTUxHehErSljwjFHY92Zf5h0K0kLqDEG37aisJMNnU swnLcxodDIvZbnqWfLIjuNDvEJCZtbCpkT2fTcCnm1uMxG9ugjyLfkkqyzUCgpq0zgGE JRruuKGFLOB6tWf+wrECnGyYFABXkN8XZSkYPp9eXO94fumw+JT7oJuwk1K0JFCSAeLC LPBg== X-Gm-Message-State: APt69E2pIjvVZfYmC7f54vVnVFpEPiZ5crVlXCZ0+cbQJqF2a6hr1iqH dURKVGqXGlWVaeRoryZCxxHY3g== X-Google-Smtp-Source: ADUXVKJr+g9UJsVyzdAHBSonK6jmYFz59fWnispgS4lJlfIEM/pIgLsRH7yzurAzrps8Gt1YBhPDcg== X-Received: by 2002:a62:a8e:: with SMTP id 14-v6mr12038524pfk.57.1528213457985; Tue, 05 Jun 2018 08:44:17 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC ([49.205.218.59]) by smtp.gmail.com with ESMTPSA id 10-v6sm15730288pfs.111.2018.06.05.08.44.14 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Jun 2018 08:44:16 -0700 (PDT) Date: Tue, 5 Jun 2018 21:16:35 +0530 From: Souptick Joarder To: willy@infradead.org, clm@fb.com, jbacik@fb.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fs: btrfs: Change return type to vm_fault_t Message-ID: <20180605154635.GA27201@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use new return type vm_fault_t for fault handler. For now, this is just documenting that the function returns a VM_FAULT value rather than an errno. Once all instances are converted, vm_fault_t will become a distinct type. Ref-> commit 1c8f422059ae ("mm: change return type to vm_fault_t") vmf_error() is the newly introduce inline function in 4.17-rc6. Signed-off-by: Souptick Joarder --- fs/btrfs/ctree.h | 2 +- fs/btrfs/inode.c | 28 +++++++++++++--------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 0d422c9..1f52d9fd 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3218,7 +3218,7 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset, size_t size, struct bio *bio, unsigned long bio_flags); void btrfs_set_range_writeback(void *private_data, u64 start, u64 end); -int btrfs_page_mkwrite(struct vm_fault *vmf); +vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf); int btrfs_readpage(struct file *file, struct page *page); void btrfs_evict_inode(struct inode *inode); int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 0b86cf1..20bde86 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8873,7 +8873,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset, * beyond EOF, then the page is guaranteed safe against truncation until we * unlock the page. */ -int btrfs_page_mkwrite(struct vm_fault *vmf) +vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf) { struct page *page = vmf->page; struct inode *inode = file_inode(vmf->vma->vm_file); @@ -8885,8 +8885,9 @@ int btrfs_page_mkwrite(struct vm_fault *vmf) char *kaddr; unsigned long zero_start; loff_t size; - int ret; + int err; int reserved = 0; + vm_fault_t ret; u64 reserved_space; u64 page_start; u64 page_end; @@ -8907,17 +8908,14 @@ int btrfs_page_mkwrite(struct vm_fault *vmf) * end up waiting indefinitely to get a lock on the page currently * being processed by btrfs_page_mkwrite() function. */ - ret = btrfs_delalloc_reserve_space(inode, &data_reserved, page_start, + err = btrfs_delalloc_reserve_space(inode, &data_reserved, page_start, reserved_space); - if (!ret) { - ret = file_update_time(vmf->vma->vm_file); + if (!err) { + err = file_update_time(vmf->vma->vm_file); reserved = 1; } - if (ret) { - if (ret == -ENOMEM) - ret = VM_FAULT_OOM; - else /* -ENOSPC, -EIO, etc */ - ret = VM_FAULT_SIGBUS; + if (err) { + ret = vmf_error(err); if (reserved) goto out; goto out_noreserve; @@ -8976,15 +8974,15 @@ int btrfs_page_mkwrite(struct vm_fault *vmf) EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG, 0, 0, &cached_state); - ret = btrfs_set_extent_delalloc(inode, page_start, end, 0, + err = btrfs_set_extent_delalloc(inode, page_start, end, 0, &cached_state, 0); - if (ret) { + if (err) { unlock_extent_cached(io_tree, page_start, page_end, &cached_state); ret = VM_FAULT_SIGBUS; goto out_unlock; } - ret = 0; + err = 0; /* page is wholly or partially inside EOF */ if (page_start + PAGE_SIZE > size) @@ -9009,11 +9007,11 @@ int btrfs_page_mkwrite(struct vm_fault *vmf) unlock_extent_cached(io_tree, page_start, page_end, &cached_state); out_unlock: - if (!ret) { + if (!err) { btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, true); sb_end_pagefault(inode->i_sb); extent_changeset_free(data_reserved); - return VM_FAULT_LOCKED; + ret = VM_FAULT_LOCKED; } unlock_page(page); out: