From patchwork Tue Sep 30 22:01:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 5008501 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CB12ABEEA6 for ; Tue, 30 Sep 2014 22:02:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F34EA20166 for ; Tue, 30 Sep 2014 22:02:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1F8D120165 for ; Tue, 30 Sep 2014 22:02:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755305AbaI3WB7 (ORCPT ); Tue, 30 Sep 2014 18:01:59 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:52870 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754144AbaI3WAs (ORCPT ); Tue, 30 Sep 2014 18:00:48 -0400 Received: by mail-pa0-f45.google.com with SMTP id rd3so10881302pab.32 for ; Tue, 30 Sep 2014 15:00:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=zebnCfKZRG456OpUHa4TOL4tR8hhjHnhRsEzP/L2oII=; b=WgNsjNfBi00iMUBOcp7jtzRTOFbkdYO7aaa8bDyOYB8nUq11ZIXxU465IdttVUa90B yw35SGqpV/RMpsb/WPqZLFFr2ntzDCOZlQ4shcRmxaO8JL7i1mWvBQn0m7VnAnh/lQiN WnBnTWCnOGN6SKWyj7HzebutPGr+CV0QGMJj5hQd/ikP61kY/8UUBf2efV7MqlNGokq9 4dFM7m53NqImBJVRrNwKuD+15otdcquSbb1Ml2CqAGkUtzQdOdSUBF75OAnT6vQodj3W Q4BRl/K3zicCOB3iev+3lzCMVkAmxX/r3ERB8epsruUT1069tkqR7Ba1veXVQG3enncx 8Y3Q== X-Gm-Message-State: ALoCoQnEbpY2EuPFL4Xc4cEIYbL1S/MRYVHokljhTP+6GV+VcCy9E22hWuzH6jZ2Ypg1TKcDfRSl X-Received: by 10.68.139.163 with SMTP id qz3mr14691195pbb.26.1412114447906; Tue, 30 Sep 2014 15:00:47 -0700 (PDT) Received: from molino.home.network (c-24-19-133-29.hsd1.wa.comcast.net. [24.19.133.29]) by mx.google.com with ESMTPSA id nz4sm16076560pdb.51.2014.09.30.15.00.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 30 Sep 2014 15:00:47 -0700 (PDT) From: Omar Sandoval To: Chris Mason , Josef Bacik , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: David Sterba , Zach Brown Subject: [PATCH v2 1/3] btrfs: replace open-coded kernel_write Date: Tue, 30 Sep 2014 15:01:40 -0700 Message-Id: X-Mailer: git-send-email 2.1.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP write_buf used by btrfs send has what is more or less a reimplementation of kernel_write. This also gets rid of a sparse address space warning. Signed-off-by: Omar Sandoval Reviewed-by: Zach Brown --- fs/btrfs/send.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 6528aa6..f6b2ec3 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -508,32 +508,23 @@ static struct btrfs_path *alloc_path_for_send(void) static int write_buf(struct file *filp, const void *buf, u32 len, loff_t *off) { int ret; - mm_segment_t old_fs; u32 pos = 0; - old_fs = get_fs(); - set_fs(KERNEL_DS); - while (pos < len) { - ret = vfs_write(filp, (char *)buf + pos, len - pos, off); + ret = kernel_write(filp, buf + pos, len - pos, *off); /* TODO handle that correctly */ /*if (ret == -ERESTARTSYS) { continue; }*/ if (ret < 0) - goto out; - if (ret == 0) { - ret = -EIO; - goto out; - } + return ret; + if (ret == 0) + return -EIO; pos += ret; + *off += ret; } - ret = 0; - -out: - set_fs(old_fs); - return ret; + return 0; } static int tlv_put(struct send_ctx *sctx, u16 attr, const void *data, int len)