From patchwork Wed Jun 6 14:24:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10450321 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 36D7560375 for ; Wed, 6 Jun 2018 14:22:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 254AD29578 for ; Wed, 6 Jun 2018 14:22:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 195872957C; Wed, 6 Jun 2018 14:22:51 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, 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 7ABA1295AB for ; Wed, 6 Jun 2018 14:22:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751988AbeFFOW1 (ORCPT ); Wed, 6 Jun 2018 10:22:27 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:37018 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751907AbeFFOW0 (ORCPT ); Wed, 6 Jun 2018 10:22:26 -0400 Received: by mail-pg0-f67.google.com with SMTP id r21-v6so2772523pgv.4; Wed, 06 Jun 2018 07:22:25 -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=ogS6zgCFvGezkTEOjbY07bmbwsqbQoVyYjWUwrOiYbw=; b=cOakwdgY6GLypHmSO+fTLY2rFROxhzky24fji/P5xKXKzbOqdzn+Ic65x4T65OL1Hs c1LjG30efW+jScwMCcpHMu9d4sbzdM+YZg/ku+5lf46Uz1gyMin2xc4thFEnaKJ3FzRT 8uN7zp5RD3o4sD75d2mSv4NCNOuyIbrf9tfLoFKo1WtJYHoaOl/fmcbesVVylg9toJTi e8i7p6G8oyCsNha/5vJYMWYuEXMkABXEiB/0V533ggmO4DrbNTqj0ywoYwKhWrzPEh5O 8dCgTwoFyCXOy+iCJZV0kswgE298h6VgslbSwyKsljhHSXL/mYkJ3SmLPC041HDvU0Dx R6Xw== 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=ogS6zgCFvGezkTEOjbY07bmbwsqbQoVyYjWUwrOiYbw=; b=mzY3OXVSGN0ioG7SvXt3OoS7Pi3xd+Df/IrviGHxLaXuJLPxzdEUfkiqlDGhyUyDXq degRg0QMBhLiaCEzZ9dvQVlRI9aMGRrk/cpGMcX+kBgPFOejQFua9gUY+ZI7egRCTAbq qvh1qQUscpmR3kw5lMo9+UG+iLw6WEdnFdVwLQhR6UVEHGtjdwcR5IpctPRFlNi8h4ns ZgKgA0vpHpNvZ9Xe2NIPJEIqfac3xdwwrU/Mj3c8Ev8RFq545LXDIN6u9e9mvik2kbbM 16gpzWD5uGu7EL8fzY+oZzqV9kDV5F0fhrmEgVwq96uqz4/wEydAsOzeHKns1MPXz+6C cWdA== X-Gm-Message-State: APt69E0kd6zTifuGwJltGg0Rw6iha94oga83zhtVgnIIxrhtfOB3knSV Kb6EcY8hBedZkHNJI2nZgYzWZg== X-Google-Smtp-Source: ADUXVKIVOzGJYCMQLB4ysDh2gKldwudXIiuADVKoZSi16J9rXvxIJ2mR67cAy4o+eEO8pDJvKjbFKA== X-Received: by 2002:a62:d74d:: with SMTP id v13-v6mr2717477pfl.0.1528294944910; Wed, 06 Jun 2018 07:22:24 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC ([183.82.18.124]) by smtp.gmail.com with ESMTPSA id x8-v6sm15878811pfa.87.2018.06.06.07.22.21 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 06 Jun 2018 07:22:22 -0700 (PDT) Date: Wed, 6 Jun 2018 19:54:44 +0530 From: Souptick Joarder To: willy@infradead.org, clm@fb.com, jbacik@fb.com, dsterba@suse.com, dsterba@suse.cz Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] fs: btrfs: Change return type to vm_fault_t Message-ID: <20180606142444.GA3806@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 --- v2: ret2 is the new temp variable to handle temporary return value within btrfs_page_mkwrite fs/btrfs/ctree.h | 2 +- fs/btrfs/inode.c | 26 ++++++++++++-------------- 2 files changed, 13 insertions(+), 15 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..d9c21e0 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 ret2; 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, + ret2 = btrfs_delalloc_reserve_space(inode, &data_reserved, page_start, reserved_space); - if (!ret) { - ret = file_update_time(vmf->vma->vm_file); + if (!ret2) { + ret2 = 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 (ret2) { + ret = vmf_error(ret2); 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, + ret2 = btrfs_set_extent_delalloc(inode, page_start, end, 0, &cached_state, 0); - if (ret) { + if (ret2) { unlock_extent_cached(io_tree, page_start, page_end, &cached_state); ret = VM_FAULT_SIGBUS; goto out_unlock; } - ret = 0; + ret2 = 0; /* page is wholly or partially inside EOF */ if (page_start + PAGE_SIZE > size) @@ -9009,7 +9007,7 @@ int btrfs_page_mkwrite(struct vm_fault *vmf) unlock_extent_cached(io_tree, page_start, page_end, &cached_state); out_unlock: - if (!ret) { + if (!ret2) { btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, true); sb_end_pagefault(inode->i_sb); extent_changeset_free(data_reserved);