Re: [15/17] SLUB: Support virtual fallback via SLAB_VFALLBACK
On Sunday 30 September 2007 05:20, Andrew Morton wrote: On Sat, 29 Sep 2007 06:19:33 +1000 Nick Piggin [EMAIL PROTECTED] wrote: On Saturday 29 September 2007 19:27, Andrew Morton wrote: On Sat, 29 Sep 2007 11:14:02 +0200 Peter Zijlstra [EMAIL PROTECTED] wrote: oom-killings, or page allocation failures? The latter, one hopes. Linux version 2.6.23-rc4-mm1-dirty ([EMAIL PROTECTED]) (gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4)) #27 Tue Sep 18 15:40:35 CEST 2007 ... mm_tester invoked oom-killer: gfp_mask=0x40d0, order=2, oomkilladj=0 Call Trace: 611b3878: [6002dd28] printk_ratelimit+0x15/0x17 611b3888: [60052ed4] out_of_memory+0x80/0x100 611b38c8: [60054b0c] __alloc_pages+0x1ed/0x280 611b3948: [6006c608] allocate_slab+0x5b/0xb0 611b3968: [6006c705] new_slab+0x7e/0x183 611b39a8: [6006cbae] __slab_alloc+0xc9/0x14b 611b39b0: [6011f89f] radix_tree_preload+0x70/0xbf 611b39b8: [600980f2] do_mpage_readpage+0x3b3/0x472 611b39e0: [6011f89f] radix_tree_preload+0x70/0xbf 611b39f8: [6006cc81] kmem_cache_alloc+0x51/0x98 611b3a38: [6011f89f] radix_tree_preload+0x70/0xbf 611b3a58: [6004f8e2] add_to_page_cache+0x22/0xf7 611b3a98: [6004f9c6] add_to_page_cache_lru+0xf/0x24 611b3ab8: [6009821e] mpage_readpages+0x6d/0x109 611b3ac0: [600d59f0] ext3_get_block+0x0/0xf2 611b3b08: [6005483d] get_page_from_freelist+0x8d/0xc1 611b3b88: [600d6937] ext3_readpages+0x18/0x1a 611b3b98: [60056f00] read_pages+0x37/0x9b 611b3bd8: [60057064] __do_page_cache_readahead+0x100/0x157 611b3c48: [60057196] do_page_cache_readahead+0x52/0x5f 611b3c78: [60050ab4] filemap_fault+0x145/0x278 611b3ca8: [60022b61] run_syscall_stub+0xd1/0xdd 611b3ce8: [6005eae3] __do_fault+0x7e/0x3ca 611b3d68: [6005ee60] do_linear_fault+0x31/0x33 611b3d88: [6005f149] handle_mm_fault+0x14e/0x246 611b3da8: [60120a7b] __up_read+0x73/0x7b 611b3de8: [60013177] handle_page_fault+0x11f/0x23b 611b3e48: [60013419] segv+0xac/0x297 611b3f28: [60013367] segv_handler+0x68/0x6e 611b3f48: [600232ad] get_skas_faultinfo+0x9c/0xa1 611b3f68: [60023853] userspace+0x13a/0x19d 611b3fc8: [60010d58] fork_handler+0x86/0x8d OK, that's different. Someone broke the vm - order-2 GFP_KERNEL allocations aren't supposed to fail. I'm suspecting that did_some_progress thing. The allocation didn't fail -- it invoked the OOM killer because the kernel ran out of unfragmented memory. We can't run out of unfragmented memory for an order-2 GFP_KERNEL allocation in this workload. We go and synchronously free stuff up to make it work. How did this get broken? Either no more order-2 pages could be freed, or the ones that were being freed were being used by something else (eg. other order-2 slab allocations). Probably because higher order allocations are the new vogue in -mm at the moment ;) That's a different bug. bug 1: We shouldn't be doing higher-order allocations in slub because of the considerable damage this does to atomic allocations. bug 2: order-2 GFP_KERNEL allocations shouldn't fail like this. I think one causes 2 as well -- it isn't just considerable damage to atomic allocations but to GFP_KERNEL allocations too. - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [15/17] SLUB: Support virtual fallback via SLAB_VFALLBACK
On Sun, 30 Sep 2007 05:09:28 +1000 Nick Piggin [EMAIL PROTECTED] wrote: On Sunday 30 September 2007 05:20, Andrew Morton wrote: On Sat, 29 Sep 2007 06:19:33 +1000 Nick Piggin [EMAIL PROTECTED] wrote: On Saturday 29 September 2007 19:27, Andrew Morton wrote: On Sat, 29 Sep 2007 11:14:02 +0200 Peter Zijlstra [EMAIL PROTECTED] wrote: oom-killings, or page allocation failures? The latter, one hopes. Linux version 2.6.23-rc4-mm1-dirty ([EMAIL PROTECTED]) (gcc version 4.1.2 (Ubuntu 4.1.2-0ubuntu4)) #27 Tue Sep 18 15:40:35 CEST 2007 ... mm_tester invoked oom-killer: gfp_mask=0x40d0, order=2, oomkilladj=0 Call Trace: 611b3878: [6002dd28] printk_ratelimit+0x15/0x17 611b3888: [60052ed4] out_of_memory+0x80/0x100 611b38c8: [60054b0c] __alloc_pages+0x1ed/0x280 611b3948: [6006c608] allocate_slab+0x5b/0xb0 611b3968: [6006c705] new_slab+0x7e/0x183 611b39a8: [6006cbae] __slab_alloc+0xc9/0x14b 611b39b0: [6011f89f] radix_tree_preload+0x70/0xbf 611b39b8: [600980f2] do_mpage_readpage+0x3b3/0x472 611b39e0: [6011f89f] radix_tree_preload+0x70/0xbf 611b39f8: [6006cc81] kmem_cache_alloc+0x51/0x98 611b3a38: [6011f89f] radix_tree_preload+0x70/0xbf 611b3a58: [6004f8e2] add_to_page_cache+0x22/0xf7 611b3a98: [6004f9c6] add_to_page_cache_lru+0xf/0x24 611b3ab8: [6009821e] mpage_readpages+0x6d/0x109 611b3ac0: [600d59f0] ext3_get_block+0x0/0xf2 611b3b08: [6005483d] get_page_from_freelist+0x8d/0xc1 611b3b88: [600d6937] ext3_readpages+0x18/0x1a 611b3b98: [60056f00] read_pages+0x37/0x9b 611b3bd8: [60057064] __do_page_cache_readahead+0x100/0x157 611b3c48: [60057196] do_page_cache_readahead+0x52/0x5f 611b3c78: [60050ab4] filemap_fault+0x145/0x278 611b3ca8: [60022b61] run_syscall_stub+0xd1/0xdd 611b3ce8: [6005eae3] __do_fault+0x7e/0x3ca 611b3d68: [6005ee60] do_linear_fault+0x31/0x33 611b3d88: [6005f149] handle_mm_fault+0x14e/0x246 611b3da8: [60120a7b] __up_read+0x73/0x7b 611b3de8: [60013177] handle_page_fault+0x11f/0x23b 611b3e48: [60013419] segv+0xac/0x297 611b3f28: [60013367] segv_handler+0x68/0x6e 611b3f48: [600232ad] get_skas_faultinfo+0x9c/0xa1 611b3f68: [60023853] userspace+0x13a/0x19d 611b3fc8: [60010d58] fork_handler+0x86/0x8d OK, that's different. Someone broke the vm - order-2 GFP_KERNEL allocations aren't supposed to fail. I'm suspecting that did_some_progress thing. The allocation didn't fail -- it invoked the OOM killer because the kernel ran out of unfragmented memory. We can't run out of unfragmented memory for an order-2 GFP_KERNEL allocation in this workload. We go and synchronously free stuff up to make it work. How did this get broken? Either no more order-2 pages could be freed, or the ones that were being freed were being used by something else (eg. other order-2 slab allocations). No. The current design of reclaim (for better or for worse) is that for order 0,1,2 and 3 allocations we just keep on trying until it works. That got broken and I think it got broken at a design level when that did_some_progress logic went in. Perhaps something else we did later worsened things. Probably because higher order allocations are the new vogue in -mm at the moment ;) That's a different bug. bug 1: We shouldn't be doing higher-order allocations in slub because of the considerable damage this does to atomic allocations. bug 2: order-2 GFP_KERNEL allocations shouldn't fail like this. I think one causes 2 as well -- it isn't just considerable damage to atomic allocations but to GFP_KERNEL allocations too. Well sure, because we already broke GFP_KERNEL allocations. - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [15/17] SLUB: Support virtual fallback via SLAB_VFALLBACK
On Monday 01 October 2007 06:12, Andrew Morton wrote: On Sun, 30 Sep 2007 05:09:28 +1000 Nick Piggin [EMAIL PROTECTED] wrote: On Sunday 30 September 2007 05:20, Andrew Morton wrote: We can't run out of unfragmented memory for an order-2 GFP_KERNEL allocation in this workload. We go and synchronously free stuff up to make it work. How did this get broken? Either no more order-2 pages could be freed, or the ones that were being freed were being used by something else (eg. other order-2 slab allocations). No. The current design of reclaim (for better or for worse) is that for order 0,1,2 and 3 allocations we just keep on trying until it works. That got broken and I think it got broken at a design level when that did_some_progress logic went in. Perhaps something else we did later worsened things. It will keep trying until it works. It won't have stopped trying (unless I'm very mistaken?), it's just oom killing things merrily along the way. - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC][PATCH 6/6] 9p: 9P server Kconfig and Makefile changes
This patchset provides support for in-kernel 9P2000 servers. 9P server Kconfig and Makefile changes. Signed-off-by: Latchesar Ionkov [EMAIL PROTECTED] --- net/9p/Kconfig |1 + net/9p/Makefile |1 + net/9p/srv/Kconfig |9 + net/9p/srv/Makefile |7 +++ 4 files changed, 18 insertions(+), 0 deletions(-) create mode 100644 net/9p/srv/Kconfig create mode 100644 net/9p/srv/Makefile diff --git a/net/9p/Kconfig b/net/9p/Kconfig index eecbf12..007ce2b 100644 --- a/net/9p/Kconfig +++ b/net/9p/Kconfig @@ -29,3 +29,4 @@ config NET_9P_DEBUG help Say Y if you want the 9P subsistem to log debug information. +source net/9p/srv/Kconfig diff --git a/net/9p/Makefile b/net/9p/Makefile index 5059bc0..be4d93e 100644 --- a/net/9p/Makefile +++ b/net/9p/Makefile @@ -1,5 +1,6 @@ obj-$(CONFIG_NET_9P) := 9pnet.o obj-$(CONFIG_NET_9P_FD) += 9pnet_fd.o +obj-$(CONFIG_NET_9P_SRV) += srv/ 9pnet-objs := \ mod.o \ diff --git a/net/9p/srv/Kconfig b/net/9p/srv/Kconfig new file mode 100644 index 000..2013945 --- /dev/null +++ b/net/9p/srv/Kconfig @@ -0,0 +1,9 @@ +# +# 9P server configuration +# + +config NET_9P_SRV + tristate 9P server support + depends on NET_9P + help + Say Y if you want the 9P server support diff --git a/net/9p/srv/Makefile b/net/9p/srv/Makefile new file mode 100644 index 000..c669592 --- /dev/null +++ b/net/9p/srv/Makefile @@ -0,0 +1,7 @@ +obj-$(CONFIG_NET_9P_SRV) += 9psrv.o + +9psrv-objs := \ + srv.o \ + conn.o \ + fid.o \ + socksrv.o \ -- 1.5.2.4 - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[RFC][PATCH 4/6] 9p: 9P server fid management
This patchset provides support for in-kernel 9P2000 servers. This patch adds the 9P server fid management. Signed-off-by: Latchesar Ionkov [EMAIL PROTECTED] --- net/9p/srv/fid.c | 178 ++ 1 files changed, 178 insertions(+), 0 deletions(-) create mode 100644 net/9p/srv/fid.c diff --git a/net/9p/srv/fid.c b/net/9p/srv/fid.c new file mode 100644 index 000..7c86204 --- /dev/null +++ b/net/9p/srv/fid.c @@ -0,0 +1,178 @@ +/* + * net/9p/srv/fid.c + * + * Fid Management + * + * Copyright (C) 2007 by Latchesar Ionkov [EMAIL PROTECTED] + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include linux/module.h +#include linux/errno.h +#include linux/fs.h +#include linux/poll.h +#include linux/list.h +#include linux/hash.h +#include linux/parser.h +#include net/9p/9p.h +#include net/9p/transport.h +#include net/9p/srv.h +#include srvimpl.h + +struct p9srv_fidpool *p9srv_fidpool_create(void) +{ + int i; + struct p9srv_fidpool *fp; + + fp = kmalloc(sizeof(struct p9srv_fidpool), GFP_KERNEL); + if (!fp) + return ERR_PTR(-ENOMEM); + + spin_lock_init(fp-lock); + for (i = 0; i FID_HTABLE_SIZE; i++) + INIT_HLIST_HEAD(fp-hash[i]); + + P9_DPRINTK(P9SRV_DEBUG_FID, fidpool %p\n, fp); + return fp; +} + +void p9srv_fidpool_destroy(struct p9srv_fidpool *fp) +{ + int i; + + P9_DPRINTK(P9SRV_DEBUG_FID, fidpool %p\n, fp); + for (i = 0; i FID_HTABLE_SIZE; i++) + BUG_ON(!hlist_empty(fp-hash[i])); + + kfree(fp); +} + +void p9srv_fidpool_reset(struct p9srv_fidpool *fp) +{ + int i; + struct p9srv_fid *cfid; + struct hlist_node *hn, *htmp; + HLIST_HEAD(hh); + + P9_DPRINTK(P9SRV_DEBUG_FID, fidpool %p\n, fp); + spin_lock(fp-lock); + for (i = 0; i FID_HTABLE_SIZE; i++) { + hlist_for_each_entry_safe(cfid, hn, htmp, fp-hash[i], + fid_list) { + hlist_del(hn); + hlist_add_head(hn, hh); + } + } + spin_unlock(fp-lock); + + hlist_for_each_entry_safe(cfid, hn, htmp, hh, fid_list) { + atomic_set(cfid-refcount, 1); + p9srv_fid_decref(cfid); + } +} + +struct p9srv_fid *p9srv_fid_create(struct p9srv_fidpool *fp, u32 fid) +{ + unsigned long hash; + struct p9srv_fid *cfid, *nfid; + struct hlist_node *hn; + + P9_DPRINTK(P9SRV_DEBUG_FID, fidpool %p fid %d\n, fp, fid); + hash = hash_long(fid, FID_HTABLE_BITS); + nfid = kmalloc(sizeof(struct p9srv_fid), GFP_KERNEL); + if (!nfid) + return ERR_PTR(-ENOMEM); + + nfid-fid = fid; + atomic_set(nfid-refcount, 0); + nfid-conn = NULL; + nfid-aux = NULL; + nfid-omode = ~0; + nfid-type = 0; + nfid-diroffset = 0; + nfid-uid = ~0; + nfid-fidpool = fp; + INIT_HLIST_NODE(nfid-fid_list); + spin_lock(fp-lock); + hlist_for_each_entry(cfid, hn, fp-hash[hash], fid_list) { + if (cfid-fid == fid) { + spin_unlock(fp-lock); + kfree(nfid); + return ERR_PTR(-EEXIST); + } + } + + hlist_add_head(nfid-fid_list, fp-hash[hash]); + spin_unlock(fp-lock); + p9srv_fid_incref(nfid); + return nfid; +} + +struct p9srv_fid *p9srv_fid_find(struct p9srv_fidpool *fp, u32 fid) +{ + unsigned long hash; + struct p9srv_fid *cfid; + struct hlist_node *hn; + + hash = hash_long(fid, FID_HTABLE_BITS); + spin_lock(fp-lock); + hlist_for_each_entry(cfid, hn, fp-hash[hash], fid_list) { + if (cfid-fid == fid) { + spin_unlock(fp-lock); + p9srv_fid_incref(cfid); + return cfid; + } + } + spin_unlock(fp-lock); + + return NULL; +} +EXPORT_SYMBOL(p9srv_fid_find); + +void p9srv_fid_incref(struct p9srv_fid *fid) +{ + if (fid) + atomic_inc(fid-refcount); + + P9_DPRINTK(P9SRV_DEBUG_FID, fidpool %p fid %d count %d\n, + fid-fidpool, fid-fid, atomic_read(fid-refcount)); +} +EXPORT_SYMBOL(p9srv_fid_incref); + +void
[RFC][REFERENCE ONLY] 9p: 9P ramfs sample implementation
Sample ramfs file server that uses the 9P in-kernel server implementation. This code is for reference only, it is not supposed to be merged into the kernel. Signed-off-by: Latchesar Ionkov [EMAIL PROTECTED] --- net/9p/srv/Kconfig |6 + net/9p/srv/Makefile |4 + net/9p/srv/ramfs.c | 938 +++ 3 files changed, 948 insertions(+), 0 deletions(-) create mode 100644 net/9p/srv/ramfs.c diff --git a/net/9p/srv/Kconfig b/net/9p/srv/Kconfig index 2013945..ecb46ef 100644 --- a/net/9p/srv/Kconfig +++ b/net/9p/srv/Kconfig @@ -7,3 +7,9 @@ config NET_9P_SRV depends on NET_9P help Say Y if you want the 9P server support + +config NET_9P_RAMFS + tristate 9P ramfs sample + depends on NET_9P_SRV + help + Say Y if you want the 9P ramfs support diff --git a/net/9p/srv/Makefile b/net/9p/srv/Makefile index c669592..9db1c31 100644 --- a/net/9p/srv/Makefile +++ b/net/9p/srv/Makefile @@ -1,7 +1,11 @@ obj-$(CONFIG_NET_9P_SRV) += 9psrv.o +obj-$(CONFIG_NET_9P_RAMFS) += 9pramfs.o 9psrv-objs := \ srv.o \ conn.o \ fid.o \ socksrv.o \ + +9pramfs-objs := \ + ramfs.o \ diff --git a/net/9p/srv/ramfs.c b/net/9p/srv/ramfs.c new file mode 100644 index 000..45b9cde --- /dev/null +++ b/net/9p/srv/ramfs.c @@ -0,0 +1,938 @@ +/* + * net/9p/srv/ramfs.c + * + * Simple RAM filesystem + * + * Copyright (C) 200xz7 by Latchesar Ionkov [EMAIL PROTECTED] + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include linux/module.h +#include linux/moduleparam.h +#include linux/errno.h +#include linux/fs.h +#include linux/poll.h +#include linux/parser.h +#include net/9p/9p.h +#include net/9p/transport.h +#include net/9p/srv.h + +#define ROOTPERM 0777 + +struct ramfs_file { + struct mutexlock; /* file lock */ + atomic_trefcount; + unsigned long status; + char*name; + u32 perm; + u64 length; + u32 atime; + u32 mtime; + u32 uid; + u32 gid; + u32 muid; + char*extension; + struct p9_qid qid; + int excl; + + struct ramfs_file *parent; + struct ramfs_file *next; /* protected by parent lock */ + struct ramfs_file *prev; + + struct ramfs_file *dirents; /* if directory */ + struct ramfs_file *dirlast; + + struct list_headfid_list; /* all fids for a file */ + + u8 *data; + u64 datasize; +}; + +struct ramfs_fid { + struct ramfs_file *file; + int omode; + u64 diroffset; + struct ramfs_file *dirent; + struct list_headfid_list; /* all fids for a file */ +}; + +enum { + Removed = 1, +}; + +int debug; +module_param(debug, int, 0); +MODULE_PARM_DESC(debug, Debug level); + +int port = 5641; +module_param(port, int, 0); +MODULE_PARM_DESC(port, Port to listen on); + +static struct p9srv *srv; +static struct ramfs_file *root; +static u64 qidpath; +static int blksize = 8192; + +static char *Enospace = no space left; + +static void ramfs_attach(struct p9srv_req *req); +static void ramfs_walk(struct p9srv_req *req); +static void ramfs_open(struct p9srv_req *req); +static void ramfs_create(struct p9srv_req *req); +static void ramfs_read(struct p9srv_req *req); +static void ramfs_write(struct p9srv_req *req); +static void ramfs_clunk(struct p9srv_req *req); +static void ramfs_remove(struct p9srv_req *req); +static void ramfs_stat(struct p9srv_req *req); +static void ramfs_wstat(struct p9srv_req *req); +static void ramfs_fiddestroy(struct p9srv_fid *fid); +static void ramfs_connopen(struct p9srv_conn *conn); +static void ramfs_connclose(struct p9srv_conn *conn); + +static char *p9_strdup(struct p9_str *str) +{ + char *ret; + + ret = kmalloc(str-len + 1, GFP_KERNEL); + memmove(ret, str-str, str-len); + ret[str-len] = '\0'; + + return ret; +} + +static void file_incref(struct ramfs_file *f)
[RFC][PATCH 1/6] 9p: 9P server low-level 9P messages support
This patchset provides support for in-kernel 9P2000 servers. Implement support for the 9P messages required by the server side. Signed-off-by: Latchesar Ionkov [EMAIL PROTECTED] --- include/net/9p/9p.h | 19 ++ net/9p/conv.c | 508 ++- net/9p/fcprint.c|2 + 3 files changed, 525 insertions(+), 4 deletions(-) diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index 686425a..eaa2385 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h @@ -65,6 +65,7 @@ do { \ /* Message Types */ enum { + P9_FIRST = 100, P9_TVERSION = 100, P9_RVERSION, P9_TAUTH = 102, @@ -93,6 +94,7 @@ enum { P9_RSTAT, P9_TWSTAT = 126, P9_RWSTAT, + P9_LAST, }; /* open modes */ @@ -381,6 +383,7 @@ struct p9_idpool; int p9_deserialize_stat(void *buf, u32 buflen, struct p9_stat *stat, int dotu); int p9_deserialize_fcall(void *buf, u32 buflen, struct p9_fcall *fc, int dotu); +int p9_serialize_stat(struct p9_wstat *wstat, u8 *buf, int buflen, int dotu); void p9_set_tag(struct p9_fcall *fc, u16 tag); struct p9_fcall *p9_create_tversion(u32 msize, char *version); struct p9_fcall *p9_create_tattach(u32 fid, u32 afid, char *uname, @@ -403,6 +406,22 @@ struct p9_fcall *p9_create_tremove(u32 fid); struct p9_fcall *p9_create_tstat(u32 fid); struct p9_fcall *p9_create_twstat(u32 fid, struct p9_wstat *wstat, int dotu); +struct p9_fcall *p9_create_rversion(u32 msize, char *version); +struct p9_fcall *p9_create_rattach(struct p9_qid *qid); +struct p9_fcall *p9_create_rerror(char *ename, u32 ecode, int dotu); +struct p9_fcall *p9_create_rauth(struct p9_qid *qid); +struct p9_fcall *p9_create_rflush(void); +struct p9_fcall *p9_create_rwalk(int nwqid, struct p9_qid *wqids); +struct p9_fcall *p9_create_ropen(struct p9_qid *qid, u32 iounit); +struct p9_fcall *p9_create_rcreate(struct p9_qid *qid, u32 iounit); +struct p9_fcall *p9_create_rread(u32 count, u8 *data); +struct p9_fcall *p9_create_rwrite(u32 count); +struct p9_fcall *p9_create_rclunk(void); +struct p9_fcall *p9_create_rremove(void); +struct p9_fcall *p9_create_rstat(struct p9_wstat *st, int dotu); +struct p9_fcall *p9_create_rwstat(void); +struct p9_fcall *p9_alloc_rread(u32 count); +void p9_set_rread_count(struct p9_fcall *fc, u32 count); int p9_printfcall(char *buf, int buflen, struct p9_fcall *fc, int dotu); int p9_errstr2errno(char *errstr, int len); diff --git a/net/9p/conv.c b/net/9p/conv.c index aa2aa98..7cb8faf 100644 --- a/net/9p/conv.c +++ b/net/9p/conv.c @@ -41,6 +41,8 @@ struct cbuf { unsigned char *ep; }; +static int p9_size_wstat(struct p9_wstat *wstat, int dotu); + static inline void buf_init(struct cbuf *buf, void *data, int datalen) { buf-sp = buf-p = data; @@ -130,9 +132,45 @@ static char *buf_put_stringn(struct cbuf *buf, const char *s, u16 slen) static inline void buf_put_string(struct cbuf *buf, const char *s) { - buf_put_stringn(buf, s, strlen(s)); + buf_put_stringn(buf, s, s?strlen(s):0); +} + +static inline void buf_put_qid(struct cbuf *buf, struct p9_qid *qid) +{ + buf_put_int8(buf, qid-type); + buf_put_int32(buf, qid-version); + buf_put_int64(buf, qid-path); +} + +static inline void buf_put_wstat(struct cbuf *bufp, struct p9_wstat *wstat, + int dotu) +{ + int statsz; + + statsz = p9_size_wstat(wstat, dotu); + buf_put_int16(bufp, statsz); + buf_put_int16(bufp, wstat-type); + buf_put_int32(bufp, wstat-dev); + buf_put_qid(bufp, wstat-qid); + buf_put_int32(bufp, wstat-mode); + buf_put_int32(bufp, wstat-atime); + buf_put_int32(bufp, wstat-mtime); + buf_put_int64(bufp, wstat-length); + + buf_put_string(bufp, wstat-name); + buf_put_string(bufp, wstat-uid); + buf_put_string(bufp, wstat-gid); + buf_put_string(bufp, wstat-muid); + + if (dotu) { + buf_put_string(bufp, wstat-extension); + buf_put_int32(bufp, wstat-n_uid); + buf_put_int32(bufp, wstat-n_gid); + buf_put_int32(bufp, wstat-n_muid); + } } + static u8 buf_get_int8(struct cbuf *buf) { u8 ret = 0; @@ -344,17 +382,63 @@ p9_deserialize_fcall(void *buf, u32 buflen, struct p9_fcall *rcall, default: P9_EPRINTK(KERN_ERR, unknown message type: %d\n, rcall-id); return -EPROTO; + case P9_TVERSION: + rcall-params.tversion.msize = buf_get_int32(bufp); + buf_get_str(bufp, rcall-params.tversion.version); + break; case P9_RVERSION: rcall-params.rversion.msize = buf_get_int32(bufp); buf_get_str(bufp, rcall-params.rversion.version); break; + case P9_TAUTH: + rcall-params.tauth.afid = buf_get_int32(bufp); + buf_get_str(bufp, rcall-params.tauth.uname); +
[RFC][PATCH 2/6] 9p: 9P server interface and common srv code
This patchset provides support for in-kernel 9P2000 servers. This patch adds the header file that defines the 9P server interface as well as the code for the common support functions for the server. Signed-off-by: Latchesar Ionkov [EMAIL PROTECTED] --- include/net/9p/srv.h | 208 net/9p/srv/srv.c | 891 ++ net/9p/srv/srvimpl.h | 46 +++ 3 files changed, 1145 insertions(+), 0 deletions(-) create mode 100644 include/net/9p/srv.h create mode 100644 net/9p/srv/srv.c create mode 100644 net/9p/srv/srvimpl.h diff --git a/include/net/9p/srv.h b/include/net/9p/srv.h new file mode 100644 index 000..36635c6 --- /dev/null +++ b/include/net/9p/srv.h @@ -0,0 +1,208 @@ +/* + * include/net/9p/srv.h + * + * 9P server definitions. + * + * Copyright (C) 2007 by Latchesar Ionkov [EMAIL PROTECTED] + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#ifndef NET_9PSRV_H +#define NET_9PSRV_H + +#define P9SRV_DEBUG_SRV(116) +#define P9SRV_DEBUG_CONN (117) +#define P9SRV_DEBUG_FID(118) +#define P9SRV_DEBUG_REQ(119) +#define P9SRV_DEBUG_FCALL (120) +#define P9SRV_DEBUG_FS (121) + +#define MAXPOLLWADDR 2 + +struct p9srv; +struct p9srv_fid; +struct p9srv_fidpool; +struct p9srv_conn; +struct p9srv_req; + +struct p9srv { + int msize; + int dotu; /* 9P2000.u */ + void*srvaux; + void*treeaux; + int debuglevel; + void(*start)(struct p9srv *); + void(*stop)(struct p9srv *); + void(*destroy)(struct p9srv *); + void(*connopen)(struct p9srv_conn *); + void(*connclose)(struct p9srv_conn *); + void(*fiddestroy)(struct p9srv_fid *); + void(*reqdestroy)(struct p9srv_req *); + + /* 9P message handlers */ + void(*attach)(struct p9srv_req *); + void(*auth)(struct p9srv_req *); + int (*flush)(struct p9srv_req *); + void(*walk)(struct p9srv_req *); + void(*open)(struct p9srv_req *); + void(*create)(struct p9srv_req *); + void(*read)(struct p9srv_req *); + void(*write)(struct p9srv_req *); + void(*clunk)(struct p9srv_req *); + void(*remove)(struct p9srv_req *); + void(*stat)(struct p9srv_req *); + void(*wstat)(struct p9srv_req *); + + /* implementation specific */ + atomic_trefcount; + spinlock_t lock; /* covers all srv fields */ + unsigned long status; + struct list_headconn_list; /* all connections for srv */ + struct list_headreq_list; /* requests not yet worked on */ + struct list_headworkreq_list; /* requests being worked on */ + struct work_struct pq; /* process request */ +}; + +enum { + /* connection status values */ + Worksched = 1, /* work scheduled or running */ +}; + +struct p9srv_conn { + struct p9srv*srv; + struct p9_trans *trans; + int msize; + int dotu; /* 9P2000.u */ + + /* implementation specific */ + spinlock_t lock; /* covers all conn fields */ + unsigned long status; + struct p9srv_fidpool*fidpool; + struct work_struct rq; + struct work_struct wq; + struct list_headconn_list; /* all srv connections */ + struct list_headvpt_conn_list; /* all connections for vpt */ + + /* outgoing data */ + struct list_headoreq_list; + char*obuf; /* outgoing data */ + int opos; /* next byte in obuf */ + int osize; /* obuf size */ + + /* incoming data */
[RFC][PATCH 5/6] 9p: 9P server TCP socket connection support
This patchset provides support for in-kernel 9P2000 servers. Support for 9P servers listening on TCP sockets. Signed-off-by: Latchesar Ionkov [EMAIL PROTECTED] --- net/9p/srv/socksrv.c | 252 ++ 1 files changed, 252 insertions(+), 0 deletions(-) create mode 100644 net/9p/srv/socksrv.c diff --git a/net/9p/srv/socksrv.c b/net/9p/srv/socksrv.c new file mode 100644 index 000..c304b91 --- /dev/null +++ b/net/9p/srv/socksrv.c @@ -0,0 +1,252 @@ +/* + * net/9p/srv/socksrv.c + * + * 9P Socket Server + * + * Copyright (C) 2007 by Latchesar Ionkov [EMAIL PROTECTED] + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include linux/module.h +#include linux/errno.h +#include linux/fs.h +#include linux/poll.h +#include linux/kthread.h +#include linux/net.h +#include linux/in.h +#include linux/parser.h +#include net/tcp.h +#include net/sock.h +#include net/9p/9p.h +#include net/9p/transport.h +#include net/9p/srv.h +#include srvimpl.h + +struct p9srv_socksrv { + struct sockaddr_in saddr; + struct socket *sock; + struct p9srv*srv; + struct work_struct wq; +}; + +void (*p9srv_socksrv_dr_save)(struct sock *sock, int count); + +static void p9srv_socksrv_start(struct p9srv *); +static void p9srv_socksrv_stop(struct p9srv *); +static void p9srv_socksrv_destroy(struct p9srv *); +static void p9srv_socksrv_data_ready(struct sock *sock, int count); +static void p9srv_socksrv_accept(struct work_struct *work); + +struct p9srv *p9srv_socksrv_create(int port) +{ + int n, err; + struct p9srv_socksrv *ss; + struct p9srv *srv; + + srv = NULL; + ss = kmalloc(sizeof(struct p9srv_socksrv), GFP_KERNEL); + if (!ss) + return ERR_PTR(-ENOMEM); + + ss-sock = NULL; + err = sock_create_kern(PF_INET, SOCK_STREAM, IPPROTO_TCP, ss-sock); + if (!ss-sock) { + P9_DPRINTK(P9SRV_DEBUG_SRV, cannot create socket %d\n, err); + goto error; + } + + n = 1; + ss-saddr.sin_family = AF_INET; + memset(ss-saddr.sin_zero, 0, sizeof(ss-saddr.sin_zero)); + ss-saddr.sin_addr.s_addr = htonl(INADDR_ANY); + ss-saddr.sin_port = htons(port); + err = ss-sock-ops-bind(ss-sock, (struct sockaddr *) ss-saddr, + sizeof(ss-saddr)); + if (err 0) { + P9_DPRINTK(P9SRV_DEBUG_SRV, cannot create bind %d\n, err); + goto error; + } + + err = kernel_setsockopt(ss-sock, SOL_SOCKET, SO_REUSEADDR, (char *) n, + sizeof(n)); + if (err 0) { + P9_DPRINTK(P9SRV_DEBUG_SRV, cannot create setsockopt\n); + goto error; + } + + srv = p9srv_srv_create(); + if (!srv) { + err = PTR_ERR(srv); + srv = NULL; + goto error; + } + + ss-srv = srv; + INIT_WORK(ss-wq, p9srv_socksrv_accept); + srv-srvaux = ss; + srv-start = p9srv_socksrv_start; + srv-stop = p9srv_socksrv_stop; + srv-destroy = p9srv_socksrv_destroy; + + P9_DPRINTK(P9SRV_DEBUG_SRV, server %p on port %d created\n, + srv, port); + return srv; + +error: + if (ss-sock) + sock_release(ss-sock); + + if (srv) + p9srv_srv_destroy(srv); + + kfree(ss); + return ERR_PTR(err); +} +EXPORT_SYMBOL(p9srv_socksrv_create); + +static void p9srv_socksrv_start(struct p9srv *srv) +{ + int err; + struct p9srv_socksrv *ss; + + ss = srv-srvaux; + err = ss-sock-ops-listen(ss-sock, 5); + if (err 0) { + P9_DPRINTK(P9SRV_DEBUG_SRV, cannot listen %d\n, err); + return; + } + + p9srv_socksrv_dr_save = ss-sock-sk-sk_data_ready; + ss-sock-sk-sk_data_ready = p9srv_socksrv_data_ready; + ss-sock-sk-sk_user_data = srv; +} + +static void p9srv_socksrv_stop(struct p9srv *srv) +{ + struct p9srv_socksrv *ss; + + P9_DPRINTK(P9SRV_DEBUG_SRV, srv %p\n, srv); + ss = srv-srvaux; + if (ss-sock) { + ss-sock-ops-shutdown(ss-sock, 2); + sock_release(ss-sock); + ss-sock = NULL; + } + + ss-sock = NULL; +} + +static void p9srv_socksrv_destroy(struct p9srv *srv) +{ + struct
[RFC][PATCH 3/6] 9p: 9P server connection code
This patchset provides support for in-kernel 9P2000 servers. This patch add the 9P server connection code. Signed-off-by: Latchesar Ionkov [EMAIL PROTECTED] --- net/9p/srv/conn.c | 743 + 1 files changed, 743 insertions(+), 0 deletions(-) create mode 100644 net/9p/srv/conn.c diff --git a/net/9p/srv/conn.c b/net/9p/srv/conn.c new file mode 100644 index 000..335ee17 --- /dev/null +++ b/net/9p/srv/conn.c @@ -0,0 +1,743 @@ +/* + * net/9p/srv/conn.c + * + * Server connection + * + * Copyright (C) 2007 by Latchesar Ionkov [EMAIL PROTECTED] + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to: + * Free Software Foundation + * 51 Franklin Street, Fifth Floor + * Boston, MA 02111-1301 USA + * + */ + +#include linux/module.h +#include linux/errno.h +#include linux/fs.h +#include linux/poll.h +#include linux/kthread.h +#include linux/parser.h +#include net/9p/9p.h +#include net/9p/transport.h +#include net/9p/srv.h +#include srvimpl.h + +#define SCHED_TIMEOUT 10 + +struct p9srv_poll_task { + struct task_struct *task; + struct list_head conn_list; + int connum; +}; + +static DEFINE_MUTEX(p9srv_task_lock); +struct workqueue_struct *p9srv_wq; + +static int p9srv_num; +static int p9srv_poll_task_num; +static struct p9srv_poll_task p9srv_poll_tasks[100]; + +static int p9srv_calc_poll_procs(int); +static int p9srv_poll_start(struct p9srv_conn *c); +static void p9srv_poll_stop(struct p9srv_conn *c); +static void p9srv_pollwait(struct file *, wait_queue_head_t *, poll_table *); +static void p9srv_poll_conn(struct p9srv_conn *c); +static int p9srv_poll_proc(void *a); +static void p9srv_read_work(struct work_struct *work); +static void p9srv_write_work(struct work_struct *work); + +int p9srv_conn_init(void) +{ + int i; + + for (i = 0; i ARRAY_SIZE(p9srv_poll_tasks); i++) + p9srv_poll_tasks[i].task = NULL; + + p9srv_wq = create_workqueue(9psrv); + if (!p9srv_wq) { + printk(KERN_WARNING 9psrv: creating workqueue failed\n); + return -ENOMEM; + } + + return 0; +} + +void p9srv_conn_exit(void) +{ + destroy_workqueue(p9srv_wq); + p9srv_wq = NULL; +} + +struct p9srv_conn *p9srv_conn_create(struct p9srv *srv, + struct p9_trans *trans) +{ + int i, n, err; + struct p9srv_conn *conn; + + conn = kmalloc(sizeof(struct p9srv_conn), GFP_KERNEL); + if (!conn) + return ERR_PTR(-ENOMEM); + + spin_lock_init(conn-lock); + conn-srv = srv; + conn-trans = trans; + conn-msize = srv-msize; + conn-dotu = srv-dotu; + conn-status = 0; + INIT_WORK(conn-rq, p9srv_read_work); + INIT_WORK(conn-wq, p9srv_write_work); + INIT_LIST_HEAD(conn-conn_list); + INIT_LIST_HEAD(conn-vpt_conn_list); + INIT_LIST_HEAD(conn-oreq_list); + conn-opos = 0; + conn-osize = 0; + conn-obuf = NULL; + conn-icall = NULL; + conn-ipos = 0; + conn-ibuf = 0; + conn-poll_task = NULL; + memset(conn-poll_wait, 0, sizeof(conn-poll_wait)); + memset(conn-poll_waddr, 0, sizeof(conn-poll_waddr)); + conn-fidpool = p9srv_fidpool_create(); + if (!conn-fidpool) { + err = PTR_ERR(conn-fidpool); + kfree(conn); + return ERR_PTR(err); + } + + err = p9srv_poll_start(conn); + if (err) { + p9srv_fidpool_destroy(conn-fidpool); + kfree(conn); + return ERR_PTR(err); + } + + n = trans-poll(trans, conn-pt); + if (n POLLIN) + set_bit(Rpending, conn-status); + + if (n POLLOUT) + set_bit(Wpending, conn-status); + + for (i = 0; i ARRAY_SIZE(conn-poll_waddr); i++) { + if (IS_ERR(conn-poll_waddr[i])) { + p9srv_poll_stop(conn); + err = PTR_ERR(conn-poll_waddr[i]); + p9srv_fidpool_destroy(conn-fidpool); + kfree(conn); + return ERR_PTR(err); + } + } + + spin_lock(srv-lock); + list_add_tail(conn-conn_list, srv-conn_list); + spin_unlock(srv-lock); + + if (test_bit(Rpending, conn-status) + !test_and_set_bit(Rworksched, conn-status)) + queue_work(p9srv_wq, conn-rq); + + if (srv-connopen)
[GIT PULL -mm] 00/19 Unionfs updates/cleanups/fixes
The following is a series of patches related to Unionfs. The main changes here are compliance with coding style and assorted cleanups, based on lkml comments and advise. Specifically, the un/likely updates from the previous series of patches was completely redone; the number of un/likely instances was reduced from 546 to 163 and what's left are considered highly unlikely (99% or higher threshold). These patches were tested (where appropriate) on our 2.6.23-rc8 latest code, as well as the backports to 2.6.{22,21,20,19,18,9} on ext2/3/4, xfs, reiserfs, nfs2/3/4, jffs2, ramfs, tmpfs, cramfs, and squashfs (where available). See http://unionfs.filesystems.org/ to download backported unionfs code. Please pull from the 'master' branch of git://git.kernel.org/pub/scm/linux/kernel/git/ezk/unionfs.git to receive the following: Erez Zadok (19): Unionfs: compile if debug is off Unionfs: add un/likely on conditionals Unionfs: minor comment cleanups Unionfs: use consistent printk prefixes Unionfs: use UNIONFS_NAME macro Unionfs: properly indent static struct Unionfs: remove unnecessary if condition Unionfs: use page_offset() helper Unionfs: use pr_debug() instead of custom dprintk() Unionfs: convert all appropriate printk's to pr_debug calls Unionfs: add missing newlines in printk's Unionfs: update/assign a KERN_* level to all printk statements Unionfs: remove periods from the end of printk strings Unionfs: use braces in both branches of conditionals Unionfs: coding style: proper spacing Unionfs: coding style: take assignments out of if conditions Unionfs: coding style: avoid multiple assignments on same line Unionfs: coding style: miscellaneous fixes Unionfs: coding style: avoid lines longer than 80 chars Makefile |4 commonfops.c | 86 ++-- copyup.c | 31 ++-- debug.c | 406 +-- dentry.c | 66 - dirfops.c| 32 ++-- dirhelper.c | 13 + fanout.h | 11 + file.c | 29 ++-- inode.c | 82 ++- lookup.c | 29 ++-- main.c | 80 ++- mmap.c | 18 +- rdstate.c| 18 +- rename.c | 59 subr.c | 13 + super.c | 102 +++--- union.h | 52 +++ unlink.c | 22 +-- xattr.c | 16 +- 20 files changed, 622 insertions(+), 547 deletions(-) --- Erez Zadok [EMAIL PROTECTED] - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 01/19] Unionfs: compile if debug is off
Signed-of-by: John Johansen [EMAIL PROTECTED] Signed-off-by: Erez Zadok [EMAIL PROTECTED] --- fs/unionfs/union.h |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h index 824bb67..7ce4771 100644 --- a/fs/unionfs/union.h +++ b/fs/unionfs/union.h @@ -556,6 +556,7 @@ extern void __show_inode_counts(const struct inode *inode, #define unionfs_check_inode(i) do { } while(0) #define unionfs_check_dentry(d)do { } while(0) #define unionfs_check_file(f) do { } while(0) +#define unionfs_check_nd(n)do { } while(0) #define show_branch_counts(sb) do { } while(0) #define show_inode_times(i)do { } while(0) #define show_dinode_times(d) do { } while(0) -- 1.5.2.2 - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 04/19] Unionfs: use consistent printk prefixes
Signed-off-by: Erez Zadok [EMAIL PROTECTED] --- fs/unionfs/inode.c |4 ++-- fs/unionfs/union.h |4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c index 021e206..ba85a67 100644 --- a/fs/unionfs/inode.c +++ b/fs/unionfs/inode.c @@ -90,7 +90,7 @@ static int unionfs_create(struct inode *parent, struct dentry *dentry, unlock_dir(lower_dir_dentry); if (err) { - printk(unionfs_create: could not unlink + printk(unionfs: create: could not unlink whiteout, err = %d\n, err); goto out; } @@ -1088,7 +1088,7 @@ static int unionfs_setattr(struct dentry *dentry, struct iattr *ia) if (ia-ia_size != i_size_read(inode)) { err = vmtruncate(inode, ia-ia_size); if (err) - printk(unionfs_setattr: vmtruncate failed\n); + printk(unionfs: setattr: vmtruncate failed\n); } } diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h index 7ce4771..91f7f1e 100644 --- a/fs/unionfs/union.h +++ b/fs/unionfs/union.h @@ -474,7 +474,7 @@ static inline struct vfsmount *unionfs_mntget(struct dentry *dentry, mnt = mntget(unionfs_lower_mnt_idx(dentry, bindex)); #ifdef CONFIG_UNION_FS_DEBUG if (!mnt) - printk(KERN_DEBUG unionfs_mntget: mnt=%p bindex=%d\n, + printk(KERN_DEBUG unionfs: mntget: mnt=%p bindex=%d\n, mnt, bindex); #endif /* CONFIG_UNION_FS_DEBUG */ @@ -500,7 +500,7 @@ static inline void unionfs_mntput(struct dentry *dentry, int bindex) */ if (!mnt !(bindex dbstart(dentry) bindex dbend(dentry))) printk(KERN_WARNING - unionfs_mntput: mnt=%p bindex=%d\n, + unionfs: mntput: mnt=%p bindex=%d\n, mnt, bindex); #endif /* CONFIG_UNION_FS_DEBUG */ mntput(mnt); -- 1.5.2.2 - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 03/19] Unionfs: minor comment cleanups
Signed-off-by: Erez Zadok [EMAIL PROTECTED] --- fs/unionfs/lookup.c |2 +- fs/unionfs/mmap.c |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c index 94e4c8e..53668d6 100644 --- a/fs/unionfs/lookup.c +++ b/fs/unionfs/lookup.c @@ -206,7 +206,7 @@ struct dentry *unionfs_lookup_backend(struct dentry *dentry, } if (wh_lower_dentry-d_inode) { - /* We found a whiteout so lets give up. */ + /* We found a whiteout so let's give up. */ if (S_ISREG(wh_lower_dentry-d_inode-i_mode)) { set_dbend(dentry, bindex); set_dbopaque(dentry, bindex); diff --git a/fs/unionfs/mmap.c b/fs/unionfs/mmap.c index bcd4267..cf9545e 100644 --- a/fs/unionfs/mmap.c +++ b/fs/unionfs/mmap.c @@ -293,7 +293,7 @@ static int unionfs_commit_write(struct file *file, struct page *page, lower_file-f_pos = ((loff_t) page-index PAGE_CACHE_SHIFT) + from; /* -* SP: I use vfs_write instead of copying page data and the +* We use vfs_write instead of copying page data and the * prepare_write/commit_write combo because file system's like * GFS/OCFS2 don't like things touching those directly, * calling the underlying write op, while a little bit slower, will -- 1.5.2.2 - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 07/19] Unionfs: remove unnecessary if condition
The condition is always true there. Signed-off-by: Erez Zadok [EMAIL PROTECTED] --- fs/unionfs/dirfops.c | 10 -- 1 files changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/unionfs/dirfops.c b/fs/unionfs/dirfops.c index 200fb55..da0fcdb 100644 --- a/fs/unionfs/dirfops.c +++ b/fs/unionfs/dirfops.c @@ -63,12 +63,10 @@ static int unionfs_filldir(void *dirent, const char *name, int namelen, off_t pos = rdstate2offset(buf-rdstate); u64 unionfs_ino = ino; - if (!err) { - err = buf-filldir(buf-dirent, name, namelen, pos, - unionfs_ino, d_type); - buf-rdstate-offset++; - verify_rdstate_offset(buf-rdstate); - } + err = buf-filldir(buf-dirent, name, namelen, pos, + unionfs_ino, d_type); + buf-rdstate-offset++; + verify_rdstate_offset(buf-rdstate); } /* * If we did fill it, stuff it in our hash, otherwise return an -- 1.5.2.2 - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 08/19] Unionfs: use page_offset() helper
Signed-off-by: Erez Zadok [EMAIL PROTECTED] --- fs/unionfs/mmap.c |7 +++ 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/unionfs/mmap.c b/fs/unionfs/mmap.c index cf9545e..8928e99 100644 --- a/fs/unionfs/mmap.c +++ b/fs/unionfs/mmap.c @@ -179,8 +179,7 @@ static int unionfs_do_readpage(struct file *file, struct page *page) * may be a little slower, but a lot safer, as the VFS does a lot of * the necessary magic for us. */ - offset = lower_file-f_pos = - ((loff_t) page-index PAGE_CACHE_SHIFT); + offset = lower_file-f_pos = page_offset(page); old_fs = get_fs(); set_fs(KERNEL_DS); err = vfs_read(lower_file, page_data, PAGE_CACHE_SIZE, @@ -290,7 +289,7 @@ static int unionfs_commit_write(struct file *file, struct page *page, BUG_ON(lower_file == NULL); page_data = (char *)kmap(page); - lower_file-f_pos = ((loff_t) page-index PAGE_CACHE_SHIFT) + from; + lower_file-f_pos = page_offset(page) + from; /* * We use vfs_write instead of copying page data and the @@ -312,7 +311,7 @@ static int unionfs_commit_write(struct file *file, struct page *page, inode-i_blocks = lower_inode-i_blocks; /* we may have to update i_size */ - pos = ((loff_t) page-index PAGE_CACHE_SHIFT) + to; + pos = page_offset(page) + to; if (pos i_size_read(inode)) i_size_write(inode, pos); /* if vfs_write succeeded above, sync up our times */ -- 1.5.2.2 - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 09/19] Unionfs: use pr_debug() instead of custom dprintk()
Also turn on DEBUG if CONFIG_UNION_FS_DEBUG is on Signed-off-by: Erez Zadok [EMAIL PROTECTED] --- fs/unionfs/Makefile |4 fs/unionfs/commonfops.c |4 ++-- fs/unionfs/dentry.c |6 +++--- fs/unionfs/lookup.c |2 +- fs/unionfs/union.h |6 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fs/unionfs/Makefile b/fs/unionfs/Makefile index 38fed90..17ca4a7 100644 --- a/fs/unionfs/Makefile +++ b/fs/unionfs/Makefile @@ -7,3 +7,7 @@ unionfs-y := subr.o dentry.o file.o inode.o main.o super.o \ unionfs-$(CONFIG_UNION_FS_XATTR) += xattr.o unionfs-$(CONFIG_UNION_FS_DEBUG) += debug.o + +ifeq ($(CONFIG_UNION_FS_DEBUG),y) +EXTRA_CFLAGS += -DDEBUG +endif diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c index 8550a34..16df572 100644 --- a/fs/unionfs/commonfops.c +++ b/fs/unionfs/commonfops.c @@ -394,8 +394,8 @@ int unionfs_file_revalidate(struct file *file, bool willwrite) if (willwrite IS_WRITE_FLAG(file-f_flags) !IS_WRITE_FLAG(unionfs_lower_file(file)-f_flags) is_robranch(dentry)) { - dprintk(KERN_DEBUG unionfs: do delay copyup of \%s\\n, - dentry-d_name.name); + pr_debug(unionfs: do delay copyup of \%s\\n, +dentry-d_name.name); err = do_delayed_copyup(file); } diff --git a/fs/unionfs/dentry.c b/fs/unionfs/dentry.c index 89f6a91..5dde6af 100644 --- a/fs/unionfs/dentry.c +++ b/fs/unionfs/dentry.c @@ -46,9 +46,9 @@ static bool __unionfs_d_revalidate_one(struct dentry *dentry, /* if the dentry is unhashed, do NOT revalidate */ if (d_deleted(dentry)) { - dprintk(KERN_DEBUG unionfs: unhashed dentry being - revalidated: %*s\n, - dentry-d_name.len, dentry-d_name.name); + pr_debug(unionfs: unhashed dentry being +revalidated: %*s\n, +dentry-d_name.len, dentry-d_name.name); goto out; } diff --git a/fs/unionfs/lookup.c b/fs/unionfs/lookup.c index 53668d6..9c6fd56 100644 --- a/fs/unionfs/lookup.c +++ b/fs/unionfs/lookup.c @@ -629,7 +629,7 @@ int init_lower_nd(struct nameidata *nd, unsigned int flags) * We should never get here, for now. * We can add new cases here later on. */ - dprintk(unionfs: unknown nameidata flag 0x%x\n, flags); + pr_debug(unionfs: unknown nameidata flag 0x%x\n, flags); BUG(); break; } diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h index 91f7f1e..4e3cb53 100644 --- a/fs/unionfs/union.h +++ b/fs/unionfs/union.h @@ -508,10 +508,8 @@ static inline void unionfs_mntput(struct dentry *dentry, int bindex) #ifdef CONFIG_UNION_FS_DEBUG -#define dprintk(args...) printk(args) - /* useful for tracking code reachability */ -#define UDBG printk(DBG:%s:%s:%d\n,__FILE__,__FUNCTION__,__LINE__) +#define UDBG pr_debug(DBG:%s:%s:%d\n,__FILE__,__FUNCTION__,__LINE__) #define unionfs_check_inode(i) __unionfs_check_inode((i), \ __FILE__,__FUNCTION__,__LINE__) @@ -550,8 +548,6 @@ extern void __show_inode_counts(const struct inode *inode, #else /* not CONFIG_UNION_FS_DEBUG */ -#define dprintk(args...) do { } while (0) - /* we leave useful hooks for these check functions throughout the code */ #define unionfs_check_inode(i) do { } while(0) #define unionfs_check_dentry(d)do { } while(0) -- 1.5.2.2 - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 05/19] Unionfs: use UNIONFS_NAME macro
Signed-off-by: Erez Zadok [EMAIL PROTECTED] --- fs/unionfs/debug.c |2 +- fs/unionfs/main.c |4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/unionfs/debug.c b/fs/unionfs/debug.c index b103eb9..da82a47 100644 --- a/fs/unionfs/debug.c +++ b/fs/unionfs/debug.c @@ -428,7 +428,7 @@ void __unionfs_check_nd(const struct nameidata *nd, file = nd-intent.open.file; if (unlikely(file-f_path.dentry strcmp(file-f_dentry-d_sb-s_type-name, - unionfs))) { + UNIONFS_NAME))) { PRINT_CALLER(fname, fxn, line); printk( CND1: lower_file of type %s\n, file-f_path.dentry-d_sb-s_type-name); diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c index 72438fb..615617a 100644 --- a/fs/unionfs/main.c +++ b/fs/unionfs/main.c @@ -227,7 +227,7 @@ void unionfs_reinterpose(struct dentry *dentry) int check_branch(struct nameidata *nd) { /* XXX: remove in ODF code -- stacking unions allowed there */ - if (!strcmp(nd-dentry-d_sb-s_type-name, unionfs)) + if (!strcmp(nd-dentry-d_sb-s_type-name, UNIONFS_NAME)) return -EINVAL; if (!nd-dentry-d_inode) return -ENOENT; @@ -722,7 +722,7 @@ static int unionfs_get_sb(struct file_system_type *fs_type, static struct file_system_type unionfs_fs_type = { .owner = THIS_MODULE, - .name = unionfs, + .name = UNIONFS_NAME, .get_sb = unionfs_get_sb, .kill_sb= generic_shutdown_super, .fs_flags = FS_REVAL_DOT, -- 1.5.2.2 - To unsubscribe from this list: send the line unsubscribe linux-fsdevel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html