Received: by 10.213.65.68 with SMTP id h4csp3424702imn; Tue, 3 Apr 2018 04:52:41 -0700 (PDT) X-Google-Smtp-Source: AIpwx49e5we6qkdckhfOEZ2zUNP51cuSyPyEtHAilqwVeGqS9J4O8oULO9sCsYXXC++lGBsvF83y X-Received: by 10.101.97.16 with SMTP id z16mr9040560pgu.23.1522756361214; Tue, 03 Apr 2018 04:52:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522756361; cv=none; d=google.com; s=arc-20160816; b=nejWdYTgTw4aU5gzUMM1pODZp6pPEngioiTv2w1xuzomEbQ6xyWH6skGF64aYS6VLk HJTJ1a63ghBVMkHiy9DCevLuA+qm+ZPJBUoww3Z6bJ+cvXcsSiFo0yg2Pdq62rh7GeJ1 Ut1OlLiEEYHEQ3uIXj2dmqirVWi4omhi3iG+T1muE0IP5RPqt1M+lw9eqLybJ0o289rC HAbq1iloRN4ond4V4hftkgO6dGJc5oyIRFYjPJXx9r6bMKSUj3jFN2/pgUByrdQiuJJ0 P39TPZJ1We65bvxRMFNsmCabxLLxjiBZ1y5W5q4Wrae2kuIzydq0iQrevg2zK98NW/50 Nq3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=3cmk8ekI/gopHDxD1165yChD+enUuzcjR5o1TTvBGno=; b=jUAS1FvBc+ilHoilrRy+KBLSJBI+eBJI+qUNmjgnKdJu2q/cfJQ82xyCIh3tzAJ5gz 67+ldSgoieVthev2YTfJT5FIi8pCItlAC0plZeVqmB5SdpfNiKsgr+wX65edzPkCvmwo dx6lQNQVgGScKqlq6GgiqMoJztB7Cn/4hDmEyyXHyl/9IQ7TnDo5iXw+66Wpl9fiMZgN 0wuq4tUE1BK8b3gva9iZpnK00+aeyMmxKbBZPW3Dn1vkccOuiYupWrwPpjmhouB295mb rbWWLR7GVXSutPrG+1+/+UGKt5JyDACeC+oJElN67vRT0TFp8O9v9omuYc2k3MOzSfXy Lnog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a19-v6si316144plm.736.2018.04.03.04.52.26; Tue, 03 Apr 2018 04:52:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755415AbeDCLvN (ORCPT + 99 others); Tue, 3 Apr 2018 07:51:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:59810 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755300AbeDCLvM (ORCPT ); Tue, 3 Apr 2018 07:51:12 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 56106AF05; Tue, 3 Apr 2018 11:51:10 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 07A6A1E0A1B; Tue, 3 Apr 2018 13:51:10 +0200 (CEST) Date: Tue, 3 Apr 2018 13:51:10 +0200 From: Jan Kara To: Dan Williams Cc: linux-nvdimm@lists.01.org, Jan Kara , kbuild test robot , david@fromorbit.com, hch@lst.de, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, jack@suse.cz, snitzer@redhat.com Subject: Re: [PATCH v8 06/18] ext2, dax: introduce ext2_dax_aops Message-ID: <20180403115110.x272sevqcutguna6@quack2.suse.cz> References: <152246892890.36038.18436540150980653229.stgit@dwillia2-desk3.amr.corp.intel.com> <152246896163.36038.15934876342603748972.stgit@dwillia2-desk3.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <152246896163.36038.15934876342603748972.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 30-03-18 21:02:41, Dan Williams wrote: > In preparation for the dax implementation to start associating dax pages > to inodes via page->mapping, we need to provide a 'struct > address_space_operations' instance for dax. Otherwise, direct-I/O > triggers incorrect page cache assumptions and warnings. > > Cc: Jan Kara > Reported-by: kbuild test robot > Signed-off-by: Dan Williams Looks good. You can add: Reviewed-by: Jan Kara Honza > --- > fs/ext2/ext2.h | 1 + > fs/ext2/inode.c | 46 +++++++++++++++++++++++++++------------------- > fs/ext2/namei.c | 18 ++---------------- > 3 files changed, 30 insertions(+), 35 deletions(-) > > diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h > index 032295e1d386..cc40802ddfa8 100644 > --- a/fs/ext2/ext2.h > +++ b/fs/ext2/ext2.h > @@ -814,6 +814,7 @@ extern const struct inode_operations ext2_file_inode_operations; > extern const struct file_operations ext2_file_operations; > > /* inode.c */ > +extern void ext2_set_file_ops(struct inode *inode); > extern const struct address_space_operations ext2_aops; > extern const struct address_space_operations ext2_nobh_aops; > extern const struct iomap_ops ext2_iomap_ops; > diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c > index 9b2ac55ac34f..1e01fabef130 100644 > --- a/fs/ext2/inode.c > +++ b/fs/ext2/inode.c > @@ -940,9 +940,6 @@ ext2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) > loff_t offset = iocb->ki_pos; > ssize_t ret; > > - if (WARN_ON_ONCE(IS_DAX(inode))) > - return -EIO; > - > ret = blockdev_direct_IO(iocb, inode, iter, ext2_get_block); > if (ret < 0 && iov_iter_rw(iter) == WRITE) > ext2_write_failed(mapping, offset + count); > @@ -952,17 +949,16 @@ ext2_direct_IO(struct kiocb *iocb, struct iov_iter *iter) > static int > ext2_writepages(struct address_space *mapping, struct writeback_control *wbc) > { > -#ifdef CONFIG_FS_DAX > - if (dax_mapping(mapping)) { > - return dax_writeback_mapping_range(mapping, > - mapping->host->i_sb->s_bdev, > - wbc); > - } > -#endif > - > return mpage_writepages(mapping, wbc, ext2_get_block); > } > > +static int > +ext2_dax_writepages(struct address_space *mapping, struct writeback_control *wbc) > +{ > + return dax_writeback_mapping_range(mapping, > + mapping->host->i_sb->s_bdev, wbc); > +} > + > const struct address_space_operations ext2_aops = { > .readpage = ext2_readpage, > .readpages = ext2_readpages, > @@ -990,6 +986,13 @@ const struct address_space_operations ext2_nobh_aops = { > .error_remove_page = generic_error_remove_page, > }; > > +static const struct address_space_operations ext2_dax_aops = { > + .writepages = ext2_dax_writepages, > + .direct_IO = noop_direct_IO, > + .set_page_dirty = noop_set_page_dirty, > + .invalidatepage = noop_invalidatepage, > +}; > + > /* > * Probably it should be a library function... search for first non-zero word > * or memcmp with zero_page, whatever is better for particular architecture. > @@ -1388,6 +1391,18 @@ void ext2_set_inode_flags(struct inode *inode) > inode->i_flags |= S_DAX; > } > > +void ext2_set_file_ops(struct inode *inode) > +{ > + inode->i_op = &ext2_file_inode_operations; > + inode->i_fop = &ext2_file_operations; > + if (IS_DAX(inode)) > + inode->i_mapping->a_ops = &ext2_dax_aops; > + else if (test_opt(inode->i_sb, NOBH)) > + inode->i_mapping->a_ops = &ext2_nobh_aops; > + else > + inode->i_mapping->a_ops = &ext2_aops; > +} > + > struct inode *ext2_iget (struct super_block *sb, unsigned long ino) > { > struct ext2_inode_info *ei; > @@ -1480,14 +1495,7 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino) > ei->i_data[n] = raw_inode->i_block[n]; > > if (S_ISREG(inode->i_mode)) { > - inode->i_op = &ext2_file_inode_operations; > - if (test_opt(inode->i_sb, NOBH)) { > - inode->i_mapping->a_ops = &ext2_nobh_aops; > - inode->i_fop = &ext2_file_operations; > - } else { > - inode->i_mapping->a_ops = &ext2_aops; > - inode->i_fop = &ext2_file_operations; > - } > + ext2_set_file_ops(inode); > } else if (S_ISDIR(inode->i_mode)) { > inode->i_op = &ext2_dir_inode_operations; > inode->i_fop = &ext2_dir_operations; > diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c > index e078075dc66f..55f7caadb093 100644 > --- a/fs/ext2/namei.c > +++ b/fs/ext2/namei.c > @@ -107,14 +107,7 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, umode_t mode > if (IS_ERR(inode)) > return PTR_ERR(inode); > > - inode->i_op = &ext2_file_inode_operations; > - if (test_opt(inode->i_sb, NOBH)) { > - inode->i_mapping->a_ops = &ext2_nobh_aops; > - inode->i_fop = &ext2_file_operations; > - } else { > - inode->i_mapping->a_ops = &ext2_aops; > - inode->i_fop = &ext2_file_operations; > - } > + ext2_set_file_ops(inode); > mark_inode_dirty(inode); > return ext2_add_nondir(dentry, inode); > } > @@ -125,14 +118,7 @@ static int ext2_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) > if (IS_ERR(inode)) > return PTR_ERR(inode); > > - inode->i_op = &ext2_file_inode_operations; > - if (test_opt(inode->i_sb, NOBH)) { > - inode->i_mapping->a_ops = &ext2_nobh_aops; > - inode->i_fop = &ext2_file_operations; > - } else { > - inode->i_mapping->a_ops = &ext2_aops; > - inode->i_fop = &ext2_file_operations; > - } > + ext2_set_file_ops(inode); > mark_inode_dirty(inode); > d_tmpfile(dentry, inode); > unlock_new_inode(inode); > -- Jan Kara SUSE Labs, CR