1e69e7fe5SEric Van Hensbergen /* 2e69e7fe5SEric Van Hensbergen * linux/fs/9p/vfs_dentry.c 3e69e7fe5SEric Van Hensbergen * 4e69e7fe5SEric Van Hensbergen * This file contians vfs dentry ops for the 9P2000 protocol. 5e69e7fe5SEric Van Hensbergen * 6e69e7fe5SEric Van Hensbergen * Copyright (C) 2004 by Eric Van Hensbergen <ericvh@gmail.com> 7e69e7fe5SEric Van Hensbergen * Copyright (C) 2002 by Ron Minnich <rminnich@lanl.gov> 8e69e7fe5SEric Van Hensbergen * 9e69e7fe5SEric Van Hensbergen * This program is free software; you can redistribute it and/or modify 1042e8c509SEric Van Hensbergen * it under the terms of the GNU General Public License version 2 1142e8c509SEric Van Hensbergen * as published by the Free Software Foundation. 12e69e7fe5SEric Van Hensbergen * 13e69e7fe5SEric Van Hensbergen * This program is distributed in the hope that it will be useful, 14e69e7fe5SEric Van Hensbergen * but WITHOUT ANY WARRANTY; without even the implied warranty of 15e69e7fe5SEric Van Hensbergen * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16e69e7fe5SEric Van Hensbergen * GNU General Public License for more details. 17e69e7fe5SEric Van Hensbergen * 18e69e7fe5SEric Van Hensbergen * You should have received a copy of the GNU General Public License 19e69e7fe5SEric Van Hensbergen * along with this program; if not, write to: 20e69e7fe5SEric Van Hensbergen * Free Software Foundation 21e69e7fe5SEric Van Hensbergen * 51 Franklin Street, Fifth Floor 22e69e7fe5SEric Van Hensbergen * Boston, MA 02111-1301 USA 23e69e7fe5SEric Van Hensbergen * 24e69e7fe5SEric Van Hensbergen */ 25e69e7fe5SEric Van Hensbergen 26e69e7fe5SEric Van Hensbergen #include <linux/module.h> 27e69e7fe5SEric Van Hensbergen #include <linux/errno.h> 28e69e7fe5SEric Van Hensbergen #include <linux/fs.h> 29e69e7fe5SEric Van Hensbergen #include <linux/file.h> 30e69e7fe5SEric Van Hensbergen #include <linux/pagemap.h> 31e69e7fe5SEric Van Hensbergen #include <linux/stat.h> 32e69e7fe5SEric Van Hensbergen #include <linux/string.h> 33e69e7fe5SEric Van Hensbergen #include <linux/inet.h> 34e69e7fe5SEric Van Hensbergen #include <linux/namei.h> 35e69e7fe5SEric Van Hensbergen #include <linux/idr.h> 36e8edc6e0SAlexey Dobriyan #include <linux/sched.h> 37*5a0e3ad6STejun Heo #include <linux/slab.h> 38bd238fb4SLatchesar Ionkov #include <net/9p/9p.h> 39bd238fb4SLatchesar Ionkov #include <net/9p/client.h> 40e69e7fe5SEric Van Hensbergen 41e69e7fe5SEric Van Hensbergen #include "v9fs.h" 42e69e7fe5SEric Van Hensbergen #include "v9fs_vfs.h" 43e69e7fe5SEric Van Hensbergen #include "fid.h" 44e69e7fe5SEric Van Hensbergen 45e69e7fe5SEric Van Hensbergen /** 4646f6dac2SEric Van Hensbergen * v9fs_dentry_delete - called when dentry refcount equals 0 4746f6dac2SEric Van Hensbergen * @dentry: dentry in question 48e69e7fe5SEric Van Hensbergen * 4946f6dac2SEric Van Hensbergen * By returning 1 here we should remove cacheing of unused 5046f6dac2SEric Van Hensbergen * dentry components. 51e69e7fe5SEric Van Hensbergen * 52e69e7fe5SEric Van Hensbergen */ 53e69e7fe5SEric Van Hensbergen 545174fdabSLatchesar Ionkov static int v9fs_dentry_delete(struct dentry *dentry) 55e69e7fe5SEric Van Hensbergen { 567dd0cdc5SWu Fengguang P9_DPRINTK(P9_DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_name.name, 577dd0cdc5SWu Fengguang dentry); 58e03abc0cSEric Van Hensbergen 59e69e7fe5SEric Van Hensbergen return 1; 60e69e7fe5SEric Van Hensbergen } 61e69e7fe5SEric Van Hensbergen 62e69e7fe5SEric Van Hensbergen /** 63e03abc0cSEric Van Hensbergen * v9fs_cached_dentry_delete - called when dentry refcount equals 0 64e03abc0cSEric Van Hensbergen * @dentry: dentry in question 65e03abc0cSEric Van Hensbergen * 66e03abc0cSEric Van Hensbergen * Only return 1 if our inode is invalid. Only non-synthetic files 67e03abc0cSEric Van Hensbergen * (ones without mtime == 0) should be calling this function. 68e03abc0cSEric Van Hensbergen * 69e03abc0cSEric Van Hensbergen */ 70e03abc0cSEric Van Hensbergen 71e03abc0cSEric Van Hensbergen static int v9fs_cached_dentry_delete(struct dentry *dentry) 72e03abc0cSEric Van Hensbergen { 73e03abc0cSEric Van Hensbergen struct inode *inode = dentry->d_inode; 747dd0cdc5SWu Fengguang P9_DPRINTK(P9_DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_name.name, 757dd0cdc5SWu Fengguang dentry); 76e03abc0cSEric Van Hensbergen 77e03abc0cSEric Van Hensbergen if(!inode) 78e03abc0cSEric Van Hensbergen return 1; 79e03abc0cSEric Van Hensbergen 80e03abc0cSEric Van Hensbergen return 0; 81e03abc0cSEric Van Hensbergen } 82e03abc0cSEric Van Hensbergen 83e03abc0cSEric Van Hensbergen /** 84e69e7fe5SEric Van Hensbergen * v9fs_dentry_release - called when dentry is going to be freed 85e69e7fe5SEric Van Hensbergen * @dentry: dentry that is being release 86e69e7fe5SEric Van Hensbergen * 87e69e7fe5SEric Van Hensbergen */ 88e69e7fe5SEric Van Hensbergen 89e69e7fe5SEric Van Hensbergen void v9fs_dentry_release(struct dentry *dentry) 90e69e7fe5SEric Van Hensbergen { 91bd238fb4SLatchesar Ionkov struct v9fs_dentry *dent; 92bd238fb4SLatchesar Ionkov struct p9_fid *temp, *current_fid; 933cf6429aSLatchesar Ionkov 947dd0cdc5SWu Fengguang P9_DPRINTK(P9_DEBUG_VFS, " dentry: %s (%p)\n", dentry->d_name.name, 957dd0cdc5SWu Fengguang dentry); 96bd238fb4SLatchesar Ionkov dent = dentry->d_fsdata; 97bd238fb4SLatchesar Ionkov if (dent) { 98bd238fb4SLatchesar Ionkov list_for_each_entry_safe(current_fid, temp, &dent->fidlist, 99bd238fb4SLatchesar Ionkov dlist) { 100bd238fb4SLatchesar Ionkov p9_client_clunk(current_fid); 101e69e7fe5SEric Van Hensbergen } 102e69e7fe5SEric Van Hensbergen 103bd238fb4SLatchesar Ionkov kfree(dent); 104bd238fb4SLatchesar Ionkov dentry->d_fsdata = NULL; 105e69e7fe5SEric Van Hensbergen } 106e69e7fe5SEric Van Hensbergen } 107e69e7fe5SEric Van Hensbergen 108a488257cSAl Viro const struct dentry_operations v9fs_cached_dentry_operations = { 109e03abc0cSEric Van Hensbergen .d_delete = v9fs_cached_dentry_delete, 110e03abc0cSEric Van Hensbergen .d_release = v9fs_dentry_release, 111e03abc0cSEric Van Hensbergen }; 112e03abc0cSEric Van Hensbergen 113a488257cSAl Viro const struct dentry_operations v9fs_dentry_operations = { 11446f6dac2SEric Van Hensbergen .d_delete = v9fs_dentry_delete, 115e69e7fe5SEric Van Hensbergen .d_release = v9fs_dentry_release, 116e69e7fe5SEric Van Hensbergen }; 117