Lines Matching refs:sbinfo
213 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); in shmem_inode_acct_block() local
220 if (sbinfo->max_blocks) { in shmem_inode_acct_block()
221 if (percpu_counter_compare(&sbinfo->used_blocks, in shmem_inode_acct_block()
222 sbinfo->max_blocks - pages) > 0) in shmem_inode_acct_block()
229 percpu_counter_add(&sbinfo->used_blocks, pages); in shmem_inode_acct_block()
246 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); in shmem_inode_unacct_blocks() local
251 if (sbinfo->max_blocks) in shmem_inode_unacct_blocks()
252 percpu_counter_sub(&sbinfo->used_blocks, pages); in shmem_inode_unacct_blocks()
332 struct shmem_sb_info *sbinfo = SHMEM_SB(sb); in shmem_reserve_inode() local
336 raw_spin_lock(&sbinfo->stat_lock); in shmem_reserve_inode()
337 if (sbinfo->max_inodes) { in shmem_reserve_inode()
338 if (sbinfo->free_ispace < BOGO_INODE_SIZE) { in shmem_reserve_inode()
339 raw_spin_unlock(&sbinfo->stat_lock); in shmem_reserve_inode()
342 sbinfo->free_ispace -= BOGO_INODE_SIZE; in shmem_reserve_inode()
345 ino = sbinfo->next_ino++; in shmem_reserve_inode()
347 ino = sbinfo->next_ino++; in shmem_reserve_inode()
348 if (unlikely(!sbinfo->full_inums && in shmem_reserve_inode()
357 sbinfo->next_ino = 1; in shmem_reserve_inode()
358 ino = sbinfo->next_ino++; in shmem_reserve_inode()
362 raw_spin_unlock(&sbinfo->stat_lock); in shmem_reserve_inode()
378 next_ino = per_cpu_ptr(sbinfo->ino_batch, get_cpu()); in shmem_reserve_inode()
381 raw_spin_lock(&sbinfo->stat_lock); in shmem_reserve_inode()
382 ino = sbinfo->next_ino; in shmem_reserve_inode()
383 sbinfo->next_ino += SHMEM_INO_BATCH; in shmem_reserve_inode()
384 raw_spin_unlock(&sbinfo->stat_lock); in shmem_reserve_inode()
398 struct shmem_sb_info *sbinfo = SHMEM_SB(sb); in shmem_free_inode() local
399 if (sbinfo->max_inodes) { in shmem_free_inode()
400 raw_spin_lock(&sbinfo->stat_lock); in shmem_free_inode()
401 sbinfo->free_ispace += BOGO_INODE_SIZE + freed_ispace; in shmem_free_inode()
402 raw_spin_unlock(&sbinfo->stat_lock); in shmem_free_inode()
612 static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, in shmem_unused_huge_shrink() argument
623 if (list_empty(&sbinfo->shrinklist)) in shmem_unused_huge_shrink()
626 spin_lock(&sbinfo->shrinklist_lock); in shmem_unused_huge_shrink()
627 list_for_each_safe(pos, next, &sbinfo->shrinklist) { in shmem_unused_huge_shrink()
648 sbinfo->shrinklist_len--; in shmem_unused_huge_shrink()
652 spin_unlock(&sbinfo->shrinklist_lock); in shmem_unused_huge_shrink()
713 spin_lock(&sbinfo->shrinklist_lock); in shmem_unused_huge_shrink()
714 list_move(&info->shrinklist, &sbinfo->shrinklist); in shmem_unused_huge_shrink()
715 sbinfo->shrinklist_len++; in shmem_unused_huge_shrink()
716 spin_unlock(&sbinfo->shrinklist_lock); in shmem_unused_huge_shrink()
727 struct shmem_sb_info *sbinfo = SHMEM_SB(sb); in shmem_unused_huge_scan() local
729 if (!READ_ONCE(sbinfo->shrinklist_len)) in shmem_unused_huge_scan()
732 return shmem_unused_huge_shrink(sbinfo, sc, 0); in shmem_unused_huge_scan()
738 struct shmem_sb_info *sbinfo = SHMEM_SB(sb); in shmem_unused_huge_count() local
739 return READ_ONCE(sbinfo->shrinklist_len); in shmem_unused_huge_count()
751 static unsigned long shmem_unused_huge_shrink(struct shmem_sb_info *sbinfo, in shmem_unused_huge_shrink() argument
1236 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); in shmem_evict_inode() local
1245 spin_lock(&sbinfo->shrinklist_lock); in shmem_evict_inode()
1248 sbinfo->shrinklist_len--; in shmem_evict_inode()
1250 spin_unlock(&sbinfo->shrinklist_lock); in shmem_evict_inode()
1264 simple_xattrs_free(&info->xattrs, sbinfo->max_inodes ? &freed : NULL); in shmem_evict_inode()
1428 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); in shmem_writepage() local
1442 if (WARN_ON_ONCE((info->flags & VM_LOCKED) || sbinfo->noswap)) in shmem_writepage()
1548 static struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo) in shmem_get_sbmpol() argument
1551 if (sbinfo->mpol) { in shmem_get_sbmpol()
1552 raw_spin_lock(&sbinfo->stat_lock); /* prevent replace/use races */ in shmem_get_sbmpol()
1553 mpol = sbinfo->mpol; in shmem_get_sbmpol()
1555 raw_spin_unlock(&sbinfo->stat_lock); in shmem_get_sbmpol()
1563 static inline struct mempolicy *shmem_get_sbmpol(struct shmem_sb_info *sbinfo) in shmem_get_sbmpol() argument
1934 struct shmem_sb_info *sbinfo; in shmem_get_folio_gfp() local
1951 sbinfo = SHMEM_SB(inode->i_sb); in shmem_get_folio_gfp()
2036 ret = shmem_unused_huge_shrink(sbinfo, NULL, 1); in shmem_get_folio_gfp()
2067 spin_lock(&sbinfo->shrinklist_lock); in shmem_get_folio_gfp()
2074 &sbinfo->shrinklist); in shmem_get_folio_gfp()
2075 sbinfo->shrinklist_len++; in shmem_get_folio_gfp()
2077 spin_unlock(&sbinfo->shrinklist_lock); in shmem_get_folio_gfp()
2440 struct shmem_sb_info *sbinfo = SHMEM_SB(sb); in __shmem_get_inode() local
2474 if (sbinfo->noswap) in __shmem_get_inode()
2490 shmem_get_sbmpol(sbinfo)); in __shmem_get_inode()
3030 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); in shmem_fallocate() local
3088 if (sbinfo->max_blocks && end - start > sbinfo->max_blocks) { in shmem_fallocate()
3182 struct shmem_sb_info *sbinfo = SHMEM_SB(dentry->d_sb); in shmem_statfs() local
3187 if (sbinfo->max_blocks) { in shmem_statfs()
3188 buf->f_blocks = sbinfo->max_blocks; in shmem_statfs()
3190 buf->f_bfree = sbinfo->max_blocks - in shmem_statfs()
3191 percpu_counter_sum(&sbinfo->used_blocks); in shmem_statfs()
3193 if (sbinfo->max_inodes) { in shmem_statfs()
3194 buf->f_files = sbinfo->max_inodes; in shmem_statfs()
3195 buf->f_ffree = sbinfo->free_ispace / BOGO_INODE_SIZE; in shmem_statfs()
3589 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); in shmem_initxattrs() local
3595 if (sbinfo->max_inodes) { in shmem_initxattrs()
3601 raw_spin_lock(&sbinfo->stat_lock); in shmem_initxattrs()
3602 if (sbinfo->free_ispace < ispace) in shmem_initxattrs()
3605 sbinfo->free_ispace -= ispace; in shmem_initxattrs()
3606 raw_spin_unlock(&sbinfo->stat_lock); in shmem_initxattrs()
3635 raw_spin_lock(&sbinfo->stat_lock); in shmem_initxattrs()
3636 sbinfo->free_ispace += ispace; in shmem_initxattrs()
3637 raw_spin_unlock(&sbinfo->stat_lock); in shmem_initxattrs()
3663 struct shmem_sb_info *sbinfo = SHMEM_SB(inode->i_sb); in shmem_xattr_handler_set() local
3668 if (value && sbinfo->max_inodes) { in shmem_xattr_handler_set()
3670 raw_spin_lock(&sbinfo->stat_lock); in shmem_xattr_handler_set()
3671 if (sbinfo->free_ispace < ispace) in shmem_xattr_handler_set()
3674 sbinfo->free_ispace -= ispace; in shmem_xattr_handler_set()
3675 raw_spin_unlock(&sbinfo->stat_lock); in shmem_xattr_handler_set()
3683 if (old_xattr && sbinfo->max_inodes) in shmem_xattr_handler_set()
3692 raw_spin_lock(&sbinfo->stat_lock); in shmem_xattr_handler_set()
3693 sbinfo->free_ispace += ispace; in shmem_xattr_handler_set()
3694 raw_spin_unlock(&sbinfo->stat_lock); in shmem_xattr_handler_set()
4104 struct shmem_sb_info *sbinfo = SHMEM_SB(fc->root->d_sb); in shmem_reconfigure() local
4109 raw_spin_lock(&sbinfo->stat_lock); in shmem_reconfigure()
4110 used_isp = sbinfo->max_inodes * BOGO_INODE_SIZE - sbinfo->free_ispace; in shmem_reconfigure()
4113 if (!sbinfo->max_blocks) { in shmem_reconfigure()
4117 if (percpu_counter_compare(&sbinfo->used_blocks, in shmem_reconfigure()
4124 if (!sbinfo->max_inodes) { in shmem_reconfigure()
4135 sbinfo->next_ino > UINT_MAX) { in shmem_reconfigure()
4139 if ((ctx->seen & SHMEM_SEEN_NOSWAP) && ctx->noswap && !sbinfo->noswap) { in shmem_reconfigure()
4143 if (!(ctx->seen & SHMEM_SEEN_NOSWAP) && !ctx->noswap && sbinfo->noswap) { in shmem_reconfigure()
4157 (ctx->qlimits.name## hardlimit != sbinfo->qlimits.name## hardlimit)) in shmem_reconfigure()
4167 sbinfo->huge = ctx->huge; in shmem_reconfigure()
4169 sbinfo->full_inums = ctx->full_inums; in shmem_reconfigure()
4171 sbinfo->max_blocks = ctx->blocks; in shmem_reconfigure()
4173 sbinfo->max_inodes = ctx->inodes; in shmem_reconfigure()
4174 sbinfo->free_ispace = ctx->inodes * BOGO_INODE_SIZE - used_isp; in shmem_reconfigure()
4181 mpol = sbinfo->mpol; in shmem_reconfigure()
4182 sbinfo->mpol = ctx->mpol; /* transfers initial ref */ in shmem_reconfigure()
4187 sbinfo->noswap = true; in shmem_reconfigure()
4189 raw_spin_unlock(&sbinfo->stat_lock); in shmem_reconfigure()
4193 raw_spin_unlock(&sbinfo->stat_lock); in shmem_reconfigure()
4199 struct shmem_sb_info *sbinfo = SHMEM_SB(root->d_sb); in shmem_show_options() local
4202 if (sbinfo->max_blocks != shmem_default_max_blocks()) in shmem_show_options()
4203 seq_printf(seq, ",size=%luk", K(sbinfo->max_blocks)); in shmem_show_options()
4204 if (sbinfo->max_inodes != shmem_default_max_inodes()) in shmem_show_options()
4205 seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes); in shmem_show_options()
4206 if (sbinfo->mode != (0777 | S_ISVTX)) in shmem_show_options()
4207 seq_printf(seq, ",mode=%03ho", sbinfo->mode); in shmem_show_options()
4208 if (!uid_eq(sbinfo->uid, GLOBAL_ROOT_UID)) in shmem_show_options()
4210 from_kuid_munged(&init_user_ns, sbinfo->uid)); in shmem_show_options()
4211 if (!gid_eq(sbinfo->gid, GLOBAL_ROOT_GID)) in shmem_show_options()
4213 from_kgid_munged(&init_user_ns, sbinfo->gid)); in shmem_show_options()
4235 if (IS_ENABLED(CONFIG_TMPFS_INODE64) || sbinfo->full_inums) in shmem_show_options()
4236 seq_printf(seq, ",inode%d", (sbinfo->full_inums ? 64 : 32)); in shmem_show_options()
4239 if (sbinfo->huge) in shmem_show_options()
4240 seq_printf(seq, ",huge=%s", shmem_format_huge(sbinfo->huge)); in shmem_show_options()
4242 mpol = shmem_get_sbmpol(sbinfo); in shmem_show_options()
4245 if (sbinfo->noswap) in shmem_show_options()
4254 struct shmem_sb_info *sbinfo = SHMEM_SB(sb); in shmem_put_super() local
4259 free_percpu(sbinfo->ino_batch); in shmem_put_super()
4260 percpu_counter_destroy(&sbinfo->used_blocks); in shmem_put_super()
4261 mpol_put(sbinfo->mpol); in shmem_put_super()
4262 kfree(sbinfo); in shmem_put_super()
4270 struct shmem_sb_info *sbinfo; in shmem_fill_super() local
4274 sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info), in shmem_fill_super()
4276 if (!sbinfo) in shmem_fill_super()
4279 sb->s_fs_info = sbinfo; in shmem_fill_super()
4294 sbinfo->noswap = ctx->noswap; in shmem_fill_super()
4303 sbinfo->max_blocks = ctx->blocks; in shmem_fill_super()
4304 sbinfo->max_inodes = ctx->inodes; in shmem_fill_super()
4305 sbinfo->free_ispace = sbinfo->max_inodes * BOGO_INODE_SIZE; in shmem_fill_super()
4307 sbinfo->ino_batch = alloc_percpu(ino_t); in shmem_fill_super()
4308 if (!sbinfo->ino_batch) in shmem_fill_super()
4311 sbinfo->uid = ctx->uid; in shmem_fill_super()
4312 sbinfo->gid = ctx->gid; in shmem_fill_super()
4313 sbinfo->full_inums = ctx->full_inums; in shmem_fill_super()
4314 sbinfo->mode = ctx->mode; in shmem_fill_super()
4315 sbinfo->huge = ctx->huge; in shmem_fill_super()
4316 sbinfo->mpol = ctx->mpol; in shmem_fill_super()
4319 raw_spin_lock_init(&sbinfo->stat_lock); in shmem_fill_super()
4320 if (percpu_counter_init(&sbinfo->used_blocks, 0, GFP_KERNEL)) in shmem_fill_super()
4322 spin_lock_init(&sbinfo->shrinklist_lock); in shmem_fill_super()
4323 INIT_LIST_HEAD(&sbinfo->shrinklist); in shmem_fill_super()
4346 memcpy(&sbinfo->qlimits, &ctx->qlimits, in shmem_fill_super()
4354 inode = shmem_get_inode(&nop_mnt_idmap, sb, NULL, S_IFDIR | sbinfo->mode, 0, in shmem_fill_super()
4360 inode->i_uid = sbinfo->uid; in shmem_fill_super()
4361 inode->i_gid = sbinfo->gid; in shmem_fill_super()