From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758070AbYD2DnU (ORCPT ); Mon, 28 Apr 2008 23:43:20 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752155AbYD2DnI (ORCPT ); Mon, 28 Apr 2008 23:43:08 -0400 Received: from yw-out-2324.google.com ([74.125.46.30]:37864 "EHLO yw-out-2324.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751384AbYD2DnG (ORCPT ); Mon, 28 Apr 2008 23:43:06 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=CGgtxhHfMjIKPSSjtbT9HCo5cL5eyT7Dt2oIuLh4RYCaJZ6NNbBadtlP2B4cnlQKqynr/A6MXK0OUeV2RmoB1e2RQOlytx5F7BUhJk2OvfVjjVENPj0X4ZR8BHJP3zPe6kfB0852d/+V6Fy4dOUgai8rdl6B89O3ibf3H26dP2A= Message-ID: <386072610804282042y2dda4b52h927683a8a938ce1f@mail.gmail.com> Date: Tue, 29 Apr 2008 11:42:48 +0800 From: "Bryan Wu" To: LKML , "Andrew Morton" , "Linus Torvalds" , willy@debian.org, "Al Viro" , uclinux-dist-devel Subject: [LTP/VFS] fcntl SETLEASE fails on ramfs/tmpfs MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Google-Sender-Auth: 00885543cdaa4f85 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi folk, This days I am digging into this LTP bug reported on our Blackfin test machine, but I think it is general for other system. https://blackfin.uclinux.org/gf/project/uclinux-dist/tracker/?action=TrackerItemEdit&tracker_id=141&tracker_item_id=3743 And I also found Kumar Gala reported this similar bug before. http://lkml.org/lkml/2007/11/14/388 1, when opening and creating a new on ramfs/tmpfs, the dentry->d_count will be added one as below: -- ramfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev) { |_______struct inode * inode = ramfs_get_inode(dir->i_sb, mode, dev); |_______int error = -ENOSPC; |_______if (inode) { |_______|_______if (dir->i_mode & S_ISGID) { |_______|_______|_______inode->i_gid = dir->i_gid; |_______|_______|_______if (S_ISDIR(mode)) |_______|_______|_______|_______inode->i_mode |= S_ISGID; |_______|_______} |_______|_______d_instantiate(dentry, inode); |_______|_______dget(dentry);|__/* Extra count - pin the dentry in core */ |_______|_______error = 0; |_______|_______dir->i_mtime = dir->i_ctime = CURRENT_TIME; |_______} |_______return error; } -- The dget(dentry) call introduces an extra count, why? it is the same in tmpfs. 2, when calling fcntl(fd, F_SETLEASE,F_WRLCK), it will return -EAGAIN -- |_______if ((arg == F_WRLCK) |_______ && ((atomic_read(&dentry->d_count) > 1) |_______|_______|| (atomic_read(&inode->i_count) > 1))) |_______|_______goto out; -- because the dentry->d_count will be 2 not 1. I tested ext2 on Blackfin, it is 1. 3, so I guess maybe the dget(dentry) of ramfs_mknod is useless. But after remove this dget(), the ramfs can not be mounted as rootfs at all. Is the bug in generic_setlease() or in the ramfs/tmpfs inode create function? Of course, simply remove the test '((atomic_read(&dentry->d_count) > 1)' can workaround this issue. Thanks Best Regards, -Bryan Wu