// SPDX-License-Identifier: GPL-2.0 /* * linux/fs/ufs/ialloc.c * * Copyright (c) 1998 * Daniel Pirkl <[email protected]> * Charles University, Faculty of Mathematics and Physics * * from * * linux/fs/ext2/ialloc.c * * Copyright (C) 1992, 1993, 1994, 1995 * Remy Card ([email protected]) * Laboratoire MASI - Institut Blaise Pascal * Universite Pierre et Marie Curie (Paris VI) * * BSD ufs-inspired inode and directory allocation by * Stephen Tweedie ([email protected]), 1993 * Big-endian to little-endian byte-swapping/bitmaps by * David S. Miller ([email protected]), 1995 * * UFS2 write support added by * Evgeniy Dushistov <[email protected]>, 2007 */ #include <linux/fs.h> #include <linux/time.h> #include <linux/stat.h> #include <linux/string.h> #include <linux/buffer_head.h> #include <linux/sched.h> #include <linux/bitops.h> #include <asm/byteorder.h> #include "ufs_fs.h" #include "ufs.h" #include "swab.h" #include "util.h" /* * NOTE! When we get the inode, we're the only people * that have access to it, and as such there are no * race conditions we have to worry about. The inode * is not on the hash-lists, and it cannot be reached * through the filesystem because the directory entry * has been deleted earlier. * * HOWEVER: we must make sure that we get no aliases, * which means that we have to call "clear_inode()" * _before_ we mark the inode not in use in the inode * bitmaps. Otherwise a newly created file might use * the same inode number (not actually the same pointer * though), and then we'd have two inodes sharing the * same inode number and space on the harddisk. */ void ufs_free_inode (struct inode * inode) { … } /* * Nullify new chunk of inodes, * BSD people also set ui_gen field of inode * during nullification, but we not care about * that because of linux ufs do not support NFS */ static void ufs2_init_inodes_chunk(struct super_block *sb, struct ufs_cg_private_info *ucpi, struct ufs_cylinder_group *ucg) { … } /* * There are two policies for allocating an inode. If the new inode is * a directory, then a forward search is made for a block group with both * free space and a low directory-to-inode ratio; if that fails, then of * the groups with above-average free space, that group with the fewest * directories already is chosen. * * For other inodes, search forward from the parent directory's block * group to find a free inode. */ struct inode *ufs_new_inode(struct inode *dir, umode_t mode) { … }