|
@@ -571,6 +571,15 @@ static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo,
|
|
|
}
|
|
}
|
|
|
#endif /* CONFIG_TRANSPARENT_HUGE_PAGECACHE */
|
|
#endif /* CONFIG_TRANSPARENT_HUGE_PAGECACHE */
|
|
|
|
|
|
|
|
|
|
+static inline bool is_huge_enabled(struct shmem_sb_info *sbinfo)
|
|
|
|
|
+{
|
|
|
|
|
+ if (IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE) &&
|
|
|
|
|
+ (shmem_huge == SHMEM_HUGE_FORCE || sbinfo->huge) &&
|
|
|
|
|
+ shmem_huge != SHMEM_HUGE_DENY)
|
|
|
|
|
+ return true;
|
|
|
|
|
+ return false;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/*
|
|
/*
|
|
|
* Like add_to_page_cache_locked, but error if expected item has gone.
|
|
* Like add_to_page_cache_locked, but error if expected item has gone.
|
|
|
*/
|
|
*/
|
|
@@ -988,6 +997,7 @@ static int shmem_getattr(const struct path *path, struct kstat *stat,
|
|
|
{
|
|
{
|
|
|
struct inode *inode = path->dentry->d_inode;
|
|
struct inode *inode = path->dentry->d_inode;
|
|
|
struct shmem_inode_info *info = SHMEM_I(inode);
|
|
struct shmem_inode_info *info = SHMEM_I(inode);
|
|
|
|
|
+ struct shmem_sb_info *sb_info = SHMEM_SB(inode->i_sb);
|
|
|
|
|
|
|
|
if (info->alloced - info->swapped != inode->i_mapping->nrpages) {
|
|
if (info->alloced - info->swapped != inode->i_mapping->nrpages) {
|
|
|
spin_lock_irq(&info->lock);
|
|
spin_lock_irq(&info->lock);
|
|
@@ -995,6 +1005,10 @@ static int shmem_getattr(const struct path *path, struct kstat *stat,
|
|
|
spin_unlock_irq(&info->lock);
|
|
spin_unlock_irq(&info->lock);
|
|
|
}
|
|
}
|
|
|
generic_fillattr(inode, stat);
|
|
generic_fillattr(inode, stat);
|
|
|
|
|
+
|
|
|
|
|
+ if (is_huge_enabled(sb_info))
|
|
|
|
|
+ stat->blksize = HPAGE_PMD_SIZE;
|
|
|
|
|
+
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|