fs/ufs/util.c

Source file repositories/reference/linux-study-clean/fs/ufs/util.c

File Facts

System
Linux kernel
Corpus path
fs/ufs/util.c
Extension
.c
Size
4954 bytes
Lines
224
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

if ((fs32 & 0xffff8000) == 0) {
			fs32 = old_encode_dev(dev);
		}
		break;

	default:
		fs32 = old_encode_dev(dev);
		break;
	}
	if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86)
		ufsi->i_u1.i_data[1] = cpu_to_fs32(sb, fs32);
	else
		ufsi->i_u1.i_data[0] = cpu_to_fs32(sb, fs32);
}

/**
 * ufs_get_locked_folio() - locate, pin and lock a pagecache folio, if not exist
 * read it from disk.
 * @mapping: the address_space to search
 * @index: the page index
 *
 * Locates the desired pagecache folio, if not exist we'll read it,
 * locks it, increments its reference
 * count and returns its address.
 *
 */
struct folio *ufs_get_locked_folio(struct address_space *mapping,
				 pgoff_t index)
{
	struct inode *inode = mapping->host;
	struct folio *folio = filemap_lock_folio(mapping, index);
	if (IS_ERR(folio)) {
		folio = read_mapping_folio(mapping, index, NULL);

		if (IS_ERR(folio)) {
			printk(KERN_ERR "ufs_change_blocknr: read_mapping_folio error: ino %llu, index: %lu\n",
			       mapping->host->i_ino, index);
			return folio;
		}

		folio_lock(folio);

		if (unlikely(folio->mapping == NULL)) {
			/* Truncate got there first */
			folio_unlock(folio);
			folio_put(folio);
			return NULL;
		}
	}
	if (!folio_buffers(folio))
		create_empty_buffers(folio, 1 << inode->i_blkbits, 0);
	return folio;
}

Annotation

Implementation Notes