aboutsummaryrefslogtreecommitdiffstats
path: root/fs/affs
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /fs/affs
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'fs/affs')
-rw-r--r--fs/affs/Makefile2
-rw-r--r--fs/affs/affs.h1
-rw-r--r--fs/affs/amigaffs.c4
-rw-r--r--fs/affs/file.c6
-rw-r--r--fs/affs/inode.c2
-rw-r--r--fs/affs/namei.c69
-rw-r--r--fs/affs/super.c42
7 files changed, 71 insertions, 55 deletions
diff --git a/fs/affs/Makefile b/fs/affs/Makefile
index b2c4f54446f3..3988b4a78339 100644
--- a/fs/affs/Makefile
+++ b/fs/affs/Makefile
@@ -2,7 +2,7 @@
2# Makefile for the Linux affs filesystem routines. 2# Makefile for the Linux affs filesystem routines.
3# 3#
4 4
5#EXTRA_CFLAGS=-DDEBUG=1 5#ccflags-y := -DDEBUG=1
6 6
7obj-$(CONFIG_AFFS_FS) += affs.o 7obj-$(CONFIG_AFFS_FS) += affs.o
8 8
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index a8cbdeb34025..0e95f73a7023 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -201,6 +201,7 @@ extern const struct address_space_operations affs_aops;
201extern const struct address_space_operations affs_aops_ofs; 201extern const struct address_space_operations affs_aops_ofs;
202 202
203extern const struct dentry_operations affs_dentry_operations; 203extern const struct dentry_operations affs_dentry_operations;
204extern const struct dentry_operations affs_intl_dentry_operations;
204 205
205static inline void 206static inline void
206affs_set_blocksize(struct super_block *sb, int size) 207affs_set_blocksize(struct super_block *sb, int size)
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 7d0f0a30f7a3..3a4557e8325c 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -128,7 +128,7 @@ affs_fix_dcache(struct dentry *dentry, u32 entry_ino)
128 void *data = dentry->d_fsdata; 128 void *data = dentry->d_fsdata;
129 struct list_head *head, *next; 129 struct list_head *head, *next;
130 130
131 spin_lock(&dcache_lock); 131 spin_lock(&inode->i_lock);
132 head = &inode->i_dentry; 132 head = &inode->i_dentry;
133 next = head->next; 133 next = head->next;
134 while (next != head) { 134 while (next != head) {
@@ -139,7 +139,7 @@ affs_fix_dcache(struct dentry *dentry, u32 entry_ino)
139 } 139 }
140 next = next->next; 140 next = next->next;
141 } 141 }
142 spin_unlock(&dcache_lock); 142 spin_unlock(&inode->i_lock);
143} 143}
144 144
145 145
diff --git a/fs/affs/file.c b/fs/affs/file.c
index c4a9875bd1a6..acf321b70fcd 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -429,7 +429,6 @@ static sector_t _affs_bmap(struct address_space *mapping, sector_t block)
429const struct address_space_operations affs_aops = { 429const struct address_space_operations affs_aops = {
430 .readpage = affs_readpage, 430 .readpage = affs_readpage,
431 .writepage = affs_writepage, 431 .writepage = affs_writepage,
432 .sync_page = block_sync_page,
433 .write_begin = affs_write_begin, 432 .write_begin = affs_write_begin,
434 .write_end = generic_write_end, 433 .write_end = generic_write_end,
435 .bmap = _affs_bmap 434 .bmap = _affs_bmap
@@ -786,7 +785,6 @@ out:
786const struct address_space_operations affs_aops_ofs = { 785const struct address_space_operations affs_aops_ofs = {
787 .readpage = affs_readpage_ofs, 786 .readpage = affs_readpage_ofs,
788 //.writepage = affs_writepage_ofs, 787 //.writepage = affs_writepage_ofs,
789 //.sync_page = affs_sync_page_ofs,
790 .write_begin = affs_write_begin_ofs, 788 .write_begin = affs_write_begin_ofs,
791 .write_end = affs_write_end_ofs 789 .write_end = affs_write_end_ofs
792}; 790};
@@ -894,9 +892,9 @@ affs_truncate(struct inode *inode)
894 if (AFFS_SB(sb)->s_flags & SF_OFS) { 892 if (AFFS_SB(sb)->s_flags & SF_OFS) {
895 struct buffer_head *bh = affs_bread_ino(inode, last_blk, 0); 893 struct buffer_head *bh = affs_bread_ino(inode, last_blk, 0);
896 u32 tmp; 894 u32 tmp;
897 if (IS_ERR(ext_bh)) { 895 if (IS_ERR(bh)) {
898 affs_warning(sb, "truncate", "unexpected read error for last block %u (%d)", 896 affs_warning(sb, "truncate", "unexpected read error for last block %u (%d)",
899 ext, PTR_ERR(ext_bh)); 897 ext, PTR_ERR(bh));
900 return; 898 return;
901 } 899 }
902 tmp = be32_to_cpu(AFFS_DATA_HEAD(bh)->next); 900 tmp = be32_to_cpu(AFFS_DATA_HEAD(bh)->next);
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 3a0fdec175ba..5d828903ac69 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -388,7 +388,7 @@ affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s3
388 affs_adjust_checksum(inode_bh, block - be32_to_cpu(chain)); 388 affs_adjust_checksum(inode_bh, block - be32_to_cpu(chain));
389 mark_buffer_dirty_inode(inode_bh, inode); 389 mark_buffer_dirty_inode(inode_bh, inode);
390 inode->i_nlink = 2; 390 inode->i_nlink = 2;
391 atomic_inc(&inode->i_count); 391 ihold(inode);
392 } 392 }
393 affs_fix_checksum(sb, bh); 393 affs_fix_checksum(sb, bh);
394 mark_buffer_dirty_inode(bh, inode); 394 mark_buffer_dirty_inode(bh, inode);
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 914d1c0bc07a..e3e9efc1fdd8 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -13,18 +13,26 @@
13typedef int (*toupper_t)(int); 13typedef int (*toupper_t)(int);
14 14
15static int affs_toupper(int ch); 15static int affs_toupper(int ch);
16static int affs_hash_dentry(struct dentry *, struct qstr *); 16static int affs_hash_dentry(const struct dentry *,
17static int affs_compare_dentry(struct dentry *, struct qstr *, struct qstr *); 17 const struct inode *, struct qstr *);
18static int affs_compare_dentry(const struct dentry *parent,
19 const struct inode *pinode,
20 const struct dentry *dentry, const struct inode *inode,
21 unsigned int len, const char *str, const struct qstr *name);
18static int affs_intl_toupper(int ch); 22static int affs_intl_toupper(int ch);
19static int affs_intl_hash_dentry(struct dentry *, struct qstr *); 23static int affs_intl_hash_dentry(const struct dentry *,
20static int affs_intl_compare_dentry(struct dentry *, struct qstr *, struct qstr *); 24 const struct inode *, struct qstr *);
25static int affs_intl_compare_dentry(const struct dentry *parent,
26 const struct inode *pinode,
27 const struct dentry *dentry, const struct inode *inode,
28 unsigned int len, const char *str, const struct qstr *name);
21 29
22const struct dentry_operations affs_dentry_operations = { 30const struct dentry_operations affs_dentry_operations = {
23 .d_hash = affs_hash_dentry, 31 .d_hash = affs_hash_dentry,
24 .d_compare = affs_compare_dentry, 32 .d_compare = affs_compare_dentry,
25}; 33};
26 34
27static const struct dentry_operations affs_intl_dentry_operations = { 35const struct dentry_operations affs_intl_dentry_operations = {
28 .d_hash = affs_intl_hash_dentry, 36 .d_hash = affs_intl_hash_dentry,
29 .d_compare = affs_intl_compare_dentry, 37 .d_compare = affs_intl_compare_dentry,
30}; 38};
@@ -58,13 +66,13 @@ affs_get_toupper(struct super_block *sb)
58 * Note: the dentry argument is the parent dentry. 66 * Note: the dentry argument is the parent dentry.
59 */ 67 */
60static inline int 68static inline int
61__affs_hash_dentry(struct dentry *dentry, struct qstr *qstr, toupper_t toupper) 69__affs_hash_dentry(struct qstr *qstr, toupper_t toupper)
62{ 70{
63 const u8 *name = qstr->name; 71 const u8 *name = qstr->name;
64 unsigned long hash; 72 unsigned long hash;
65 int i; 73 int i;
66 74
67 i = affs_check_name(qstr->name,qstr->len); 75 i = affs_check_name(qstr->name, qstr->len);
68 if (i) 76 if (i)
69 return i; 77 return i;
70 78
@@ -78,39 +86,41 @@ __affs_hash_dentry(struct dentry *dentry, struct qstr *qstr, toupper_t toupper)
78} 86}
79 87
80static int 88static int
81affs_hash_dentry(struct dentry *dentry, struct qstr *qstr) 89affs_hash_dentry(const struct dentry *dentry, const struct inode *inode,
90 struct qstr *qstr)
82{ 91{
83 return __affs_hash_dentry(dentry, qstr, affs_toupper); 92 return __affs_hash_dentry(qstr, affs_toupper);
84} 93}
85static int 94static int
86affs_intl_hash_dentry(struct dentry *dentry, struct qstr *qstr) 95affs_intl_hash_dentry(const struct dentry *dentry, const struct inode *inode,
96 struct qstr *qstr)
87{ 97{
88 return __affs_hash_dentry(dentry, qstr, affs_intl_toupper); 98 return __affs_hash_dentry(qstr, affs_intl_toupper);
89} 99}
90 100
91static inline int 101static inline int __affs_compare_dentry(unsigned int len,
92__affs_compare_dentry(struct dentry *dentry, struct qstr *a, struct qstr *b, toupper_t toupper) 102 const char *str, const struct qstr *name, toupper_t toupper)
93{ 103{
94 const u8 *aname = a->name; 104 const u8 *aname = str;
95 const u8 *bname = b->name; 105 const u8 *bname = name->name;
96 int len;
97 106
98 /* 'a' is the qstr of an already existing dentry, so the name 107 /*
99 * must be valid. 'b' must be validated first. 108 * 'str' is the name of an already existing dentry, so the name
109 * must be valid. 'name' must be validated first.
100 */ 110 */
101 111
102 if (affs_check_name(b->name,b->len)) 112 if (affs_check_name(name->name, name->len))
103 return 1; 113 return 1;
104 114
105 /* If the names are longer than the allowed 30 chars, 115 /*
116 * If the names are longer than the allowed 30 chars,
106 * the excess is ignored, so their length may differ. 117 * the excess is ignored, so their length may differ.
107 */ 118 */
108 len = a->len;
109 if (len >= 30) { 119 if (len >= 30) {
110 if (b->len < 30) 120 if (name->len < 30)
111 return 1; 121 return 1;
112 len = 30; 122 len = 30;
113 } else if (len != b->len) 123 } else if (len != name->len)
114 return 1; 124 return 1;
115 125
116 for (; len > 0; len--) 126 for (; len > 0; len--)
@@ -121,14 +131,18 @@ __affs_compare_dentry(struct dentry *dentry, struct qstr *a, struct qstr *b, tou
121} 131}
122 132
123static int 133static int
124affs_compare_dentry(struct dentry *dentry, struct qstr *a, struct qstr *b) 134affs_compare_dentry(const struct dentry *parent, const struct inode *pinode,
135 const struct dentry *dentry, const struct inode *inode,
136 unsigned int len, const char *str, const struct qstr *name)
125{ 137{
126 return __affs_compare_dentry(dentry, a, b, affs_toupper); 138 return __affs_compare_dentry(len, str, name, affs_toupper);
127} 139}
128static int 140static int
129affs_intl_compare_dentry(struct dentry *dentry, struct qstr *a, struct qstr *b) 141affs_intl_compare_dentry(const struct dentry *parent,const struct inode *pinode,
142 const struct dentry *dentry, const struct inode *inode,
143 unsigned int len, const char *str, const struct qstr *name)
130{ 144{
131 return __affs_compare_dentry(dentry, a, b, affs_intl_toupper); 145 return __affs_compare_dentry(len, str, name, affs_intl_toupper);
132} 146}
133 147
134/* 148/*
@@ -226,7 +240,6 @@ affs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *nd)
226 if (IS_ERR(inode)) 240 if (IS_ERR(inode))
227 return ERR_CAST(inode); 241 return ERR_CAST(inode);
228 } 242 }
229 dentry->d_op = AFFS_SB(sb)->s_flags & SF_INTL ? &affs_intl_dentry_operations : &affs_dentry_operations;
230 d_add(dentry, inode); 243 d_add(dentry, inode);
231 return NULL; 244 return NULL;
232} 245}
diff --git a/fs/affs/super.c b/fs/affs/super.c
index 33c4e7eef470..b31507d0f9b9 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -16,7 +16,6 @@
16#include <linux/parser.h> 16#include <linux/parser.h>
17#include <linux/magic.h> 17#include <linux/magic.h>
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/smp_lock.h>
20#include <linux/slab.h> 19#include <linux/slab.h>
21#include "affs.h" 20#include "affs.h"
22 21
@@ -46,8 +45,6 @@ affs_put_super(struct super_block *sb)
46 struct affs_sb_info *sbi = AFFS_SB(sb); 45 struct affs_sb_info *sbi = AFFS_SB(sb);
47 pr_debug("AFFS: put_super()\n"); 46 pr_debug("AFFS: put_super()\n");
48 47
49 lock_kernel();
50
51 if (!(sb->s_flags & MS_RDONLY) && sb->s_dirt) 48 if (!(sb->s_flags & MS_RDONLY) && sb->s_dirt)
52 affs_commit_super(sb, 1, 1); 49 affs_commit_super(sb, 1, 1);
53 50
@@ -56,8 +53,6 @@ affs_put_super(struct super_block *sb)
56 affs_brelse(sbi->s_root_bh); 53 affs_brelse(sbi->s_root_bh);
57 kfree(sbi); 54 kfree(sbi);
58 sb->s_fs_info = NULL; 55 sb->s_fs_info = NULL;
59
60 unlock_kernel();
61} 56}
62 57
63static void 58static void
@@ -100,17 +95,24 @@ static struct inode *affs_alloc_inode(struct super_block *sb)
100 return &i->vfs_inode; 95 return &i->vfs_inode;
101} 96}
102 97
103static void affs_destroy_inode(struct inode *inode) 98static void affs_i_callback(struct rcu_head *head)
104{ 99{
100 struct inode *inode = container_of(head, struct inode, i_rcu);
101 INIT_LIST_HEAD(&inode->i_dentry);
105 kmem_cache_free(affs_inode_cachep, AFFS_I(inode)); 102 kmem_cache_free(affs_inode_cachep, AFFS_I(inode));
106} 103}
107 104
105static void affs_destroy_inode(struct inode *inode)
106{
107 call_rcu(&inode->i_rcu, affs_i_callback);
108}
109
108static void init_once(void *foo) 110static void init_once(void *foo)
109{ 111{
110 struct affs_inode_info *ei = (struct affs_inode_info *) foo; 112 struct affs_inode_info *ei = (struct affs_inode_info *) foo;
111 113
112 init_MUTEX(&ei->i_link_lock); 114 sema_init(&ei->i_link_lock, 1);
113 init_MUTEX(&ei->i_ext_lock); 115 sema_init(&ei->i_ext_lock, 1);
114 inode_init_once(&ei->vfs_inode); 116 inode_init_once(&ei->vfs_inode);
115} 117}
116 118
@@ -302,6 +304,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
302 sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL); 304 sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL);
303 if (!sbi) 305 if (!sbi)
304 return -ENOMEM; 306 return -ENOMEM;
307
305 sb->s_fs_info = sbi; 308 sb->s_fs_info = sbi;
306 mutex_init(&sbi->s_bmlock); 309 mutex_init(&sbi->s_bmlock);
307 spin_lock_init(&sbi->symlink_lock); 310 spin_lock_init(&sbi->symlink_lock);
@@ -474,12 +477,16 @@ got_root:
474 goto out_error_noinode; 477 goto out_error_noinode;
475 } 478 }
476 479
480 if (AFFS_SB(sb)->s_flags & SF_INTL)
481 sb->s_d_op = &affs_intl_dentry_operations;
482 else
483 sb->s_d_op = &affs_dentry_operations;
484
477 sb->s_root = d_alloc_root(root_inode); 485 sb->s_root = d_alloc_root(root_inode);
478 if (!sb->s_root) { 486 if (!sb->s_root) {
479 printk(KERN_ERR "AFFS: Get root inode failed\n"); 487 printk(KERN_ERR "AFFS: Get root inode failed\n");
480 goto out_error; 488 goto out_error;
481 } 489 }
482 sb->s_root->d_op = &affs_dentry_operations;
483 490
484 pr_debug("AFFS: s_flags=%lX\n",sb->s_flags); 491 pr_debug("AFFS: s_flags=%lX\n",sb->s_flags);
485 return 0; 492 return 0;
@@ -527,7 +534,7 @@ affs_remount(struct super_block *sb, int *flags, char *data)
527 kfree(new_opts); 534 kfree(new_opts);
528 return -EINVAL; 535 return -EINVAL;
529 } 536 }
530 lock_kernel(); 537
531 replace_mount_options(sb, new_opts); 538 replace_mount_options(sb, new_opts);
532 539
533 sbi->s_flags = mount_flags; 540 sbi->s_flags = mount_flags;
@@ -543,17 +550,15 @@ affs_remount(struct super_block *sb, int *flags, char *data)
543 memcpy(sbi->s_volume, volume, 32); 550 memcpy(sbi->s_volume, volume, 32);
544 spin_unlock(&sbi->symlink_lock); 551 spin_unlock(&sbi->symlink_lock);
545 552
546 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) { 553 if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY))
547 unlock_kernel();
548 return 0; 554 return 0;
549 } 555
550 if (*flags & MS_RDONLY) { 556 if (*flags & MS_RDONLY) {
551 affs_write_super(sb); 557 affs_write_super(sb);
552 affs_free_bitmap(sb); 558 affs_free_bitmap(sb);
553 } else 559 } else
554 res = affs_init_bitmap(sb, flags); 560 res = affs_init_bitmap(sb, flags);
555 561
556 unlock_kernel();
557 return res; 562 return res;
558} 563}
559 564
@@ -579,17 +584,16 @@ affs_statfs(struct dentry *dentry, struct kstatfs *buf)
579 return 0; 584 return 0;
580} 585}
581 586
582static int affs_get_sb(struct file_system_type *fs_type, 587static struct dentry *affs_mount(struct file_system_type *fs_type,
583 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 588 int flags, const char *dev_name, void *data)
584{ 589{
585 return get_sb_bdev(fs_type, flags, dev_name, data, affs_fill_super, 590 return mount_bdev(fs_type, flags, dev_name, data, affs_fill_super);
586 mnt);
587} 591}
588 592
589static struct file_system_type affs_fs_type = { 593static struct file_system_type affs_fs_type = {
590 .owner = THIS_MODULE, 594 .owner = THIS_MODULE,
591 .name = "affs", 595 .name = "affs",
592 .get_sb = affs_get_sb, 596 .mount = affs_mount,
593 .kill_sb = kill_block_super, 597 .kill_sb = kill_block_super,
594 .fs_flags = FS_REQUIRES_DEV, 598 .fs_flags = FS_REQUIRES_DEV,
595}; 599};