read/write support for shm fs
Subsystems (5)
PATCH 1/1 read/write support for shm fs
Hi Alan,
Here is a patch which makes the shm fs a full swappable file system like Solaris' tmpfs.
Does anybody have a really good fs check tool? Not benchmarking, but concurrent truncate, read, write, unlink stress test. Would be good to test it with that. I did my usual POSIX/SYSV shm tests which it survived quite easily.
The patch is additional to my truncate patch which is included in 2.4.0-ac8.
Greetings
Christoph
include/linux/fs.h +2 -0
@@ -1198,6 +1198,7 @@ }return inode; } +extern void remove_suid (struct inode *inode);extern void insert_inode_hash (struct inode *);extern void remove_inode_hash (struct inode *);
@@ -1245,6 +1246,7 @@int block_truncate_page (struct address_space *,loff_t ,get_block_t *);extern int generic_file_mmap (struct file *,struct vm_area_struct *); +extern int file_read_actor (read_descriptor_t * desc,struct page *page,unsigned long offset,unsigned long size);extern ssize_t generic_file_read (struct file *,char *,size_t ,loff_t *);extern ssize_t generic_file_write (struct file *,const char *,size_t ,loff_t *);extern void do_generic_file_read (struct file *,loff_t *,read_descriptor_t *,read_actor_t );
include/linux/mm.h +2 -2
@@ -200,8 +200,8 @@smp_mb__before_clear_bit (); \if (!test_and_clear_bit (PG_locked, &(page)->flags))BUG (); \smp_mb__after_clear_bit (); \ -if (waitqueue_active (&page->wait)) \ -wake_up (&page->wait); \ +if (waitqueue_active (&(page)->wait)) \ +wake_up (&(page)->wait); \ } while (0)#define PageError (page) test_bit(PG_error, &(page)->flags)#define SetPageError (page) set_bit(PG_error, &(page)->flags)
mm/filemap.c +2 -2
@@ -1212,7 +1212,7 @@UPDATE_ATIME (inode); } -static int file_read_actor (read_descriptor_t * desc,struct page *page,unsigned long offset,unsigned long size) +int file_read_actor (read_descriptor_t * desc,struct page *page,unsigned long offset,unsigned long size) {char *kaddr;unsigned long left, count = desc->count;
@@ -2408,7 +2408,7 @@return page; } -static inline void remove_suid (struct inode *inode) +inline void remove_suid (struct inode *inode) {unsigned int mode;
mm/shmem.c +297 -67
474 lines not on this page · raw message
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
PATCH 1/1 symlink fix for shm/swap fs
Hi Alan,
Here comes a patch which fixes the totally broken symlink support in shm/swapfs. It is additional to my former patches for read and write support.
It survives now a parallel kernel make on my 8way.
Greetings
Christoph
mm/shmem.c +64 -8
@@ -39,6 +39,7 @@static struct inode_operations shmem_inode_operations;static struct file_operations shmem_dir_operations;static struct inode_operations shmem_dir_inode_operations; +static struct inode_operations shmem_symlink_inode_operations;static struct vm_operations_struct shmem_vm_ops;LIST_HEAD (shmem_inodes);
@@ -127,7 +128,7 @@spin_lock (&info->lock); index = (inode->i_size +PAGE_CACHE_SIZE -1 ) >>PAGE_CACHE_SHIFT ; -if (index >= info->max_index) +if (index > info->max_index) goto out; start =shmem_truncate_part (info->i_direct,SHMEM_NR_DIRECT , index, &freed);
@@ -419,7 +420,7 @@ inode->i_fop = &shmem_dir_operations;break ;case S_IFLNK : - inode->i_op = &page_symlink_inode_operations; + inode->i_op = &shmem_symlink_inode_operations;break ; }spin_lock (&shmem_ilock);
@@ -787,14 +788,63 @@static int shmem_symlink (struct inode * dir,struct dentry *dentry,const char * symname) {int error; +int len; +struct inode *inode; +struct page *page; +char *kaddr; error =shmem_mknod (dir, dentry,S_IFLNK |S_IRWXUGO ,0 ); -if (!error) { -int l =strlen (symname)+1 ; -struct inode *inode = dentry->d_inode; - error =block_symlink (inode, symname, l); - } -return error; +if (error) +return error; + + len =strlen (symname); +if (len >PAGE_SIZE ) +return -ENAMETOOLONG ; + + inode = dentry->d_inode; +down (&inode->i_sem); + page =shmem_getpage_locked (inode,0 ); +if (IS_ERR (page)) + goto fail; + kaddr =kmap (page); +memcpy (kaddr, symname, len); +kunmap (page); + inode->i_size = len; +SetPageDirty (page); +UnlockPage (page); +page_cache_release (page); +up (&inode->i_sem); +return 0 ; +fail: +up (&inode->i_sem); +return PTR_ERR (page); +} + +static int shmem_readlink (struct dentry *dentry,char *buffer,int buflen) +{ +struct page * page; +int res =shmem_getpage (dentry->d_inode,0 , &page); + +if (res) +return res; + + res =vfs_readlink (dentry,buffer,buflen,kmap (page)); +kunmap (page); +page_cache_release (page); +return res; +} + +static int shmem_follow_link (struct dentry *dentry,struct nameidata *nd) +{ +struct page * page; +int res =shmem_getpage (dentry->d_inode,0 , &page); +if (res) +return res; + + res =vfs_follow_link (nd,kmap (page)); +kunmap (page); +page_cache_release (page); +return res; }static int shmem_parse_options (char *options,int *mode,unsigned long * blocks,unsigned long *inodes)
@@ -912,6 +962,12 @@static struct inode_operations shmem_inode_operations = { truncate: shmem_truncate, +}; + +static struct inode_operations shmem_symlink_inode_operations = { + truncate: shmem_truncate, + readlink: shmem_readlink, + follow_link: shmem_follow_link, };static struct file_operations shmem_dir_operations = {
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/