fs/ceph/inode.c

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

File Facts

System
Linux kernel
Corpus path
fs/ceph/inode.c
Extension
.c
Size
92691 bytes
Lines
3258
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 (ci->fscrypt_auth) {
			inode->i_flags |= S_ENCRYPTED;
			ci->fscrypt_auth_len = pci->fscrypt_auth_len;
		} else {
			doutc(cl, "Failed to alloc snapdir fscrypt_auth\n");
			ret = -ENOMEM;
			goto err;
		}
	}
#endif
	if (inode_state_read_once(inode) & I_NEW) {
		inode->i_op = &ceph_snapdir_iops;
		inode->i_fop = &ceph_snapdir_fops;
		ci->i_snap_caps = CEPH_CAP_PIN; /* so we can open */
		unlock_new_inode(inode);
	}

	return inode;
err:
	if ((inode_state_read_once(inode) & I_NEW))
		discard_new_inode(inode);
	else
		iput(inode);
	return ERR_PTR(ret);
}

const struct inode_operations ceph_file_iops = {
	.permission = ceph_permission,
	.setattr = ceph_setattr,
	.getattr = ceph_getattr,
	.listxattr = ceph_listxattr,
	.get_inode_acl = ceph_get_acl,
	.set_acl = ceph_set_acl,
};


/*
 * We use a 'frag tree' to keep track of the MDS's directory fragments
 * for a given inode (usually there is just a single fragment).  We
 * need to know when a child frag is delegated to a new MDS, or when
 * it is flagged as replicated, so we can direct our requests
 * accordingly.
 */

/*
 * find/create a frag in the tree
 */
static struct ceph_inode_frag *__get_or_create_frag(struct ceph_inode_info *ci,
						    u32 f)
{
	struct inode *inode = &ci->netfs.inode;
	struct ceph_client *cl = ceph_inode_to_client(inode);
	struct rb_node **p;
	struct rb_node *parent = NULL;
	struct ceph_inode_frag *frag;
	int c;

	p = &ci->i_fragtree.rb_node;
	while (*p) {
		parent = *p;
		frag = rb_entry(parent, struct ceph_inode_frag, node);
		c = ceph_frag_compare(f, frag->frag);
		if (c < 0)
			p = &(*p)->rb_left;
		else if (c > 0)
			p = &(*p)->rb_right;
		else
			return frag;
	}

	frag = kmalloc_obj(*frag, GFP_NOFS);
	if (!frag)
		return ERR_PTR(-ENOMEM);

	frag->frag = f;
	frag->split_by = 0;
	frag->mds = -1;
	frag->ndist = 0;

	rb_link_node(&frag->node, parent, p);
	rb_insert_color(&frag->node, &ci->i_fragtree);

	doutc(cl, "added %p %llx.%llx frag %x\n", inode, ceph_vinop(inode), f);
	return frag;
}

/*
 * find a specific frag @f
 */
struct ceph_inode_frag *__ceph_find_frag(struct ceph_inode_info *ci, u32 f)

Annotation

Implementation Notes