Skip to content

Commit 1a224ad

Browse files
jankaraMark Fasheh
authored andcommitted
ocfs2: Assign feature bits and system inodes to quota feature and quota files
Signed-off-by: Jan Kara <[email protected]> Signed-off-by: Mark Fasheh <[email protected]>
1 parent 90e86a6 commit 1a224ad

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

fs/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,8 @@ config OCFS2_FS
189189
select CONFIGFS_FS
190190
select JBD2
191191
select CRC32
192+
select QUOTA
193+
select QUOTA_TREE
192194
help
193195
OCFS2 is a general purpose extent based shared disk cluster file
194196
system with many similarities to ext3. It supports 64 bit inode

fs/ocfs2/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ void ocfs2_populate_inode(struct inode *inode, struct ocfs2_dinode *fe,
283283
mlog(0, "local alloc inode: i_ino=%lu\n", inode->i_ino);
284284
} else if (fe->i_flags & cpu_to_le32(OCFS2_BITMAP_FL)) {
285285
OCFS2_I(inode)->ip_flags |= OCFS2_INODE_BITMAP;
286+
} else if (fe->i_flags & cpu_to_le32(OCFS2_QUOTA_FL)) {
287+
inode->i_flags |= S_NOQUOTA;
286288
} else if (fe->i_flags & cpu_to_le32(OCFS2_SUPER_BLOCK_FL)) {
287289
mlog(0, "superblock inode: i_ino=%lu\n", inode->i_ino);
288290
/* we can't actually hit this as read_inode can't

fs/ocfs2/ocfs2_fs.h

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
| OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \
9595
| OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \
9696
| OCFS2_FEATURE_INCOMPAT_XATTR)
97-
#define OCFS2_FEATURE_RO_COMPAT_SUPP OCFS2_FEATURE_RO_COMPAT_UNWRITTEN
97+
#define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN)
9898

9999
/*
100100
* Heartbeat-only devices are missing journals and other files. The
@@ -163,6 +163,12 @@
163163
*/
164164
#define OCFS2_FEATURE_RO_COMPAT_UNWRITTEN 0x0001
165165

166+
/*
167+
* Maintain quota information for this filesystem
168+
*/
169+
#define OCFS2_FEATURE_RO_COMPAT_USRQUOTA 0x0002
170+
#define OCFS2_FEATURE_RO_COMPAT_GRPQUOTA 0x0004
171+
166172
/* The byte offset of the first backup block will be 1G.
167173
* The following will be 4G, 16G, 64G, 256G and 1T.
168174
*/
@@ -192,6 +198,7 @@
192198
#define OCFS2_HEARTBEAT_FL (0x00000200) /* Heartbeat area */
193199
#define OCFS2_CHAIN_FL (0x00000400) /* Chain allocator */
194200
#define OCFS2_DEALLOC_FL (0x00000800) /* Truncate log */
201+
#define OCFS2_QUOTA_FL (0x00001000) /* Quota file */
195202

196203
/*
197204
* Flags on ocfs2_dinode.i_dyn_features
@@ -329,13 +336,17 @@ enum {
329336
#define OCFS2_FIRST_ONLINE_SYSTEM_INODE SLOT_MAP_SYSTEM_INODE
330337
HEARTBEAT_SYSTEM_INODE,
331338
GLOBAL_BITMAP_SYSTEM_INODE,
332-
#define OCFS2_LAST_GLOBAL_SYSTEM_INODE GLOBAL_BITMAP_SYSTEM_INODE
339+
USER_QUOTA_SYSTEM_INODE,
340+
GROUP_QUOTA_SYSTEM_INODE,
341+
#define OCFS2_LAST_GLOBAL_SYSTEM_INODE GROUP_QUOTA_SYSTEM_INODE
333342
ORPHAN_DIR_SYSTEM_INODE,
334343
EXTENT_ALLOC_SYSTEM_INODE,
335344
INODE_ALLOC_SYSTEM_INODE,
336345
JOURNAL_SYSTEM_INODE,
337346
LOCAL_ALLOC_SYSTEM_INODE,
338347
TRUNCATE_LOG_SYSTEM_INODE,
348+
LOCAL_USER_QUOTA_SYSTEM_INODE,
349+
LOCAL_GROUP_QUOTA_SYSTEM_INODE,
339350
NUM_SYSTEM_INODES
340351
};
341352

@@ -349,14 +360,18 @@ static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = {
349360
[SLOT_MAP_SYSTEM_INODE] = { "slot_map", 0, S_IFREG | 0644 },
350361
[HEARTBEAT_SYSTEM_INODE] = { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
351362
[GLOBAL_BITMAP_SYSTEM_INODE] = { "global_bitmap", 0, S_IFREG | 0644 },
363+
[USER_QUOTA_SYSTEM_INODE] = { "aquota.user", OCFS2_QUOTA_FL, S_IFREG | 0644 },
364+
[GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group", OCFS2_QUOTA_FL, S_IFREG | 0644 },
352365

353366
/* Slot-specific system inodes (one copy per slot) */
354367
[ORPHAN_DIR_SYSTEM_INODE] = { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
355368
[EXTENT_ALLOC_SYSTEM_INODE] = { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
356369
[INODE_ALLOC_SYSTEM_INODE] = { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
357370
[JOURNAL_SYSTEM_INODE] = { "journal:%04d", OCFS2_JOURNAL_FL, S_IFREG | 0644 },
358371
[LOCAL_ALLOC_SYSTEM_INODE] = { "local_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_LOCAL_ALLOC_FL, S_IFREG | 0644 },
359-
[TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 }
372+
[TRUNCATE_LOG_SYSTEM_INODE] = { "truncate_log:%04d", OCFS2_DEALLOC_FL, S_IFREG | 0644 },
373+
[LOCAL_USER_QUOTA_SYSTEM_INODE] = { "aquota.user:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
374+
[LOCAL_GROUP_QUOTA_SYSTEM_INODE] = { "aquota.group:%04d", OCFS2_QUOTA_FL, S_IFREG | 0644 },
360375
};
361376

362377
/* Parameter passed from mount.ocfs2 to module */

fs/ocfs2/super.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,19 @@ static int ocfs2_sync_fs(struct super_block *sb, int wait)
225225
return 0;
226226
}
227227

228+
static int ocfs2_need_system_inode(struct ocfs2_super *osb, int ino)
229+
{
230+
if (!OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, OCFS2_FEATURE_RO_COMPAT_USRQUOTA)
231+
&& (ino == USER_QUOTA_SYSTEM_INODE
232+
|| ino == LOCAL_USER_QUOTA_SYSTEM_INODE))
233+
return 0;
234+
if (!OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)
235+
&& (ino == GROUP_QUOTA_SYSTEM_INODE
236+
|| ino == LOCAL_GROUP_QUOTA_SYSTEM_INODE))
237+
return 0;
238+
return 1;
239+
}
240+
228241
static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb)
229242
{
230243
struct inode *new = NULL;
@@ -251,6 +264,8 @@ static int ocfs2_init_global_system_inodes(struct ocfs2_super *osb)
251264

252265
for (i = OCFS2_FIRST_ONLINE_SYSTEM_INODE;
253266
i <= OCFS2_LAST_GLOBAL_SYSTEM_INODE; i++) {
267+
if (!ocfs2_need_system_inode(osb, i))
268+
continue;
254269
new = ocfs2_get_system_file_inode(osb, i, osb->slot_num);
255270
if (!new) {
256271
ocfs2_release_system_inodes(osb);
@@ -281,6 +296,8 @@ static int ocfs2_init_local_system_inodes(struct ocfs2_super *osb)
281296
for (i = OCFS2_LAST_GLOBAL_SYSTEM_INODE + 1;
282297
i < NUM_SYSTEM_INODES;
283298
i++) {
299+
if (!ocfs2_need_system_inode(osb, i))
300+
continue;
284301
new = ocfs2_get_system_file_inode(osb, i, osb->slot_num);
285302
if (!new) {
286303
ocfs2_release_system_inodes(osb);

0 commit comments

Comments
 (0)