Skip to content

Commit d7dbf4f

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ryusuke/nilfs2
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ryusuke/nilfs2: (23 commits) nilfs2: disallow remount of snapshot from/to a regular mount nilfs2: use huge_encode_dev/huge_decode_dev nilfs2: update comment on deactivate_super at nilfs_get_sb nilfs2: replace MS_VERBOSE with MS_SILENT nilfs2: add missing initialization of s_mode nilfs2: fix misuse of open_bdev_exclusive/close_bdev_exclusive nilfs2: enlarge s_volume_name member in nilfs_super_block nilfs2: use checkpoint number instead of timestamp to select super block nilfs2: add missing endian conversion on super block magic number nilfs2: make nilfs_sc_*_ops static nilfs2: add kernel doc comments to persistent object allocator functions nilfs2: change sc_timer from a pointer to an embedded one in struct nilfs_sc_info nilfs2: remove nilfs_segctor_init() in segment.c nilfs2: insert checkpoint number in segment summary header nilfs2: add a print message after loading nilfs2 nilfs2: cleanup multi kmem_cache_{create,destroy} code nilfs2: move out checksum routines to segment buffer code nilfs2: move pointer to super root block into logs nilfs2: change default of 'errors' mount option to 'remount-ro' mode nilfs2: Combine nilfs_btree_release_path() and nilfs_btree_free_path() ...
2 parents 677abe4 + d240e06 commit d7dbf4f

File tree

14 files changed

+423
-350
lines changed

14 files changed

+423
-350
lines changed

Documentation/filesystems/nilfs2.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ NILFS2 supports the following mount options:
5050
(*) == default
5151

5252
nobarrier Disables barriers.
53-
errors=continue(*) Keep going on a filesystem error.
54-
errors=remount-ro Remount the filesystem read-only on an error.
53+
errors=continue Keep going on a filesystem error.
54+
errors=remount-ro(*) Remount the filesystem read-only on an error.
5555
errors=panic Panic and halt the machine if an error occurs.
5656
cp=n Specify the checkpoint-number of the snapshot to be
5757
mounted. Checkpoints and snapshots are listed by lscp

fs/nilfs2/alloc.c

Lines changed: 153 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,33 @@
3131
#include "alloc.h"
3232

3333

34+
/**
35+
* nilfs_palloc_groups_per_desc_block - get the number of groups that a group
36+
* descriptor block can maintain
37+
* @inode: inode of metadata file using this allocator
38+
*/
3439
static inline unsigned long
3540
nilfs_palloc_groups_per_desc_block(const struct inode *inode)
3641
{
3742
return (1UL << inode->i_blkbits) /
3843
sizeof(struct nilfs_palloc_group_desc);
3944
}
4045

46+
/**
47+
* nilfs_palloc_groups_count - get maximum number of groups
48+
* @inode: inode of metadata file using this allocator
49+
*/
4150
static inline unsigned long
4251
nilfs_palloc_groups_count(const struct inode *inode)
4352
{
4453
return 1UL << (BITS_PER_LONG - (inode->i_blkbits + 3 /* log2(8) */));
4554
}
4655

56+
/**
57+
* nilfs_palloc_init_blockgroup - initialize private variables for allocator
58+
* @inode: inode of metadata file using this allocator
59+
* @entry_size: size of the persistent object
60+
*/
4761
int nilfs_palloc_init_blockgroup(struct inode *inode, unsigned entry_size)
4862
{
4963
struct nilfs_mdt_info *mi = NILFS_MDT(inode);
@@ -69,6 +83,12 @@ int nilfs_palloc_init_blockgroup(struct inode *inode, unsigned entry_size)
6983
return 0;
7084
}
7185

86+
/**
87+
* nilfs_palloc_group - get group number and offset from an entry number
88+
* @inode: inode of metadata file using this allocator
89+
* @nr: serial number of the entry (e.g. inode number)
90+
* @offset: pointer to store offset number in the group
91+
*/
7292
static unsigned long nilfs_palloc_group(const struct inode *inode, __u64 nr,
7393
unsigned long *offset)
7494
{
@@ -78,6 +98,14 @@ static unsigned long nilfs_palloc_group(const struct inode *inode, __u64 nr,
7898
return group;
7999
}
80100

101+
/**
102+
* nilfs_palloc_desc_blkoff - get block offset of a group descriptor block
103+
* @inode: inode of metadata file using this allocator
104+
* @group: group number
105+
*
106+
* nilfs_palloc_desc_blkoff() returns block offset of the descriptor
107+
* block which contains a descriptor of the specified group.
108+
*/
81109
static unsigned long
82110
nilfs_palloc_desc_blkoff(const struct inode *inode, unsigned long group)
83111
{
@@ -86,6 +114,14 @@ nilfs_palloc_desc_blkoff(const struct inode *inode, unsigned long group)
86114
return desc_block * NILFS_MDT(inode)->mi_blocks_per_desc_block;
87115
}
88116

117+
/**
118+
* nilfs_palloc_bitmap_blkoff - get block offset of a bitmap block
119+
* @inode: inode of metadata file using this allocator
120+
* @group: group number
121+
*
122+
* nilfs_palloc_bitmap_blkoff() returns block offset of the bitmap
123+
* block used to allocate/deallocate entries in the specified group.
124+
*/
89125
static unsigned long
90126
nilfs_palloc_bitmap_blkoff(const struct inode *inode, unsigned long group)
91127
{
@@ -95,6 +131,12 @@ nilfs_palloc_bitmap_blkoff(const struct inode *inode, unsigned long group)
95131
desc_offset * NILFS_MDT(inode)->mi_blocks_per_group;
96132
}
97133

134+
/**
135+
* nilfs_palloc_group_desc_nfrees - get the number of free entries in a group
136+
* @inode: inode of metadata file using this allocator
137+
* @group: group number
138+
* @desc: pointer to descriptor structure for the group
139+
*/
98140
static unsigned long
99141
nilfs_palloc_group_desc_nfrees(struct inode *inode, unsigned long group,
100142
const struct nilfs_palloc_group_desc *desc)
@@ -107,6 +149,13 @@ nilfs_palloc_group_desc_nfrees(struct inode *inode, unsigned long group,
107149
return nfree;
108150
}
109151

152+
/**
153+
* nilfs_palloc_group_desc_add_entries - adjust count of free entries
154+
* @inode: inode of metadata file using this allocator
155+
* @group: group number
156+
* @desc: pointer to descriptor structure for the group
157+
* @n: delta to be added
158+
*/
110159
static void
111160
nilfs_palloc_group_desc_add_entries(struct inode *inode,
112161
unsigned long group,
@@ -118,6 +167,11 @@ nilfs_palloc_group_desc_add_entries(struct inode *inode,
118167
spin_unlock(nilfs_mdt_bgl_lock(inode, group));
119168
}
120169

170+
/**
171+
* nilfs_palloc_entry_blkoff - get block offset of an entry block
172+
* @inode: inode of metadata file using this allocator
173+
* @nr: serial number of the entry (e.g. inode number)
174+
*/
121175
static unsigned long
122176
nilfs_palloc_entry_blkoff(const struct inode *inode, __u64 nr)
123177
{
@@ -129,6 +183,12 @@ nilfs_palloc_entry_blkoff(const struct inode *inode, __u64 nr)
129183
group_offset / NILFS_MDT(inode)->mi_entries_per_block;
130184
}
131185

186+
/**
187+
* nilfs_palloc_desc_block_init - initialize buffer of a group descriptor block
188+
* @inode: inode of metadata file
189+
* @bh: buffer head of the buffer to be initialized
190+
* @kaddr: kernel address mapped for the page including the buffer
191+
*/
132192
static void nilfs_palloc_desc_block_init(struct inode *inode,
133193
struct buffer_head *bh, void *kaddr)
134194
{
@@ -179,6 +239,13 @@ static int nilfs_palloc_get_block(struct inode *inode, unsigned long blkoff,
179239
return ret;
180240
}
181241

242+
/**
243+
* nilfs_palloc_get_desc_block - get buffer head of a group descriptor block
244+
* @inode: inode of metadata file using this allocator
245+
* @group: group number
246+
* @create: create flag
247+
* @bhp: pointer to store the resultant buffer head
248+
*/
182249
static int nilfs_palloc_get_desc_block(struct inode *inode,
183250
unsigned long group,
184251
int create, struct buffer_head **bhp)
@@ -191,6 +258,13 @@ static int nilfs_palloc_get_desc_block(struct inode *inode,
191258
bhp, &cache->prev_desc, &cache->lock);
192259
}
193260

261+
/**
262+
* nilfs_palloc_get_bitmap_block - get buffer head of a bitmap block
263+
* @inode: inode of metadata file using this allocator
264+
* @group: group number
265+
* @create: create flag
266+
* @bhp: pointer to store the resultant buffer head
267+
*/
194268
static int nilfs_palloc_get_bitmap_block(struct inode *inode,
195269
unsigned long group,
196270
int create, struct buffer_head **bhp)
@@ -203,6 +277,13 @@ static int nilfs_palloc_get_bitmap_block(struct inode *inode,
203277
&cache->prev_bitmap, &cache->lock);
204278
}
205279

280+
/**
281+
* nilfs_palloc_get_entry_block - get buffer head of an entry block
282+
* @inode: inode of metadata file using this allocator
283+
* @nr: serial number of the entry (e.g. inode number)
284+
* @create: create flag
285+
* @bhp: pointer to store the resultant buffer head
286+
*/
206287
int nilfs_palloc_get_entry_block(struct inode *inode, __u64 nr,
207288
int create, struct buffer_head **bhp)
208289
{
@@ -214,6 +295,13 @@ int nilfs_palloc_get_entry_block(struct inode *inode, __u64 nr,
214295
&cache->prev_entry, &cache->lock);
215296
}
216297

298+
/**
299+
* nilfs_palloc_block_get_group_desc - get kernel address of a group descriptor
300+
* @inode: inode of metadata file using this allocator
301+
* @group: group number
302+
* @bh: buffer head of the buffer storing the group descriptor block
303+
* @kaddr: kernel address mapped for the page including the buffer
304+
*/
217305
static struct nilfs_palloc_group_desc *
218306
nilfs_palloc_block_get_group_desc(const struct inode *inode,
219307
unsigned long group,
@@ -223,6 +311,13 @@ nilfs_palloc_block_get_group_desc(const struct inode *inode,
223311
group % nilfs_palloc_groups_per_desc_block(inode);
224312
}
225313

314+
/**
315+
* nilfs_palloc_block_get_entry - get kernel address of an entry
316+
* @inode: inode of metadata file using this allocator
317+
* @nr: serial number of the entry (e.g. inode number)
318+
* @bh: buffer head of the buffer storing the entry block
319+
* @kaddr: kernel address mapped for the page including the buffer
320+
*/
226321
void *nilfs_palloc_block_get_entry(const struct inode *inode, __u64 nr,
227322
const struct buffer_head *bh, void *kaddr)
228323
{
@@ -235,11 +330,19 @@ void *nilfs_palloc_block_get_entry(const struct inode *inode, __u64 nr,
235330
entry_offset * NILFS_MDT(inode)->mi_entry_size;
236331
}
237332

333+
/**
334+
* nilfs_palloc_find_available_slot - find available slot in a group
335+
* @inode: inode of metadata file using this allocator
336+
* @group: group number
337+
* @target: offset number of an entry in the group (start point)
338+
* @bitmap: bitmap of the group
339+
* @bsize: size in bits
340+
*/
238341
static int nilfs_palloc_find_available_slot(struct inode *inode,
239342
unsigned long group,
240343
unsigned long target,
241344
unsigned char *bitmap,
242-
int bsize) /* size in bits */
345+
int bsize)
243346
{
244347
int curr, pos, end, i;
245348

@@ -277,6 +380,13 @@ static int nilfs_palloc_find_available_slot(struct inode *inode,
277380
return -ENOSPC;
278381
}
279382

383+
/**
384+
* nilfs_palloc_rest_groups_in_desc_block - get the remaining number of groups
385+
* in a group descriptor block
386+
* @inode: inode of metadata file using this allocator
387+
* @curr: current group number
388+
* @max: maximum number of groups
389+
*/
280390
static unsigned long
281391
nilfs_palloc_rest_groups_in_desc_block(const struct inode *inode,
282392
unsigned long curr, unsigned long max)
@@ -287,6 +397,11 @@ nilfs_palloc_rest_groups_in_desc_block(const struct inode *inode,
287397
max - curr + 1);
288398
}
289399

400+
/**
401+
* nilfs_palloc_prepare_alloc_entry - prepare to allocate a persistent object
402+
* @inode: inode of metadata file using this allocator
403+
* @req: nilfs_palloc_req structure exchanged for the allocation
404+
*/
290405
int nilfs_palloc_prepare_alloc_entry(struct inode *inode,
291406
struct nilfs_palloc_req *req)
292407
{
@@ -366,6 +481,11 @@ int nilfs_palloc_prepare_alloc_entry(struct inode *inode,
366481
return ret;
367482
}
368483

484+
/**
485+
* nilfs_palloc_commit_alloc_entry - finish allocation of a persistent object
486+
* @inode: inode of metadata file using this allocator
487+
* @req: nilfs_palloc_req structure exchanged for the allocation
488+
*/
369489
void nilfs_palloc_commit_alloc_entry(struct inode *inode,
370490
struct nilfs_palloc_req *req)
371491
{
@@ -377,6 +497,11 @@ void nilfs_palloc_commit_alloc_entry(struct inode *inode,
377497
brelse(req->pr_desc_bh);
378498
}
379499

500+
/**
501+
* nilfs_palloc_commit_free_entry - finish deallocating a persistent object
502+
* @inode: inode of metadata file using this allocator
503+
* @req: nilfs_palloc_req structure exchanged for the removal
504+
*/
380505
void nilfs_palloc_commit_free_entry(struct inode *inode,
381506
struct nilfs_palloc_req *req)
382507
{
@@ -410,6 +535,11 @@ void nilfs_palloc_commit_free_entry(struct inode *inode,
410535
brelse(req->pr_desc_bh);
411536
}
412537

538+
/**
539+
* nilfs_palloc_abort_alloc_entry - cancel allocation of a persistent object
540+
* @inode: inode of metadata file using this allocator
541+
* @req: nilfs_palloc_req structure exchanged for the allocation
542+
*/
413543
void nilfs_palloc_abort_alloc_entry(struct inode *inode,
414544
struct nilfs_palloc_req *req)
415545
{
@@ -442,6 +572,11 @@ void nilfs_palloc_abort_alloc_entry(struct inode *inode,
442572
req->pr_desc_bh = NULL;
443573
}
444574

575+
/**
576+
* nilfs_palloc_prepare_free_entry - prepare to deallocate a persistent object
577+
* @inode: inode of metadata file using this allocator
578+
* @req: nilfs_palloc_req structure exchanged for the removal
579+
*/
445580
int nilfs_palloc_prepare_free_entry(struct inode *inode,
446581
struct nilfs_palloc_req *req)
447582
{
@@ -464,6 +599,11 @@ int nilfs_palloc_prepare_free_entry(struct inode *inode,
464599
return 0;
465600
}
466601

602+
/**
603+
* nilfs_palloc_abort_free_entry - cancel deallocating a persistent object
604+
* @inode: inode of metadata file using this allocator
605+
* @req: nilfs_palloc_req structure exchanged for the removal
606+
*/
467607
void nilfs_palloc_abort_free_entry(struct inode *inode,
468608
struct nilfs_palloc_req *req)
469609
{
@@ -475,6 +615,12 @@ void nilfs_palloc_abort_free_entry(struct inode *inode,
475615
req->pr_desc_bh = NULL;
476616
}
477617

618+
/**
619+
* nilfs_palloc_group_is_in - judge if an entry is in a group
620+
* @inode: inode of metadata file using this allocator
621+
* @group: group number
622+
* @nr: serial number of the entry (e.g. inode number)
623+
*/
478624
static int
479625
nilfs_palloc_group_is_in(struct inode *inode, unsigned long group, __u64 nr)
480626
{
@@ -485,6 +631,12 @@ nilfs_palloc_group_is_in(struct inode *inode, unsigned long group, __u64 nr)
485631
return (nr >= first) && (nr <= last);
486632
}
487633

634+
/**
635+
* nilfs_palloc_freev - deallocate a set of persistent objects
636+
* @inode: inode of metadata file using this allocator
637+
* @entry_nrs: array of entry numbers to be deallocated
638+
* @nitems: number of entries stored in @entry_nrs
639+
*/
488640
int nilfs_palloc_freev(struct inode *inode, __u64 *entry_nrs, size_t nitems)
489641
{
490642
struct buffer_head *desc_bh, *bitmap_bh;

fs/nilfs2/alloc.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@
2929
#include <linux/buffer_head.h>
3030
#include <linux/fs.h>
3131

32+
/**
33+
* nilfs_palloc_entries_per_group - get the number of entries per group
34+
* @inode: inode of metadata file using this allocator
35+
*
36+
* The number of entries per group is defined by the number of bits
37+
* that a bitmap block can maintain.
38+
*/
3239
static inline unsigned long
3340
nilfs_palloc_entries_per_group(const struct inode *inode)
3441
{

0 commit comments

Comments
 (0)