aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nilfs2/mdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nilfs2/mdt.c')
-rw-r--r--fs/nilfs2/mdt.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c
index f6326112d647..62074e8d25cb 100644
--- a/fs/nilfs2/mdt.c
+++ b/fs/nilfs2/mdt.c
@@ -445,9 +445,17 @@ static const struct file_operations def_mdt_fops;
445 * longer than those of the super block structs; they may continue for 445 * longer than those of the super block structs; they may continue for
446 * several consecutive mounts/umounts. This would need discussions. 446 * several consecutive mounts/umounts. This would need discussions.
447 */ 447 */
448/**
449 * nilfs_mdt_new_common - allocate a pseudo inode for metadata file
450 * @nilfs: nilfs object
451 * @sb: super block instance the metadata file belongs to
452 * @ino: inode number
453 * @gfp_mask: gfp mask for data pages
454 * @objsz: size of the private object attached to inode->i_private
455 */
448struct inode * 456struct inode *
449nilfs_mdt_new_common(struct the_nilfs *nilfs, struct super_block *sb, 457nilfs_mdt_new_common(struct the_nilfs *nilfs, struct super_block *sb,
450 ino_t ino, gfp_t gfp_mask) 458 ino_t ino, gfp_t gfp_mask, size_t objsz)
451{ 459{
452 struct inode *inode = nilfs_alloc_inode_common(nilfs); 460 struct inode *inode = nilfs_alloc_inode_common(nilfs);
453 461
@@ -455,8 +463,9 @@ nilfs_mdt_new_common(struct the_nilfs *nilfs, struct super_block *sb,
455 return NULL; 463 return NULL;
456 else { 464 else {
457 struct address_space * const mapping = &inode->i_data; 465 struct address_space * const mapping = &inode->i_data;
458 struct nilfs_mdt_info *mi = kzalloc(sizeof(*mi), GFP_NOFS); 466 struct nilfs_mdt_info *mi;
459 467
468 mi = kzalloc(max(sizeof(*mi), objsz), GFP_NOFS);
460 if (!mi) { 469 if (!mi) {
461 nilfs_destroy_inode(inode); 470 nilfs_destroy_inode(inode);
462 return NULL; 471 return NULL;
@@ -513,11 +522,11 @@ nilfs_mdt_new_common(struct the_nilfs *nilfs, struct super_block *sb,
513} 522}
514 523
515struct inode *nilfs_mdt_new(struct the_nilfs *nilfs, struct super_block *sb, 524struct inode *nilfs_mdt_new(struct the_nilfs *nilfs, struct super_block *sb,
516 ino_t ino) 525 ino_t ino, size_t objsz)
517{ 526{
518 struct inode *inode = nilfs_mdt_new_common(nilfs, sb, ino, 527 struct inode *inode;
519 NILFS_MDT_GFP);
520 528
529 inode = nilfs_mdt_new_common(nilfs, sb, ino, NILFS_MDT_GFP, objsz);
521 if (!inode) 530 if (!inode)
522 return NULL; 531 return NULL;
523 532