Lines Matching refs:inode
20 * directories. Indeed, any inode (but of course not xattr inodes) may have a
23 * attribute, the host inode number, and the extended attribute inode number.
24 * Similarly, direntries store the name, the parent and the target inode
30 * attributes associated with an inode (%XATTR_LIST_MAX), so UBIFS makes sure
31 * the sum of all extended attribute names of the inode does not exceed that
40 * in the VFS inode cache. The xentries are cached in the LNC cache (see
70 * @host: host inode
76 * and value @value for inode @host. The host inode is also updated on flash
81 static int create_xattr(struct ubifs_info *c, struct inode *host,
85 struct inode *inode;
92 ubifs_err(c, "inode %lu already has too many xattrs (%d), cannot create more",
104 ubifs_err(c, "cannot add one more xattr name to inode %lu, total names length would become %d, max. is %d",
113 inode = ubifs_new_inode(c, host, S_IFREG | S_IRWXUGO, true);
114 if (IS_ERR(inode)) {
115 err = PTR_ERR(inode);
120 inode->i_mapping->a_ops = &empty_aops;
121 inode->i_op = &empty_iops;
122 inode->i_fop = &empty_fops;
124 inode->i_flags |= S_SYNC | S_NOATIME | S_NOCMTIME;
125 ui = ubifs_inode(inode);
133 inode->i_size = ui->ui_size = size;
145 * have to set the UBIFS_CRYPT_FL flag on the host inode.
146 * To avoid multiple updates of the same inode in the same operation,
152 err = ubifs_jnl_update(c, host, nm, inode, 0, 1);
159 insert_inode_hash(inode);
160 iput(inode);
171 make_bad_inode(inode);
172 iput(inode);
181 * @host: host inode
182 * @inode: extended attribute inode
186 * This helper function changes the value of extended attribute @inode with new
190 static int change_xattr(struct ubifs_info *c, struct inode *host,
191 struct inode *inode, const void *value, int size)
195 struct ubifs_inode *ui = ubifs_inode(inode);
201 ubifs_assert(c, ui->data_len == inode->i_size);
213 inode->i_size = ui->ui_size = size;
223 * It is important to write the host inode after the xattr inode
224 * because if the host inode gets synchronized (via 'fsync()'), then
225 * the extended attribute inode gets synchronized, because it goes
226 * before the host inode in the write-buffer.
228 err = ubifs_jnl_change_xattr(c, inode, host);
240 make_bad_inode(inode);
246 static struct inode *iget_xattr(struct ubifs_info *c, ino_t inum)
248 struct inode *inode;
250 inode = ubifs_iget(c->vfs_sb, inum);
251 if (IS_ERR(inode)) {
253 (int)PTR_ERR(inode));
254 return inode;
256 if (ubifs_inode(inode)->xattr)
257 return inode;
259 iput(inode);
263 int ubifs_xattr_set(struct inode *host, const char *name, const void *value,
266 struct inode *inode;
311 inode = iget_xattr(c, le64_to_cpu(xent->inum));
312 if (IS_ERR(inode)) {
313 err = PTR_ERR(inode);
317 err = change_xattr(c, host, inode, value, size);
318 iput(inode);
326 ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf,
329 struct inode *inode;
353 inode = iget_xattr(c, le64_to_cpu(xent->inum));
354 if (IS_ERR(inode)) {
355 err = PTR_ERR(inode);
359 ui = ubifs_inode(inode);
360 ubifs_assert(c, inode->i_size == ui->data_len);
375 iput(inode);
399 struct inode *host = d_inode(dentry);
461 static int remove_xattr(struct ubifs_info *c, struct inode *host,
462 struct inode *inode, const struct fscrypt_name *nm)
466 struct ubifs_inode *ui = ubifs_inode(inode);
470 ubifs_assert(c, ui->data_len == inode->i_size);
483 err = ubifs_jnl_delete_xattr(c, host, inode, nm);
498 make_bad_inode(inode);
502 int ubifs_purge_xattrs(struct inode *host)
507 struct inode *xino;
514 ubifs_warn(c, "inode %lu has too many xattrs, doing a non-atomic deletion",
574 * ubifs_evict_xattr_inode - Evict an xattr inode.
576 * @xattr_inum: xattr inode number
578 * When an inode that hosts xattrs is being removed we have to make sure
579 * that cached inodes of the xattrs also get removed from the inode cache
580 * otherwise we'd waste memory. This function looks up an inode from the
581 * inode cache and clears the link counter such that iput() will evict
582 * the inode.
586 struct inode *inode;
588 inode = ilookup(c->vfs_sb, xattr_inum);
589 if (inode) {
590 clear_nlink(inode);
591 iput(inode);
595 static int ubifs_xattr_remove(struct inode *host, const char *name)
597 struct inode *inode;
622 inode = iget_xattr(c, le64_to_cpu(xent->inum));
623 if (IS_ERR(inode)) {
624 err = PTR_ERR(inode);
628 ubifs_assert(c, inode->i_nlink == 1);
629 clear_nlink(inode);
630 err = remove_xattr(c, host, inode, &nm);
632 set_nlink(inode, 1);
634 /* If @i_nlink is 0, 'iput()' will delete the inode */
635 iput(inode);
644 static int init_xattrs(struct inode *inode, const struct xattr *xattr_array,
661 * creating a new inode without holding the inode rwsem,
662 * no need to check whether inode is locked.
664 err = ubifs_xattr_set(inode, name, xattr->value,
674 int ubifs_init_security(struct inode *dentry, struct inode *inode,
679 err = security_inode_init_security(inode, dentry, qstr,
683 ubifs_err(c, "cannot initialize security for inode %lu, error %d",
684 inode->i_ino, err);
691 struct dentry *dentry, struct inode *inode,
695 inode->i_ino, dentry, size);
698 return ubifs_xattr_get(inode, name, buffer, size);
703 struct dentry *dentry, struct inode *inode,
708 name, inode->i_ino, dentry, size);
713 return ubifs_xattr_set(inode, name, value, size, flags, true);
715 return ubifs_xattr_remove(inode, name);