From patchwork Wed Sep 14 08:37:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 9330921 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 4A1026077F for ; Wed, 14 Sep 2016 08:41:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B79D29B7E for ; Wed, 14 Sep 2016 08:41:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3078329B81; Wed, 14 Sep 2016 08:41:24 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 D117329B7E for ; Wed, 14 Sep 2016 08:41:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761805AbcINIkt (ORCPT ); Wed, 14 Sep 2016 04:40:49 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:37820 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760505AbcINIhV (ORCPT ); Wed, 14 Sep 2016 04:37:21 -0400 Received: by mail-wm0-f44.google.com with SMTP id c131so16222705wmh.0 for ; Wed, 14 Sep 2016 01:37:20 -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; bh=MJDhFQF0bz49bYV+7VybuqANGys1PQurCAtYwDQ+R0Q=; b=EfqH+lQHuMP1C6rYqOtaYcYRtcuo0Sz670U/j9rZGMYTMt0AhmuYcZcAbh7sWPiMTZ 9ZXZDlbP1gYXOMlSagFuN46/hVNBooX1pqGID1NjBkjkUs6MNE9IOaISGN8AqOUSjMU/ s/7bW5wDCBTf9UkT3T7R0KXCd025zv0BwdtmQA7xe/qBG+asKuMsipslxMzzKmMBpguR VwBRvbKJV63tAOWiGdEdnbKbbr8emXJpCyyclKl64Nm6r0sWCEIIabjRCWcaSnl0zKyl 7ene1kat2u7xlWNNVVl1igPFm1oW8wpRUuu8ZcuTQLttqaOPrbHq0tlFNkP2iIsUVC8k pRDQ== X-Gm-Message-State: AE9vXwPJyecwuWYNJFlL9dMe6WF5eIY1zTTuGvBrqGuL419WjHEXaDSyJ4fuEtJ/rkX++lC3 X-Received: by 10.194.141.203 with SMTP id rq11mr1556606wjb.112.1473842239885; Wed, 14 Sep 2016 01:37:19 -0700 (PDT) Received: from veci.piliscsaba.szeredi.hu (pool-dsl-2c-0018.externet.hu. [217.173.44.24]) by smtp.gmail.com with ESMTPSA id g184sm9533889wme.15.2016.09.14.01.37.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Sep 2016 01:37:19 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Al Viro Subject: [PATCH 01/11] pipe: add pipe_buf_get() helper Date: Wed, 14 Sep 2016 10:37:06 +0200 Message-Id: <1473842236-28655-2-git-send-email-mszeredi@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1473842236-28655-1-git-send-email-mszeredi@redhat.com> References: <1473842236-28655-1-git-send-email-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 Signed-off-by: Miklos Szeredi --- fs/fuse/dev.c | 2 +- fs/splice.c | 4 ++-- include/linux/pipe_fs_i.h | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index a94d2ed81ab4..5cb20600bc9e 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -1993,7 +1993,7 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1); pipe->nrbufs--; } else { - ibuf->ops->get(pipe, ibuf); + pipe_buf_get(pipe, ibuf); *obuf = *ibuf; obuf->flags &= ~PIPE_BUF_FLAG_GIFT; obuf->len = rem; diff --git a/fs/splice.c b/fs/splice.c index dd9bf7e410d2..36457a192c13 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1876,7 +1876,7 @@ retry: * Get a reference to this pipe buffer, * so we can copy the contents over. */ - ibuf->ops->get(ipipe, ibuf); + pipe_buf_get(ipipe, ibuf); *obuf = *ibuf; /* @@ -1948,7 +1948,7 @@ static int link_pipe(struct pipe_inode_info *ipipe, * Get a reference to this pipe buffer, * so we can copy the contents over. */ - ibuf->ops->get(ipipe, ibuf); + pipe_buf_get(ipipe, ibuf); obuf = opipe->bufs + nbuf; *obuf = *ibuf; diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h index 24f5470d3944..10876f3cb3da 100644 --- a/include/linux/pipe_fs_i.h +++ b/include/linux/pipe_fs_i.h @@ -115,6 +115,17 @@ struct pipe_buf_operations { void (*get)(struct pipe_inode_info *, struct pipe_buffer *); }; +/** + * pipe_buf_get - get a reference to a pipe_buffer + * @pipe: the pipe that the buffer belongs to + * @buf: the buffer to get a reference to + */ +static inline void pipe_buf_get(struct pipe_inode_info *pipe, + struct pipe_buffer *buf) +{ + buf->ops->get(pipe, buf); +} + /* Differs from PIPE_BUF in that PIPE_SIZE is the length of the actual memory allocation, whereas PIPE_BUF makes atomicity guarantees. */ #define PIPE_SIZE PAGE_SIZE