Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4275710pxb; Tue, 10 Nov 2020 12:09:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvx3cCS4TnDs3XcgsattwQlmJ9I+5DrUkcbFb02zBTc7Acbb8mSGTaBTacWRO1anFpRDyz X-Received: by 2002:a17:906:52c6:: with SMTP id w6mr20762283ejn.199.1605038966497; Tue, 10 Nov 2020 12:09:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605038966; cv=none; d=google.com; s=arc-20160816; b=cd0J91rZGPipSavXPlq74URsWC57DFB2H1m+JGRO18Z+go4+OJIyQ9+i2Fe8LO+4Zu 7Fcse3xvdRNqQWPzoZk4wL9dRgA0LOv7AT1IehyqCD3h0R5OEm1UNXtRSg3qu2q53wNq wE0Pe5BrHLgS4RZ0AS2CI4bf+6ngNn5gieyif7Jth7DWDKMAUU9Xy2EEfUO64VEuNyfS EkdOC1AaD/F1Zql2Dcqxi+0rAgGNveGBgXwGY/oPyFf/ah5xO70eQmbnnqQBahayPzmO XlLXcoHSUy5ALCH8IYUNDPLRsyewxgBhN4mmJB4SpLjBninvYX9tIdG6roUVj07pd3vc mf+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=SpgQq+aB8i2ZNnoe8g+Ep6z+VMj6TXHbVNx9O0R7Pfw=; b=WF2tiRhjOUd5rg0mvAwafsYPokN/o5EeUsWP406+1GoKfmKE6GlibRjQJZZOZjZHhx W5xPM4t8uKG0prbQuDxJH2RTOWLDGws1xRsW4m/iWP1/Fug9yd0Uj3nWod8EsYVUVr+6 BFUg+T5fF7uL6oye0JA9clMeKzOQvOzYAUTv+PWnbxDO1dJ5XFny7aVuqSmVpeU1yV/0 lmY/MPo+43ZswTtYC9qVPCy4yp/tpMG4VE79FZbEoFSp2tCe2jMtUX0xsJoXHqaoew9S JRqwHoQSnWYWD5j8PdZh18qnQdExQe50duH56eufRWogUpJRMKD7z0c1P+0PMDg/o2Hq ZGEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p23si6573312edw.195.2020.11.10.12.09.01; Tue, 10 Nov 2020 12:09:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731142AbgKJUEo (ORCPT + 99 others); Tue, 10 Nov 2020 15:04:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726861AbgKJUEo (ORCPT ); Tue, 10 Nov 2020 15:04:44 -0500 Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [IPv6:2002:c35c:fd02::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48BF1C0613D1; Tue, 10 Nov 2020 12:04:43 -0800 (PST) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcZsB-0031DR-RH; Tue, 10 Nov 2020 20:04:11 +0000 Date: Tue, 10 Nov 2020 20:04:11 +0000 From: Al Viro To: yulei.kernel@gmail.com Cc: akpm@linux-foundation.org, naoya.horiguchi@nec.com, pbonzini@redhat.com, linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, xiaoguangrong.eric@gmail.com, kernellwp@gmail.com, lihaiwei.kernel@gmail.com, Yulei Zhang , Xiao Guangrong Subject: Re: [PATCH 01/35] fs: introduce dmemfs module Message-ID: <20201110200411.GU3576660@ZenIV.linux.org.uk> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 08, 2020 at 03:53:51PM +0800, yulei.kernel@gmail.com wrote: > +static struct inode * > +dmemfs_get_inode(struct super_block *sb, const struct inode *dir, umode_t mode, > + dev_t dev); WTF is 'dev' for? > +static int > +dmemfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev) > +{ > + struct inode *inode = dmemfs_get_inode(dir->i_sb, dir, mode, dev); > + int error = -ENOSPC; > + > + if (inode) { > + d_instantiate(dentry, inode); > + dget(dentry); /* Extra count - pin the dentry in core */ > + error = 0; > + dir->i_mtime = dir->i_ctime = current_time(inode); > + } > + return error; > +} ... same here, seeing that you only call that thing from the next two functions and you do *not* provide ->mknod() as a method (unsurprisingly - what would device nodes do there?) > +static int dmemfs_create(struct inode *dir, struct dentry *dentry, > + umode_t mode, bool excl) > +{ > + return dmemfs_mknod(dir, dentry, mode | S_IFREG, 0); > +} > + > +static int dmemfs_mkdir(struct inode *dir, struct dentry *dentry, > + umode_t mode) > +{ > + int retval = dmemfs_mknod(dir, dentry, mode | S_IFDIR, 0); > + > + if (!retval) > + inc_nlink(dir); > + return retval; > +} > +int dmemfs_file_mmap(struct file *file, struct vm_area_struct *vma) > +{ > + return 0; > +} > + > +static const struct file_operations dmemfs_file_operations = { > + .mmap = dmemfs_file_mmap, > +}; Er... Is that a placeholder for later in the series? Because as it is, it makes no sense whatsoever - "it can be mmapped, but any access to the mapped area will segfault". > +struct inode *dmemfs_get_inode(struct super_block *sb, > + const struct inode *dir, umode_t mode, dev_t dev) > +{ > + struct inode *inode = new_inode(sb); > + > + if (inode) { > + inode->i_ino = get_next_ino(); > + inode_init_owner(inode, dir, mode); > + inode->i_mapping->a_ops = &empty_aops; > + mapping_set_gfp_mask(inode->i_mapping, GFP_HIGHUSER); > + mapping_set_unevictable(inode->i_mapping); > + inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); > + switch (mode & S_IFMT) { > + default: > + init_special_inode(inode, mode, dev); > + break; > + case S_IFREG: > + inode->i_op = &dmemfs_file_inode_operations; > + inode->i_fop = &dmemfs_file_operations; > + break; > + case S_IFDIR: > + inode->i_op = &dmemfs_dir_inode_operations; > + inode->i_fop = &simple_dir_operations; > + > + /* > + * directory inodes start off with i_nlink == 2 > + * (for "." entry) > + */ > + inc_nlink(inode); > + break; > + case S_IFLNK: > + inode->i_op = &page_symlink_inode_operations; > + break; Where would symlinks come from? Or anything other than regular files and directories, for that matter...