linux-vfs : inode number
2015-08-08 18:01
851 查看
http://blog.chinaunix.net/uid-20481436-id-1941493.html
linux-3.10/fs/inode.c 856 /* 857 * Each cpu owns a range of LAST_INO_BATCH numbers. 858 * 'shared_last_ino' is dirtied only once out of LAST_INO_BATCH allocations, 859 * to renew the exhausted range. 860 * 861 * This does not significantly increase overflow rate because every CPU can 862 * consume at most LAST_INO_BATCH-1 unused inode numbers. So there is 863 * NR_CPUS*(LAST_INO_BATCH-1) wastage. At 4096 and 1024, this is ~0.1% of the 864 * 2^32 range, and is a worst-case. Even a 50% wastage would only increase 865 * overflow rate by 2x, which does not seem too significant. 866 * 867 * On a 32bit, non LFS stat() call, glibc will generate an EOVERFLOW 868 * error if st_ino won't fit in target struct field. Use 32bit counter 869 * here to attempt to avoid that. 870 */ 871 #define LAST_INO_BATCH 1024 872 static DEFINE_PER_CPU(unsigned int, last_ino); 873 874 unsigned int get_next_ino(void) 875 { 876 unsigned int *p = &get_cpu_var(last_ino); 877 unsigned int res = *p; 878 879 #ifdef CONFIG_SMP 880 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) { 881 static atomic_t shared_last_ino; 882 int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino); 883 884 res = next - LAST_INO_BATCH; 885 } 886 #endif 887 888 *p = ++res; 889 put_cpu_var(last_ino); 890 return res; 891 } 892 EXPORT_SYMBOL(get_next_ino); |
相关文章推荐
- [Sqlite] --> Sqlite于Windows、Linux 和 Mac OS X 在安装过程
- Linux常用命令大全
- linux系统的颜色配置
- Linux LVM 磁盘管理
- linux下vi命令大全
- linux下的so、o、lo、a、la文件的区别
- Linux网卡数据包的接收
- (大数据工程师学习路径)第一步 Linux 基础入门----简单的文本处理
- Linux高并发机制——epoll模型
- linux 死机 处理 reisub
- (大数据工程师学习路径)第一步 Linux 基础入门----命令执行顺序控制与管道
- Linux根文件系统详解
- [转载] 分析Linux内核创建一个新进程的过程
- DAY_18_linux/list.h
- LINUX系统安装
- Linux常用命令笔记
- (大数据工程师学习路径)第一步 Linux 基础入门----文件系统操作与磁盘管理
- linux 下 c++ 多线程的实现
- Linux命令学习之二
- linux syetem()函数