Skip to content
Snippets Groups Projects
Commit 66865621 authored by Yury Umanets's avatar Yury Umanets
Browse files

b=17194

r=adilger,tappro

- truncate last_rcvd for abort recovey case.
parent 02ef9cee
No related branches found
No related tags found
No related merge requests found
......@@ -110,6 +110,10 @@ int lustre_fread(struct file *file, void *buf, int len, loff_t *off);
int lustre_fwrite(struct file *file, const void *buf, int len, loff_t *off);
int lustre_fsync(struct file *file);
long l_readdir(struct file * file, struct list_head *dentry_list);
int l_notify_change(struct vfsmount *mnt, struct dentry *dchild,
struct iattr *newattrs);
int simple_truncate(struct dentry *dir, struct vfsmount *mnt,
char *name, loff_t length);
static inline void l_dput(struct dentry *de)
{
......
......@@ -473,6 +473,57 @@ long l_readdir(struct file *file, struct list_head *dentry_list)
}
EXPORT_SYMBOL(l_readdir);
int l_notify_change(struct vfsmount *mnt, struct dentry *dchild,
struct iattr *newattrs)
{
int rc;
LOCK_INODE_MUTEX(dchild->d_inode);
#ifdef HAVE_SECURITY_PLUG
rc = notify_change(dchild, mnt, newattrs);
#else
rc = notify_change(dchild, newattrs);
#endif
UNLOCK_INODE_MUTEX(dchild->d_inode);
return rc;
}
EXPORT_SYMBOL(l_notify_change);
/* utility to truncate a file */
int simple_truncate(struct dentry *dir, struct vfsmount *mnt,
char *name, loff_t length)
{
struct dentry *dchild;
struct iattr newattrs;
int err = 0;
ENTRY;
CDEBUG(D_INODE, "truncating file %.*s to %lld\n", (int)strlen(name),
name, (long long)length);
dchild = ll_lookup_one_len(name, dir, strlen(name));
if (IS_ERR(dchild))
GOTO(out, err = PTR_ERR(dchild));
if (dchild->d_inode) {
int old_mode = dchild->d_inode->i_mode;
if (S_ISDIR(old_mode)) {
CERROR("found %s (%lu/%u) is mode %o\n", name,
dchild->d_inode->i_ino,
dchild->d_inode->i_generation, old_mode);
GOTO(out_dput, err = -EISDIR);
}
newattrs.ia_size = length;
newattrs.ia_valid = ATTR_SIZE;
err = l_notify_change(mnt, dchild, &newattrs);
}
EXIT;
out_dput:
dput(dchild);
out:
return err;
}
EXPORT_SYMBOL(simple_truncate);
#ifdef LUSTRE_KERNEL_VERSION
#ifndef HAVE_CLEAR_RDONLY_ON_PUT
......
......@@ -1321,6 +1321,10 @@ static struct vfsmount *server_kernel_mount(struct super_block *sb)
GOTO(out_free, rc);
}
if (lmd->lmd_flags & LMD_FLG_ABORT_RECOV)
simple_truncate(mnt->mnt_sb->s_root, mnt, LAST_RCVD,
LR_CLIENT_START);
OBD_PAGE_FREE(__page);
lsi->lsi_ldd = ldd; /* freed at lsi cleanup */
CDEBUG(D_SUPER, "%s: mnt = %p\n", lmd->lmd_dev, mnt);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment