Skip to content

Commit 88dcb91

Browse files
author
Linus Torvalds
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/shaggy/jfs-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/shaggy/jfs-2.6: JFS: add uid, gid, and umask mount options JFS: Take logsync lock before testing mp->lsn JFS: kzalloc conversion JFS: Add missing file from fa3241d JFS: Use the kthread_ API JFS: Fix regression. fsck complains if symlinks do not have INLINEEA attribute JFS: ext2 inode attributes for jfs JFS: semaphore to mutex conversion. JFS: make buddy table static JFS: Add back directory i_size calculations for legacy partitions
2 parents c7cace6 + c5111f5 commit 88dcb91

24 files changed

Lines changed: 429 additions & 204 deletions

‎fs/jfs/Makefile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ jfs-y := super.o file.o inode.o namei.o jfs_mount.o jfs_umount.o \
88
jfs_xtree.o jfs_imap.o jfs_debug.o jfs_dmap.o \
99
jfs_unicode.o jfs_dtree.o jfs_inode.o \
1010
jfs_extent.o symlink.o jfs_metapage.o \
11-
jfs_logmgr.o jfs_txnmgr.o jfs_uniupr.o resize.o xattr.o
11+
jfs_logmgr.o jfs_txnmgr.o jfs_uniupr.o \
12+
resize.o xattr.o ioctl.o
1213

1314
jfs-$(CONFIG_JFS_POSIX_ACL) += acl.o
1415

‎fs/jfs/acl.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir)
183183
posix_acl_release(acl);
184184
} else
185185
inode->i_mode &= ~current->fs->umask;
186+
187+
JFS_IP(inode)->mode2 = (JFS_IP(inode)->mode2 & 0xffff0000) |
188+
inode->i_mode;
186189

187190
return rc;
188191
}
@@ -207,12 +210,12 @@ static int jfs_acl_chmod(struct inode *inode)
207210
rc = posix_acl_chmod_masq(clone, inode->i_mode);
208211
if (!rc) {
209212
tid_t tid = txBegin(inode->i_sb, 0);
210-
down(&JFS_IP(inode)->commit_sem);
213+
mutex_lock(&JFS_IP(inode)->commit_mutex);
211214
rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, clone);
212215
if (!rc)
213216
rc = txCommit(tid, 1, &inode, 0);
214217
txEnd(tid);
215-
up(&JFS_IP(inode)->commit_sem);
218+
mutex_unlock(&JFS_IP(inode)->commit_mutex);
216219
}
217220

218221
posix_acl_release(clone);

‎fs/jfs/file.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,5 @@ struct file_operations jfs_file_operations = {
113113
.sendfile = generic_file_sendfile,
114114
.fsync = jfs_fsync,
115115
.release = jfs_release,
116+
.ioctl = jfs_ioctl,
116117
};

‎fs/jfs/inode.c‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ void jfs_read_inode(struct inode *inode)
5555
inode->i_op = &jfs_file_inode_operations;
5656
init_special_inode(inode, inode->i_mode, inode->i_rdev);
5757
}
58+
jfs_set_inode_flags(inode);
5859
}
5960

6061
/*
@@ -89,16 +90,16 @@ int jfs_commit_inode(struct inode *inode, int wait)
8990
}
9091

9192
tid = txBegin(inode->i_sb, COMMIT_INODE);
92-
down(&JFS_IP(inode)->commit_sem);
93+
mutex_lock(&JFS_IP(inode)->commit_mutex);
9394

9495
/*
95-
* Retest inode state after taking commit_sem
96+
* Retest inode state after taking commit_mutex
9697
*/
9798
if (inode->i_nlink && test_cflag(COMMIT_Dirty, inode))
9899
rc = txCommit(tid, 1, &inode, wait ? COMMIT_SYNC : 0);
99100

100101
txEnd(tid);
101-
up(&JFS_IP(inode)->commit_sem);
102+
mutex_unlock(&JFS_IP(inode)->commit_mutex);
102103
return rc;
103104
}
104105

@@ -335,18 +336,18 @@ void jfs_truncate_nolock(struct inode *ip, loff_t length)
335336
tid = txBegin(ip->i_sb, 0);
336337

337338
/*
338-
* The commit_sem cannot be taken before txBegin.
339+
* The commit_mutex cannot be taken before txBegin.
339340
* txBegin may block and there is a chance the inode
340341
* could be marked dirty and need to be committed
341342
* before txBegin unblocks
342343
*/
343-
down(&JFS_IP(ip)->commit_sem);
344+
mutex_lock(&JFS_IP(ip)->commit_mutex);
344345

345346
newsize = xtTruncate(tid, ip, length,
346347
COMMIT_TRUNCATE | COMMIT_PWMAP);
347348
if (newsize < 0) {
348349
txEnd(tid);
349-
up(&JFS_IP(ip)->commit_sem);
350+
mutex_unlock(&JFS_IP(ip)->commit_mutex);
350351
break;
351352
}
352353

@@ -355,7 +356,7 @@ void jfs_truncate_nolock(struct inode *ip, loff_t length)
355356

356357
txCommit(tid, 1, &ip, 0);
357358
txEnd(tid);
358-
up(&JFS_IP(ip)->commit_sem);
359+
mutex_unlock(&JFS_IP(ip)->commit_mutex);
359360
} while (newsize > length); /* Truncate isn't always atomic */
360361
}
361362

‎fs/jfs/ioctl.c‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/*
2+
* linux/fs/jfs/ioctl.c
3+
*
4+
* Copyright (C) 2006 Herbert Poetzl
5+
* adapted from Remy Card's ext2/ioctl.c
6+
*/
7+
8+
#include <linux/fs.h>
9+
#include <linux/ext2_fs.h>
10+
#include <linux/ctype.h>
11+
#include <linux/capability.h>
12+
#include <linux/time.h>
13+
#include <asm/current.h>
14+
#include <asm/uaccess.h>
15+
16+
#include "jfs_incore.h"
17+
#include "jfs_dinode.h"
18+
#include "jfs_inode.h"
19+
20+
21+
static struct {
22+
long jfs_flag;
23+
long ext2_flag;
24+
} jfs_map[] = {
25+
{JFS_NOATIME_FL, EXT2_NOATIME_FL},
26+
{JFS_DIRSYNC_FL, EXT2_DIRSYNC_FL},
27+
{JFS_SYNC_FL, EXT2_SYNC_FL},
28+
{JFS_SECRM_FL, EXT2_SECRM_FL},
29+
{JFS_UNRM_FL, EXT2_UNRM_FL},
30+
{JFS_APPEND_FL, EXT2_APPEND_FL},
31+
{JFS_IMMUTABLE_FL, EXT2_IMMUTABLE_FL},
32+
{0, 0},
33+
};
34+
35+
static long jfs_map_ext2(unsigned long flags, int from)
36+
{
37+
int index=0;
38+
long mapped=0;
39+
40+
while (jfs_map[index].jfs_flag) {
41+
if (from) {
42+
if (jfs_map[index].ext2_flag & flags)
43+
mapped |= jfs_map[index].jfs_flag;
44+
} else {
45+
if (jfs_map[index].jfs_flag & flags)
46+
mapped |= jfs_map[index].ext2_flag;
47+
}
48+
index++;
49+
}
50+
return mapped;
51+
}
52+
53+
54+
int jfs_ioctl(struct inode * inode, struct file * filp, unsigned int cmd,
55+
unsigned long arg)
56+
{
57+
struct jfs_inode_info *jfs_inode = JFS_IP(inode);
58+
unsigned int flags;
59+
60+
switch (cmd) {
61+
case JFS_IOC_GETFLAGS:
62+
flags = jfs_inode->mode2 & JFS_FL_USER_VISIBLE;
63+
flags = jfs_map_ext2(flags, 0);
64+
return put_user(flags, (int __user *) arg);
65+
case JFS_IOC_SETFLAGS: {
66+
unsigned int oldflags;
67+
68+
if (IS_RDONLY(inode))
69+
return -EROFS;
70+
71+
if ((current->fsuid != inode->i_uid) && !capable(CAP_FOWNER))
72+
return -EACCES;
73+
74+
if (get_user(flags, (int __user *) arg))
75+
return -EFAULT;
76+
77+
flags = jfs_map_ext2(flags, 1);
78+
if (!S_ISDIR(inode->i_mode))
79+
flags &= ~JFS_DIRSYNC_FL;
80+
81+
oldflags = jfs_inode->mode2;
82+
83+
/*
84+
* The IMMUTABLE and APPEND_ONLY flags can only be changed by
85+
* the relevant capability.
86+
*/
87+
if ((oldflags & JFS_IMMUTABLE_FL) ||
88+
((flags ^ oldflags) &
89+
(JFS_APPEND_FL | JFS_IMMUTABLE_FL))) {
90+
if (!capable(CAP_LINUX_IMMUTABLE))
91+
return -EPERM;
92+
}
93+
94+
flags = flags & JFS_FL_USER_MODIFIABLE;
95+
flags |= oldflags & ~JFS_FL_USER_MODIFIABLE;
96+
jfs_inode->mode2 = flags;
97+
98+
jfs_set_inode_flags(inode);
99+
inode->i_ctime = CURRENT_TIME_SEC;
100+
mark_inode_dirty(inode);
101+
return 0;
102+
}
103+
default:
104+
return -ENOTTY;
105+
}
106+
}
107+

‎fs/jfs/jfs_dinode.h‎

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,36 @@ struct dinode {
139139

140140
/* more extended mode bits: attributes for OS/2 */
141141
#define IREADONLY 0x02000000 /* no write access to file */
142-
#define IARCHIVE 0x40000000 /* file archive bit */
143-
#define ISYSTEM 0x08000000 /* system file */
144142
#define IHIDDEN 0x04000000 /* hidden file */
145-
#define IRASH 0x4E000000 /* mask for changeable attributes */
146-
#define INEWNAME 0x80000000 /* non-8.3 filename format */
143+
#define ISYSTEM 0x08000000 /* system file */
144+
147145
#define IDIRECTORY 0x20000000 /* directory (shadow of real bit) */
146+
#define IARCHIVE 0x40000000 /* file archive bit */
147+
#define INEWNAME 0x80000000 /* non-8.3 filename format */
148+
149+
#define IRASH 0x4E000000 /* mask for changeable attributes */
148150
#define ATTRSHIFT 25 /* bits to shift to move attribute
149151
specification to mode position */
150152

153+
/* extended attributes for Linux */
154+
155+
#define JFS_NOATIME_FL 0x00080000 /* do not update atime */
156+
157+
#define JFS_DIRSYNC_FL 0x00100000 /* dirsync behaviour */
158+
#define JFS_SYNC_FL 0x00200000 /* Synchronous updates */
159+
#define JFS_SECRM_FL 0x00400000 /* Secure deletion */
160+
#define JFS_UNRM_FL 0x00800000 /* allow for undelete */
161+
162+
#define JFS_APPEND_FL 0x01000000 /* writes to file may only append */
163+
#define JFS_IMMUTABLE_FL 0x02000000 /* Immutable file */
164+
165+
#define JFS_FL_USER_VISIBLE 0x03F80000
166+
#define JFS_FL_USER_MODIFIABLE 0x03F80000
167+
#define JFS_FL_INHERIT 0x03C80000
168+
169+
/* These are identical to EXT[23]_IOC_GETFLAGS/SETFLAGS */
170+
#define JFS_IOC_GETFLAGS _IOR('f', 1, long)
171+
#define JFS_IOC_SETFLAGS _IOW('f', 2, long)
172+
173+
151174
#endif /*_H_JFS_DINODE */

‎fs/jfs/jfs_dmap.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
* to the persistent bitmaps in dmaps) is guarded by (busy) buffers.
6565
*/
6666

67-
#define BMAP_LOCK_INIT(bmp) init_MUTEX(&bmp->db_bmaplock)
68-
#define BMAP_LOCK(bmp) down(&bmp->db_bmaplock)
69-
#define BMAP_UNLOCK(bmp) up(&bmp->db_bmaplock)
67+
#define BMAP_LOCK_INIT(bmp) mutex_init(&bmp->db_bmaplock)
68+
#define BMAP_LOCK(bmp) mutex_lock(&bmp->db_bmaplock)
69+
#define BMAP_UNLOCK(bmp) mutex_unlock(&bmp->db_bmaplock)
7070

7171
/*
7272
* forward references
@@ -125,7 +125,7 @@ static int dbGetL2AGSize(s64 nblocks);
125125
* into the table, with the table elements yielding the maximum
126126
* binary buddy of free bits within the character.
127127
*/
128-
static s8 budtab[256] = {
128+
static const s8 budtab[256] = {
129129
3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
130130
2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
131131
2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,

‎fs/jfs/jfs_dmap.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ struct dbmap {
243243
struct bmap {
244244
struct dbmap db_bmap; /* on-disk aggregate map descriptor */
245245
struct inode *db_ipbmap; /* ptr to aggregate map incore inode */
246-
struct semaphore db_bmaplock; /* aggregate map lock */
246+
struct mutex db_bmaplock; /* aggregate map lock */
247247
atomic_t db_active[MAXAG]; /* count of active, open files in AG */
248248
u32 *db_DBmap;
249249
};

‎fs/jfs/jfs_dtree.c‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,6 +1005,9 @@ static int dtSplitUp(tid_t tid,
10051005

10061006
DT_PUTPAGE(smp);
10071007

1008+
if (!DO_INDEX(ip))
1009+
ip->i_size = xlen << sbi->l2bsize;
1010+
10081011
goto freeKeyName;
10091012
}
10101013

@@ -1055,7 +1058,9 @@ static int dtSplitUp(tid_t tid,
10551058
xaddr = addressPXD(pxd) + xlen;
10561059
dbFree(ip, xaddr, (s64) n);
10571060
}
1058-
}
1061+
} else if (!DO_INDEX(ip))
1062+
ip->i_size = lengthPXD(pxd) << sbi->l2bsize;
1063+
10591064

10601065
extendOut:
10611066
DT_PUTPAGE(smp);
@@ -1098,6 +1103,9 @@ static int dtSplitUp(tid_t tid,
10981103
goto splitOut;
10991104
}
11001105

1106+
if (!DO_INDEX(ip))
1107+
ip->i_size += PSIZE;
1108+
11011109
/*
11021110
* propagate up the router entry for the leaf page just split
11031111
*
@@ -2424,6 +2432,9 @@ static int dtDeleteUp(tid_t tid, struct inode *ip,
24242432
break;
24252433
}
24262434

2435+
if (!DO_INDEX(ip))
2436+
ip->i_size -= PSIZE;
2437+
24272438
return 0;
24282439
}
24292440

0 commit comments

Comments
 (0)