@@ -439,6 +439,27 @@ static const struct address_space_operations def_mdt_aops = {
439439static const struct inode_operations def_mdt_iops ;
440440static const struct file_operations def_mdt_fops ;
441441
442+
443+ int nilfs_mdt_init (struct inode * inode , struct the_nilfs * nilfs ,
444+ gfp_t gfp_mask , size_t objsz )
445+ {
446+ struct nilfs_mdt_info * mi ;
447+
448+ mi = kzalloc (max (sizeof (* mi ), objsz ), GFP_NOFS );
449+ if (!mi )
450+ return - ENOMEM ;
451+
452+ mi -> mi_nilfs = nilfs ;
453+ init_rwsem (& mi -> mi_sem );
454+ inode -> i_private = mi ;
455+
456+ inode -> i_mode = S_IFREG ;
457+ mapping_set_gfp_mask (inode -> i_mapping , gfp_mask );
458+ inode -> i_mapping -> backing_dev_info = nilfs -> ns_bdi ;
459+
460+ return 0 ;
461+ }
462+
442463/*
443464 * NILFS2 uses pseudo inodes for meta data files such as DAT, cpfile, sufile,
444465 * ifile, or gcinodes. This allows the B-tree code and segment constructor
@@ -454,37 +475,24 @@ static const struct file_operations def_mdt_fops;
454475 * @nilfs: nilfs object
455476 * @sb: super block instance the metadata file belongs to
456477 * @ino: inode number
457- * @gfp_mask: gfp mask for data pages
458- * @objsz: size of the private object attached to inode->i_private
459478 */
460479struct inode *
461480nilfs_mdt_new_common (struct the_nilfs * nilfs , struct super_block * sb ,
462- ino_t ino , gfp_t gfp_mask , size_t objsz )
481+ ino_t ino )
463482{
464483 struct inode * inode = nilfs_alloc_inode_common (nilfs );
465484
466485 if (!inode )
467486 return NULL ;
468487 else {
469488 struct address_space * const mapping = & inode -> i_data ;
470- struct nilfs_mdt_info * mi ;
471-
472- mi = kzalloc (max (sizeof (* mi ), objsz ), GFP_NOFS );
473- if (!mi ) {
474- nilfs_destroy_inode (inode );
475- return NULL ;
476- }
477- mi -> mi_nilfs = nilfs ;
478- init_rwsem (& mi -> mi_sem );
479489
480490 inode -> i_sb = sb ; /* sb may be NULL for some meta data files */
481491 inode -> i_blkbits = nilfs -> ns_blocksize_bits ;
482492 inode -> i_flags = 0 ;
483493 atomic_set (& inode -> i_count , 1 );
484494 inode -> i_nlink = 1 ;
485495 inode -> i_ino = ino ;
486- inode -> i_mode = S_IFREG ;
487- inode -> i_private = mi ;
488496
489497#ifdef INIT_UNUSED_INODE_FIELDS
490498 atomic_set (& inode -> i_writecount , 0 );
@@ -515,9 +523,7 @@ nilfs_mdt_new_common(struct the_nilfs *nilfs, struct super_block *sb,
515523
516524 mapping -> host = NULL ; /* instead of inode */
517525 mapping -> flags = 0 ;
518- mapping_set_gfp_mask (mapping , gfp_mask );
519526 mapping -> assoc_mapping = NULL ;
520- mapping -> backing_dev_info = nilfs -> ns_bdi ;
521527
522528 inode -> i_mapping = mapping ;
523529 }
@@ -530,10 +536,14 @@ struct inode *nilfs_mdt_new(struct the_nilfs *nilfs, struct super_block *sb,
530536{
531537 struct inode * inode ;
532538
533- inode = nilfs_mdt_new_common (nilfs , sb , ino , NILFS_MDT_GFP , objsz );
539+ inode = nilfs_mdt_new_common (nilfs , sb , ino );
534540 if (!inode )
535541 return NULL ;
536542
543+ if (nilfs_mdt_init (inode , nilfs , NILFS_MDT_GFP , objsz ) < 0 ) {
544+ nilfs_destroy_inode (inode );
545+ return NULL ;
546+ }
537547 inode -> i_op = & def_mdt_iops ;
538548 inode -> i_fop = & def_mdt_fops ;
539549 inode -> i_mapping -> a_ops = & def_mdt_aops ;
0 commit comments