Skip to content

Commit e2a0883

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs pile 1 from Al Viro: "This is _not_ all; in particular, Miklos' and Jan's stuff is not there yet." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (64 commits) ext4: initialization of ext4_li_mtx needs to be done earlier debugfs-related mode_t whack-a-mole hfsplus: add an ioctl to bless files hfsplus: change finder_info to u32 hfsplus: initialise userflags qnx4: new helper - try_extent() qnx4: get rid of qnx4_bread/qnx4_getblk take removal of PF_FORKNOEXEC to flush_old_exec() trim includes in inode.c um: uml_dup_mmap() relies on ->mmap_sem being held, but activate_mm() doesn't hold it um: embed ->stub_pages[] into mmu_context gadgetfs: list_for_each_safe() misuse ocfs2: fix leaks on failure exits in module_init ecryptfs: make register_filesystem() the last potential failure exit ntfs: forgets to unregister sysctls on register_filesystem() failure logfs: missing cleanup on register_filesystem() failure jfs: mising cleanup on register_filesystem() failure make configfs_pin_fs() return root dentry on success configfs: configfs_create_dir() has parent dentry in dentry->d_parent configfs: sanitize configfs_create() ...
2 parents 3a990a5 + 07c0c5d commit e2a0883

186 files changed

Lines changed: 5360 additions & 4141 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/filesystems/debugfs.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ file.
136136
void __iomem *base;
137137
};
138138

139-
struct dentry *debugfs_create_regset32(const char *name, mode_t mode,
139+
struct dentry *debugfs_create_regset32(const char *name, umode_t mode,
140140
struct dentry *parent,
141141
struct debugfs_regset32 *regset);
142142

‎Documentation/filesystems/porting‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,9 @@ filemap_write_and_wait_range() so that all dirty pages are synced out properly.
429429
You must also keep in mind that ->fsync() is not called with i_mutex held
430430
anymore, so if you require i_mutex locking you must make sure to take it and
431431
release it yourself.
432+
433+
--
434+
[mandatory]
435+
d_alloc_root() is gone, along with a lot of bugs caused by code
436+
misusing it. Replacement: d_make_root(inode). The difference is,
437+
d_make_root() drops the reference to inode if dentry allocation fails.

‎Documentation/filesystems/qnx6.txt‎

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
The QNX6 Filesystem
2+
===================
3+
4+
The qnx6fs is used by newer QNX operating system versions. (e.g. Neutrino)
5+
It got introduced in QNX 6.4.0 and is used default since 6.4.1.
6+
7+
Option
8+
======
9+
10+
mmi_fs Mount filesystem as used for example by Audi MMI 3G system
11+
12+
Specification
13+
=============
14+
15+
qnx6fs shares many properties with traditional Unix filesystems. It has the
16+
concepts of blocks, inodes and directories.
17+
On QNX it is possible to create little endian and big endian qnx6 filesystems.
18+
This feature makes it possible to create and use a different endianness fs
19+
for the target (QNX is used on quite a range of embedded systems) plattform
20+
running on a different endianess.
21+
The Linux driver handles endianness transparently. (LE and BE)
22+
23+
Blocks
24+
------
25+
26+
The space in the device or file is split up into blocks. These are a fixed
27+
size of 512, 1024, 2048 or 4096, which is decided when the filesystem is
28+
created.
29+
Blockpointers are 32bit, so the maximum space that can be adressed is
30+
2^32 * 4096 bytes or 16TB
31+
32+
The superblocks
33+
---------------
34+
35+
The superblock contains all global information about the filesystem.
36+
Each qnx6fs got two superblocks, each one having a 64bit serial number.
37+
That serial number is used to identify the "active" superblock.
38+
In write mode with reach new snapshot (after each synchronous write), the
39+
serial of the new master superblock is increased (old superblock serial + 1)
40+
41+
So basically the snapshot functionality is realized by an atomic final
42+
update of the serial number. Before updating that serial, all modifications
43+
are done by copying all modified blocks during that specific write request
44+
(or period) and building up a new (stable) filesystem structure under the
45+
inactive superblock.
46+
47+
Each superblock holds a set of root inodes for the different filesystem
48+
parts. (Inode, Bitmap and Longfilenames)
49+
Each of these root nodes holds information like total size of the stored
50+
data and the adressing levels in that specific tree.
51+
If the level value is 0, up to 16 direct blocks can be adressed by each
52+
node.
53+
Level 1 adds an additional indirect adressing level where each indirect
54+
adressing block holds up to blocksize / 4 bytes pointers to data blocks.
55+
Level 2 adds an additional indirect adressig block level (so, already up
56+
to 16 * 256 * 256 = 1048576 blocks that can be adressed by such a tree)a
57+
58+
Unused block pointers are always set to ~0 - regardless of root node,
59+
indirect adressing blocks or inodes.
60+
Data leaves are always on the lowest level. So no data is stored on upper
61+
tree levels.
62+
63+
The first Superblock is located at 0x2000. (0x2000 is the bootblock size)
64+
The Audi MMI 3G first superblock directly starts at byte 0.
65+
Second superblock position can either be calculated from the superblock
66+
information (total number of filesystem blocks) or by taking the highest
67+
device address, zeroing the last 3 bytes and then substracting 0x1000 from
68+
that address.
69+
70+
0x1000 is the size reserved for each superblock - regardless of the
71+
blocksize of the filesystem.
72+
73+
Inodes
74+
------
75+
76+
Each object in the filesystem is represented by an inode. (index node)
77+
The inode structure contains pointers to the filesystem blocks which contain
78+
the data held in the object and all of the metadata about an object except
79+
its longname. (filenames longer than 27 characters)
80+
The metadata about an object includes the permissions, owner, group, flags,
81+
size, number of blocks used, access time, change time and modification time.
82+
83+
Object mode field is POSIX format. (which makes things easier)
84+
85+
There are also pointers to the first 16 blocks, if the object data can be
86+
adressed with 16 direct blocks.
87+
For more than 16 blocks an indirect adressing in form of another tree is
88+
used. (scheme is the same as the one used for the superblock root nodes)
89+
90+
The filesize is stored 64bit. Inode counting starts with 1. (whilst long
91+
filename inodes start with 0)
92+
93+
Directories
94+
-----------
95+
96+
A directory is a filesystem object and has an inode just like a file.
97+
It is a specially formatted file containing records which associate each
98+
name with an inode number.
99+
'.' inode number points to the directory inode
100+
'..' inode number points to the parent directory inode
101+
Eeach filename record additionally got a filename length field.
102+
103+
One special case are long filenames or subdirectory names.
104+
These got set a filename length field of 0xff in the corresponding directory
105+
record plus the longfile inode number also stored in that record.
106+
With that longfilename inode number, the longfilename tree can be walked
107+
starting with the superblock longfilename root node pointers.
108+
109+
Special files
110+
-------------
111+
112+
Symbolic links are also filesystem objects with inodes. They got a specific
113+
bit in the inode mode field identifying them as symbolic link.
114+
The directory entry file inode pointer points to the target file inode.
115+
116+
Hard links got an inode, a directory entry, but a specific mode bit set,
117+
no block pointers and the directory file record pointing to the target file
118+
inode.
119+
120+
Character and block special devices do not exist in QNX as those files
121+
are handled by the QNX kernel/drivers and created in /dev independant of the
122+
underlaying filesystem.
123+
124+
Long filenames
125+
--------------
126+
127+
Long filenames are stored in a seperate adressing tree. The staring point
128+
is the longfilename root node in the active superblock.
129+
Each data block (tree leaves) holds one long filename. That filename is
130+
limited to 510 bytes. The first two starting bytes are used as length field
131+
for the actual filename.
132+
If that structure shall fit for all allowed blocksizes, it is clear why there
133+
is a limit of 510 bytes for the actual filename stored.
134+
135+
Bitmap
136+
------
137+
138+
The qnx6fs filesystem allocation bitmap is stored in a tree under bitmap
139+
root node in the superblock and each bit in the bitmap represents one
140+
filesystem block.
141+
The first block is block 0, which starts 0x1000 after superblock start.
142+
So for a normal qnx6fs 0x3000 (bootblock + superblock) is the physical
143+
address at which block 0 is located.
144+
145+
Bits at the end of the last bitmap block are set to 1, if the device is
146+
smaller than addressing space in the bitmap.
147+
148+
Bitmap system area
149+
------------------
150+
151+
The bitmap itself is devided into three parts.
152+
First the system area, that is split into two halfs.
153+
Then userspace.
154+
155+
The requirement for a static, fixed preallocated system area comes from how
156+
qnx6fs deals with writes.
157+
Each superblock got it's own half of the system area. So superblock #1
158+
always uses blocks from the lower half whilst superblock #2 just writes to
159+
blocks represented by the upper half bitmap system area bits.
160+
161+
Bitmap blocks, Inode blocks and indirect addressing blocks for those two
162+
tree structures are treated as system blocks.
163+
164+
The rational behind that is that a write request can work on a new snapshot
165+
(system area of the inactive - resp. lower serial numbered superblock) while
166+
at the same time there is still a complete stable filesystem structer in the
167+
other half of the system area.
168+
169+
When finished with writing (a sync write is completed, the maximum sync leap
170+
time or a filesystem sync is requested), serial of the previously inactive
171+
superblock atomically is increased and the fs switches over to that - then
172+
stable declared - superblock.
173+
174+
For all data outside the system area, blocks are just copied while writing.

‎Documentation/ioctl/ioctl-number.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ Code Seq#(hex) Include File Comments
218218
'h' 00-7F conflict! Charon filesystem
219219
<mailto:zapman@interlan.net>
220220
'h' 00-1F linux/hpet.h conflict!
221+
'h' 80-8F fs/hfsplus/ioctl.c
221222
'i' 00-3F linux/i2o-dev.h conflict!
222223
'i' 0B-1F linux/ipmi.h conflict!
223224
'i' 80-8F linux/i8k.h

‎arch/alpha/kernel/binfmt_loader.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ static struct linux_binfmt loader_format = {
4646

4747
static int __init init_loader_binfmt(void)
4848
{
49-
return insert_binfmt(&loader_format);
49+
insert_binfmt(&loader_format);
50+
return 0;
5051
}
5152
arch_initcall(init_loader_binfmt);

‎arch/powerpc/platforms/cell/spufs/inode.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -757,9 +757,9 @@ spufs_create_root(struct super_block *sb, void *data)
757757
goto out_iput;
758758

759759
ret = -ENOMEM;
760-
sb->s_root = d_alloc_root(inode);
760+
sb->s_root = d_make_root(inode);
761761
if (!sb->s_root)
762-
goto out_iput;
762+
goto out;
763763

764764
return 0;
765765
out_iput:
@@ -828,19 +828,19 @@ static int __init spufs_init(void)
828828
ret = spu_sched_init();
829829
if (ret)
830830
goto out_cache;
831-
ret = register_filesystem(&spufs_type);
831+
ret = register_spu_syscalls(&spufs_calls);
832832
if (ret)
833833
goto out_sched;
834-
ret = register_spu_syscalls(&spufs_calls);
834+
ret = register_filesystem(&spufs_type);
835835
if (ret)
836-
goto out_fs;
836+
goto out_syscalls;
837837

838838
spufs_init_isolated_loader();
839839

840840
return 0;
841841

842-
out_fs:
843-
unregister_filesystem(&spufs_type);
842+
out_syscalls:
843+
unregister_spu_syscalls(&spufs_calls);
844844
out_sched:
845845
spu_sched_exit();
846846
out_cache:

‎arch/s390/hypfs/inode.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,9 @@ static int hypfs_fill_super(struct super_block *sb, void *data, int silent)
293293
return -ENOMEM;
294294
root_inode->i_op = &simple_dir_inode_operations;
295295
root_inode->i_fop = &simple_dir_operations;
296-
sb->s_root = root_dentry = d_alloc_root(root_inode);
297-
if (!root_dentry) {
298-
iput(root_inode);
296+
sb->s_root = root_dentry = d_make_root(root_inode);
297+
if (!root_dentry)
299298
return -ENOMEM;
300-
}
301299
if (MACHINE_IS_VM)
302300
rc = hypfs_vm_create_files(sb, root_dentry);
303301
else

‎arch/um/include/asm/mmu.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
typedef struct mm_context {
1313
struct mm_id id;
1414
struct uml_arch_mm_context arch;
15-
struct page **stub_pages;
15+
struct page *stub_pages[2];
1616
} mm_context_t;
1717

1818
extern void __switch_mm(struct mm_id * mm_idp);

‎arch/um/include/asm/mmu_context.h‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <linux/sched.h>
1010
#include <asm/mmu.h>
1111

12-
extern void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm);
12+
extern void uml_setup_stubs(struct mm_struct *mm);
1313
extern void arch_exit_mmap(struct mm_struct *mm);
1414

1515
#define deactivate_mm(tsk,mm) do { } while (0)
@@ -23,7 +23,9 @@ static inline void activate_mm(struct mm_struct *old, struct mm_struct *new)
2323
* when the new ->mm is used for the first time.
2424
*/
2525
__switch_mm(&new->context.id);
26-
arch_dup_mmap(old, new);
26+
down_write(&new->mmap_sem);
27+
uml_setup_stubs(new);
28+
up_write(&new->mmap_sem);
2729
}
2830

2931
static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
@@ -39,6 +41,11 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
3941
}
4042
}
4143

44+
static inline void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
45+
{
46+
uml_setup_stubs(mm);
47+
}
48+
4249
static inline void enter_lazy_tlb(struct mm_struct *mm,
4350
struct task_struct *tsk)
4451
{

‎arch/um/kernel/skas/mmu.c‎

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
9292
goto out_free;
9393
}
9494

95-
to_mm->stub_pages = NULL;
96-
9795
return 0;
9896

9997
out_free:
@@ -103,7 +101,7 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
103101
return ret;
104102
}
105103

106-
void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
104+
void uml_setup_stubs(struct mm_struct *mm)
107105
{
108106
struct page **pages;
109107
int err, ret;
@@ -120,29 +118,20 @@ void arch_dup_mmap(struct mm_struct *oldmm, struct mm_struct *mm)
120118
if (ret)
121119
goto out;
122120

123-
pages = kmalloc(2 * sizeof(struct page *), GFP_KERNEL);
124-
if (pages == NULL) {
125-
printk(KERN_ERR "arch_dup_mmap failed to allocate 2 page "
126-
"pointers\n");
127-
goto out;
128-
}
129-
130-
pages[0] = virt_to_page(&__syscall_stub_start);
131-
pages[1] = virt_to_page(mm->context.id.stack);
132-
mm->context.stub_pages = pages;
121+
mm->context.stub_pages[0] = virt_to_page(&__syscall_stub_start);
122+
mm->context.stub_pages[1] = virt_to_page(mm->context.id.stack);
133123

134124
/* dup_mmap already holds mmap_sem */
135125
err = install_special_mapping(mm, STUB_START, STUB_END - STUB_START,
136126
VM_READ | VM_MAYREAD | VM_EXEC |
137-
VM_MAYEXEC | VM_DONTCOPY, pages);
127+
VM_MAYEXEC | VM_DONTCOPY,
128+
mm->context.stub_pages);
138129
if (err) {
139130
printk(KERN_ERR "install_special_mapping returned %d\n", err);
140-
goto out_free;
131+
goto out;
141132
}
142133
return;
143134

144-
out_free:
145-
kfree(pages);
146135
out:
147136
force_sigsegv(SIGSEGV, current);
148137
}
@@ -151,8 +140,6 @@ void arch_exit_mmap(struct mm_struct *mm)
151140
{
152141
pte_t *pte;
153142

154-
if (mm->context.stub_pages != NULL)
155-
kfree(mm->context.stub_pages);
156143
pte = virt_to_pte(mm, STUB_CODE);
157144
if (pte != NULL)
158145
pte_clear(mm, STUB_CODE, pte);

0 commit comments

Comments
 (0)