From patchwork Sat Mar 10 18:18:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andiry Xu X-Patchwork-Id: 10273987 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 86349602BD for ; Sat, 10 Mar 2018 18:22:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7632F29106 for ; Sat, 10 Mar 2018 18:22:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B0292974F; Sat, 10 Mar 2018 18:22:02 +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=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0A10229106 for ; Sat, 10 Mar 2018 18:22:02 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 526F12258AF0B; Sat, 10 Mar 2018 10:15:30 -0800 (PST) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:400e:c05::242; helo=mail-pg0-x242.google.com; envelope-from=jix024@eng.ucsd.edu; receiver=linux-nvdimm@lists.01.org Received: from mail-pg0-x242.google.com (mail-pg0-x242.google.com [IPv6:2607:f8b0:400e:c05::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9745C22646317 for ; Sat, 10 Mar 2018 10:15:28 -0800 (PST) Received: by mail-pg0-x242.google.com with SMTP id g8so4833068pgv.7 for ; Sat, 10 Mar 2018 10:21:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eng.ucsd.edu; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nQS7axGVJ6GVgVsXACgfiVM6aNt+hqfm2MCp2h/QUy4=; b=fuichF5wliwpizRw45dRswY93wu1vL0IVmo6rtR7wM6Il+NGQfMnMB5VQgHqQG9bHF 1udSrrsr2ym8Ulhh57ceTCC4+Ta0D44pV7RGDLogpW9MiDT8GGriGYY9hywSHiWjXuDF V1bQWR9flE1pUT6GdeJrcg1FQsSyLIqrMlNQU= 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=nQS7axGVJ6GVgVsXACgfiVM6aNt+hqfm2MCp2h/QUy4=; b=rSRme9kJXd5w8AH7bCWrSayAFgKGp/t0OVuYmVhfaOLQopyFadsW4HIwk3DGkxZlT7 YifviXElaG3wWiVY2NHBCkSDqlkBrlBNINQcErGUgqGt+0lhpC3zoiRSlIP4Er4n7iXG H5qMdFyioPzr0N8ir1DR/60aDHGJqMDYD3W5sOSjFFfmqdGE8gSYq2laZD1E1p/2c5md 6Jg1OCjsfbhbkjIJ3EA1+r382DpAKR9YcZDGXLjXYOdk1JgEleGvLyNT+yAN4g/PGAOx YN1e6S/qzBoooFug8Zi5ILcEe55JyadyRUfMcFGR97qYX1VTtXRaP/kRVvhFLEc4X8Yn T1Cw== X-Gm-Message-State: AElRT7H5NEwr+EPZwO6M7c03h9lEBev8zHxC/iFQ8RI2aFsVZpSjlREO LCcUhuFd94JmtCays5V9UIQhbw== X-Google-Smtp-Source: AG47ELvOJrbtR7E4ak9HmHrSHoxI+3Exg6VTdYrlIOJ7fWZLaupizZ5mizbOEJAPlnTwq1L3qzS0uQ== X-Received: by 10.99.117.24 with SMTP id q24mr2201791pgc.53.1520706107043; Sat, 10 Mar 2018 10:21:47 -0800 (PST) Received: from brienza-desktop.8.8.4.4 (andxu.ucsd.edu. [132.239.17.134]) by smtp.gmail.com with ESMTPSA id h80sm9210167pfj.181.2018.03.10.10.21.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 10:21:46 -0800 (PST) From: Andiry Xu To: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [RFC v2 75/83] File operation: read/write iter. Date: Sat, 10 Mar 2018 10:18:56 -0800 Message-Id: <1520705944-6723-76-git-send-email-jix024@eng.ucsd.edu> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520705944-6723-1-git-send-email-jix024@eng.ucsd.edu> References: <1520705944-6723-1-git-send-email-jix024@eng.ucsd.edu> X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: coughlan@redhat.com, miklos@szeredi.hu, Andiry Xu , david@fromorbit.com, jack@suse.com, swanson@cs.ucsd.edu, swhiteho@redhat.com, andiry.xu@gmail.com MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP From: Andiry Xu They use the iomap framework to do read/write. Due to software overheads they are slower than dax read/write. Signed-off-by: Andiry Xu --- fs/nova/file.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/fs/nova/file.c b/fs/nova/file.c index 0ae0333..7e90415 100644 --- a/fs/nova/file.c +++ b/fs/nova/file.c @@ -260,6 +260,69 @@ static long nova_fallocate(struct file *file, int mode, loff_t offset, return ret; } +static ssize_t nova_dax_read_iter(struct kiocb *iocb, struct iov_iter *to) +{ + struct inode *inode = iocb->ki_filp->f_mapping->host; + ssize_t ret; + timing_t read_iter_time; + + if (!iov_iter_count(to)) + return 0; + + NOVA_START_TIMING(read_iter_t, read_iter_time); + + inode_lock_shared(inode); + ret = dax_iomap_rw(iocb, to, &nova_iomap_ops); + inode_unlock_shared(inode); + + file_accessed(iocb->ki_filp); + NOVA_END_TIMING(read_iter_t, read_iter_time); + return ret; +} + +static ssize_t nova_dax_write_iter(struct kiocb *iocb, struct iov_iter *from) +{ + struct file *file = iocb->ki_filp; + struct inode *inode = file->f_mapping->host; + struct nova_inode_info *si = NOVA_I(inode); + struct nova_inode_info_header *sih = &si->header; + loff_t offset; + size_t count; + ssize_t ret; + timing_t write_iter_time; + + NOVA_START_TIMING(write_iter_t, write_iter_time); + inode_lock(inode); + ret = generic_write_checks(iocb, from); + if (ret <= 0) + goto out_unlock; + + ret = file_remove_privs(file); + if (ret) + goto out_unlock; + + ret = file_update_time(file); + if (ret) + goto out_unlock; + + count = iov_iter_count(from); + offset = iocb->ki_pos; + + ret = dax_iomap_rw(iocb, from, &nova_iomap_ops); + if (ret > 0 && iocb->ki_pos > i_size_read(inode)) { + i_size_write(inode, iocb->ki_pos); + sih->i_size = iocb->ki_pos; + mark_inode_dirty(inode); + } + +out_unlock: + inode_unlock(inode); + if (ret > 0) + ret = generic_write_sync(iocb, ret); + NOVA_END_TIMING(write_iter_t, write_iter_time); + return ret; +} + static ssize_t do_dax_mapping_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos) @@ -645,6 +708,8 @@ const struct file_operations nova_dax_file_operations = { .llseek = nova_llseek, .read = nova_dax_file_read, .write = nova_dax_file_write, + .read_iter = nova_dax_read_iter, + .write_iter = nova_dax_write_iter, .mmap = nova_dax_file_mmap, .open = nova_open, .fsync = nova_fsync,