fs/smb/client/inode.c

Source file repositories/reference/linux-study-clean/fs/smb/client/inode.c

File Facts

System
Linux kernel
Corpus path
fs/smb/client/inode.c
Extension
.c
Size
96474 bytes
Lines
3519
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 (sbflags & CIFS_MOUNT_DIRECT_IO) {
			set_bit(NETFS_ICTX_UNBUFFERED, &ictx->flags);
			if (sbflags & CIFS_MOUNT_NO_BRL)
				inode->i_fop = &cifs_file_direct_nobrl_ops;
			else
				inode->i_fop = &cifs_file_direct_ops;
		} else if (sbflags & CIFS_MOUNT_STRICT_IO) {
			if (sbflags & CIFS_MOUNT_NO_BRL)
				inode->i_fop = &cifs_file_strict_nobrl_ops;
			else
				inode->i_fop = &cifs_file_strict_ops;
		} else if (sbflags & CIFS_MOUNT_NO_BRL)
			inode->i_fop = &cifs_file_nobrl_ops;
		else { /* not direct, send byte range locks */
			inode->i_fop = &cifs_file_ops;
		}

		/* check if server can support readahead */
		if (tcon->ses->server->max_read < PAGE_SIZE + MAX_CIFS_HDR_SIZE)
			inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
		else
			inode->i_data.a_ops = &cifs_addr_ops;
		mapping_set_large_folios(inode->i_mapping);
		break;
	case S_IFDIR:
		if (IS_AUTOMOUNT(inode)) {
			inode->i_op = &cifs_namespace_inode_operations;
		} else {
			inode->i_op = &cifs_dir_inode_ops;
			inode->i_fop = &cifs_dir_ops;
		}
		break;
	case S_IFLNK:
		inode->i_op = &cifs_symlink_inode_ops;
		break;
	default:
		init_special_inode(inode, inode->i_mode, inode->i_rdev);
		break;
	}
}

/* check inode attributes against fattr. If they don't match, tag the
 * inode for cache invalidation
 */
static void
cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
{
	struct cifs_fscache_inode_coherency_data cd;
	struct cifsInodeInfo *cifs_i = CIFS_I(inode);
	struct timespec64 mtime;

	cifs_dbg(FYI, "%s: revalidating inode %llu\n",
		 __func__, cifs_i->uniqueid);

	if (inode_state_read_once(inode) & I_NEW) {
		cifs_dbg(FYI, "%s: inode %llu is new\n",
			 __func__, cifs_i->uniqueid);
		return;
	}

	/* don't bother with revalidation if we have an oplock */
	if (CIFS_CACHE_READ(cifs_i)) {
		cifs_dbg(FYI, "%s: inode %llu is oplocked\n",
			 __func__, cifs_i->uniqueid);
		return;
	}

	 /* revalidate if mtime or size have changed */
	fattr->cf_mtime = timestamp_truncate(fattr->cf_mtime, inode);
	mtime = inode_get_mtime(inode);
	if (timespec64_equal(&mtime, &fattr->cf_mtime) &&
	    netfs_read_remote_i_size(inode) == fattr->cf_eof) {
		cifs_dbg(FYI, "%s: inode %llu is unchanged\n",
			 __func__, cifs_i->uniqueid);
		return;
	}

	cifs_dbg(FYI, "%s: invalidating inode %llu mapping\n",
		 __func__, cifs_i->uniqueid);
	set_bit(CIFS_INO_INVALID_MAPPING, &cifs_i->flags);
	/* Invalidate fscache cookie */
	cifs_fscache_fill_coherency(&cifs_i->netfs.inode, &cd);
	fscache_invalidate(cifs_inode_cookie(inode), &cd, i_size_read(inode), 0);
}

/*
 * copy nlink to the inode, unless it wasn't provided.  Provide
 * sane values if we don't have an existing one and none was provided
 */
static void

Annotation

Implementation Notes