@@ -237,7 +237,7 @@ static ssize_t wrapfs_read(struct file *file, char __user *buf, size_t count, lo
237237
238238 lower_file = wrapfs_lower_file (file );
239239
240- pvd = ((struct wrapfs_file_info * )file -> private_data )-> pvd ;
240+ pvd = ((struct wrapfs_file_info * )file -> private_data )-> fmap_info -> pvd ;
241241
242242 if (
243243 (pvd != NULL )
@@ -313,7 +313,7 @@ static ssize_t wrapfs_write(struct file *file, const char __user *buf, size_t co
313313 unsigned int radix_tree_id ;
314314#endif
315315
316- struct pr_vma_data * pvd = ((struct wrapfs_file_info * )file -> private_data )-> pvd ;
316+ struct pr_vma_data * pvd = ((struct wrapfs_file_info * )file -> private_data )-> fmap_info -> pvd ;
317317
318318 if (
319319 (pvd != NULL )
@@ -376,7 +376,7 @@ static long dmap_priority_ioctl(struct file *file, unsigned int cmd, unsigned lo
376376{
377377#if 0
378378 int retval = 0 ;
379- struct pr_vma_data * pvd = ((struct wrapfs_file_info * )file -> private_data )-> pvd ;
379+ struct pr_vma_data * pvd = ((struct wrapfs_file_info * )file -> private_data )-> fmap_info -> pvd ;
380380 struct dmap_page_prio __user * __dpp_p ;
381381 struct dmap_page_prio __dpp_d ;
382382
@@ -487,6 +487,12 @@ static int wrapfs_open(struct inode *inode, struct file *file)
487487 goto out_err ;
488488 }
489489
490+ ((struct wrapfs_file_info * )file -> private_data )-> fmap_info = kzalloc (sizeof (struct fastmap_info ), GFP_KERNEL );
491+ if (!((struct wrapfs_file_info * )file -> private_data )-> fmap_info ){
492+ err = - ENOMEM ;
493+ goto out_err ;
494+ }
495+
490496 /* open lower object and link wrapfs's file struct to lower's */
491497 wrapfs_get_lower_path (file -> f_path .dentry , & lower_path );
492498 lower_file = dentry_open (& lower_path , file -> f_flags , current_cred ());
@@ -527,7 +533,7 @@ static int wrapfs_open(struct inode *inode, struct file *file)
527533
528534 // set it to the private data of the file
529535 DMAP_BGON ( (pvd -> magic1 != PVD_MAGIC_1 ) || (pvd -> magic2 != PVD_MAGIC_2 ) );
530- ((struct wrapfs_file_info * )file -> private_data )-> pvd = pvd ;
536+ ((struct wrapfs_file_info * )file -> private_data )-> fmap_info -> pvd = pvd ;
531537 }
532538
533539 if (IS_ERR (lower_file )) {
@@ -588,11 +594,11 @@ static int wrapfs_file_release(struct inode *inode, struct file *file)
588594
589595 lower_file = wrapfs_lower_file (file );
590596
591- pvd = ((struct wrapfs_file_info * )file -> private_data )-> pvd ;
597+ pvd = ((struct wrapfs_file_info * )file -> private_data )-> fmap_info -> pvd ;
592598 if (pvd != NULL && pvd -> is_mmap == true && pvd -> is_valid == true && atomic64_read (& pvd -> mmaped ) == 1 ){
593599
594600 if (lower_file )
595- ((struct wrapfs_file_info * )file -> private_data )-> pvd -> bk .filp = lower_file ;
601+ ((struct wrapfs_file_info * )file -> private_data )-> fmap_info -> pvd -> bk .filp = lower_file ;
596602 else
597603 DMAP_BGON (1 );
598604
@@ -613,12 +619,12 @@ static int wrapfs_file_release(struct inode *inode, struct file *file)
613619
614620 for (i = 0 ; i < MAX_OPEN_FDS ; ++ i ){
615621 if (pvd -> open_fds [i ] != NULL && pvd -> open_fds [i ]-> f_inode != NULL ){
616- ((struct wrapfs_file_info * )file -> private_data )-> pvd -> bk .filp = pvd -> open_fds [i ];
622+ ((struct wrapfs_file_info * )file -> private_data )-> fmap_info -> pvd -> bk .filp = pvd -> open_fds [i ];
617623 break ;
618624 }
619625 }
620626
621- ((struct wrapfs_file_info * )file -> private_data )-> pvd = NULL ;
627+ ((struct wrapfs_file_info * )file -> private_data )-> fmap_info -> pvd = NULL ;
622628 }else if (pvd != NULL ){
623629 for (i = 0 ; i < MAX_OPEN_FDS ; ++ i )
624630 if (pvd -> open_fds [i ] == lower_file ){
@@ -644,7 +650,7 @@ static int wrapfs_fsync(struct file *file, loff_t start, loff_t end, int datasyn
644650 struct dentry * dentry = file -> f_path .dentry ;
645651 struct pr_vma_data * pvd ;
646652
647- pvd = ((struct wrapfs_file_info * )file -> private_data )-> pvd ;
653+ pvd = ((struct wrapfs_file_info * )file -> private_data )-> fmap_info -> pvd ;
648654 if (pvd == NULL )
649655 goto mmap_fsync ;
650656
@@ -712,7 +718,7 @@ wrapfs_read_iter(struct kiocb *iocb, struct iov_iter *iter)
712718 struct file * file = iocb -> ki_filp , * lower_file ;
713719
714720#ifdef DEBUG_DIRECT_RW
715- struct pr_vma_data * pvd = ((struct wrapfs_file_info * )file -> private_data )-> pvd ;
721+ struct pr_vma_data * pvd = ((struct wrapfs_file_info * )file -> private_data )-> fmap_info -> pvd ;
716722 if (pvd != NULL ){
717723 DMAP_BGON ( (pvd -> magic1 != PVD_MAGIC_1 ) || (pvd -> magic2 != PVD_MAGIC_2 ) );
718724 WARN (atomic64_read (& pvd -> cnt ) > 0 , "[%s:%s:%d][%ld]\n" , __FILE__ , __func__ , __LINE__ , atomic64_read (& pvd -> cnt ));
@@ -750,7 +756,7 @@ wrapfs_write_iter(struct kiocb *iocb, struct iov_iter *iter)
750756 struct file * file = iocb -> ki_filp , * lower_file ;
751757
752758#ifdef DEBUG_DIRECT_RW
753- struct pr_vma_data * pvd = ((struct wrapfs_file_info * )file -> private_data )-> pvd ;
759+ struct pr_vma_data * pvd = ((struct wrapfs_file_info * )file -> private_data )-> fmap_info -> pvd ;
754760 if (pvd != NULL ){
755761 DMAP_BGON ( (pvd -> magic1 != PVD_MAGIC_1 ) || (pvd -> magic2 != PVD_MAGIC_2 ) );
756762 WARN (atomic64_read (& pvd -> cnt ) > 0 , "[%s:%s:%d][%ld]\n" , __FILE__ , __func__ , __LINE__ , atomic64_read (& pvd -> cnt ));
0 commit comments