mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
ext4: ->tmpfile() support
very similar to ext3 counterpart... Change-Id: Ia6d57ae72f19f17b3ea8dc3ebb5016aa4d7bda5d Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
3b63bffd0f
commit
2813fb51b6
1 changed files with 49 additions and 1 deletions
|
@ -1826,6 +1826,48 @@ retry:
|
|||
return err;
|
||||
}
|
||||
|
||||
static int ext4_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
|
||||
{
|
||||
handle_t *handle;
|
||||
struct inode *inode;
|
||||
int err, retries = 0;
|
||||
|
||||
dquot_initialize(dir);
|
||||
|
||||
retry:
|
||||
handle = ext4_journal_start(dir, EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +
|
||||
4 + EXT4_XATTR_TRANS_BLOCKS);
|
||||
|
||||
if (IS_ERR(handle))
|
||||
return PTR_ERR(handle);
|
||||
if (IS_DIRSYNC(dir))
|
||||
ext4_handle_sync(handle);
|
||||
|
||||
inode = ext4_new_inode(handle, dir, mode, NULL, 0, NULL);
|
||||
err = PTR_ERR(inode);
|
||||
if (!IS_ERR(inode)) {
|
||||
inode->i_op = &ext4_file_inode_operations;
|
||||
inode->i_fop = &ext4_file_operations;
|
||||
ext4_set_aops(inode);
|
||||
err = ext4_orphan_add(handle, inode);
|
||||
if (err)
|
||||
goto err_drop_inode;
|
||||
mark_inode_dirty(inode);
|
||||
d_tmpfile(dentry, inode);
|
||||
unlock_new_inode(inode);
|
||||
}
|
||||
if (handle)
|
||||
ext4_journal_stop(handle);
|
||||
if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries))
|
||||
goto retry;
|
||||
return err;
|
||||
err_drop_inode:
|
||||
ext4_journal_stop(handle);
|
||||
unlock_new_inode(inode);
|
||||
iput(inode);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int ext4_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
|
||||
{
|
||||
handle_t *handle;
|
||||
|
@ -2380,7 +2422,7 @@ static int ext4_link(struct dentry *old_dentry,
|
|||
|
||||
retry:
|
||||
handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
|
||||
EXT4_INDEX_EXTRA_TRANS_BLOCKS);
|
||||
EXT4_INDEX_EXTRA_TRANS_BLOCKS + 1);
|
||||
if (IS_ERR(handle))
|
||||
return PTR_ERR(handle);
|
||||
|
||||
|
@ -2394,6 +2436,11 @@ retry:
|
|||
err = ext4_add_entry(handle, dentry, inode);
|
||||
if (!err) {
|
||||
ext4_mark_inode_dirty(handle, inode);
|
||||
/* this can happen only for tmpfile being
|
||||
* linked the first time
|
||||
*/
|
||||
if (inode->i_nlink == 1)
|
||||
ext4_orphan_del(handle, inode);
|
||||
d_instantiate(dentry, inode);
|
||||
} else {
|
||||
drop_nlink(inode);
|
||||
|
@ -2610,6 +2657,7 @@ const struct inode_operations ext4_dir_inode_operations = {
|
|||
.mkdir = ext4_mkdir,
|
||||
.rmdir = ext4_rmdir,
|
||||
.mknod = ext4_mknod,
|
||||
.tmpfile = ext4_tmpfile,
|
||||
.rename = ext4_rename,
|
||||
.setattr = ext4_setattr,
|
||||
#ifdef CONFIG_EXT4_FS_XATTR
|
||||
|
|
Loading…
Reference in a new issue