lkml.org 
[lkml]   [2012]   [Oct]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH 08/16 v2] f2fs: add file operations
Date
> > +void f2fs_truncate(struct inode *inode)
> > +{
> > + if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
> > + S_ISLNK(inode->i_mode)))
> > + return;
> > +
> > + if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
> > + return;
>
> No truncate for an append only file? You call f2fs_truncate from
> evict_inode, so no block freeing when this kind of inode is deleted.

Agreed.

>
> > +
> > + if (!truncate_blocks(inode, i_size_read(inode))) {
> > + inode->i_mtime = inode->i_ctime = CURRENT_TIME;
> > + mark_inode_dirty(inode);
> > + }
> > +
> > + f2fs_balance_fs(F2FS_SB(inode->i_sb));
> > +}
> > +
> > +static int f2fs_getattr(struct vfsmount *mnt,
> > + struct dentry *dentry, struct kstat *stat)
> > +{
> > + struct inode *inode = dentry->d_inode;
> > + generic_fillattr(inode, stat);
> > + stat->blocks <<= 3;
> > + return 0;
> > +}
> > +
> > +#ifdef CONFIG_F2FS_FS_POSIX_ACL
> > +static void __setattr_copy(struct inode *inode, const struct iattr *attr)
> > +{
> > + struct f2fs_inode_info *fi = F2FS_I(inode);
> > + unsigned int ia_valid = attr->ia_valid;
> > +
> > + if (ia_valid & ATTR_UID)
> > + inode->i_uid = attr->ia_uid;
> > + if (ia_valid & ATTR_GID)
> > + inode->i_gid = attr->ia_gid;
> > + if (ia_valid & ATTR_ATIME)
> > + inode->i_atime = timespec_trunc(attr->ia_atime,
> > + inode->i_sb->s_time_gran);
> > + if (ia_valid & ATTR_MTIME)
> > + inode->i_mtime = timespec_trunc(attr->ia_mtime,
> > + inode->i_sb->s_time_gran);
> > + if (ia_valid & ATTR_CTIME)
> > + inode->i_ctime = timespec_trunc(attr->ia_ctime,
> > + inode->i_sb->s_time_gran);
> > + if (ia_valid & ATTR_MODE) {
> > + umode_t mode = attr->ia_mode;
> > +
> > + if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
> > + mode &= ~S_ISGID;
> > + set_acl_inode(fi, mode);
> > + }
> > +}
> > +#else
> > +#define __setattr_copy setattr_copy
> > +#endif
> > +
> > +int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
> > +{
> > + struct inode *inode = dentry->d_inode;
> > + struct f2fs_inode_info *fi = F2FS_I(inode);
> > + int err;
> > +
> > + err = inode_change_ok(inode, attr);
> > + if (err)
> > + return err;
> > +
> > + if ((attr->ia_valid & ATTR_SIZE) &&
> > + attr->ia_size != i_size_read(inode)) {
> > + truncate_setsize(inode, attr->ia_size);
> > + f2fs_truncate(inode);
>
> No need to call truncate_pagecache & co.?

truncate_setsize() calls truncate_pagecache().
Any comment?

>
> Marco



---
Jaegeuk Kim
Samsung



\
 
 \ /
  Last update: 2012-10-23 10:21    [W:0.069 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site