-
-/* this isn't where truncate starts. roughly:
- * sys_truncate->ll_setattr_raw->vmtruncate->ll_truncate
- * we grab the lock back in setattr_raw to avoid races. */
-static void llu_truncate(struct inode *inode)
-{
- struct llu_inode_info *lli = llu_i2info(inode);
- struct lov_stripe_md *lsm = lli->lli_smd;
- struct obdo oa = {0};
- int err;
- ENTRY;
- CDEBUG(D_VFSTRACE, "VFS Op:inode=%lu/%lu\n", lli->lli_st_ino,
- lli->lli_st_generation);
-
- if (!lsm) {
- CERROR("truncate on inode %lu with no objects\n", lli->lli_st_ino);
- EXIT;
- return;
- }
-
- oa.o_id = lsm->lsm_object_id;
- oa.o_valid = OBD_MD_FLID;
- obdo_from_inode(&oa, inode, OBD_MD_FLTYPE|OBD_MD_FLMODE|OBD_MD_FLATIME|
- OBD_MD_FLMTIME | OBD_MD_FLCTIME);
-
- CDEBUG(D_INFO, "calling punch for "LPX64" (all bytes after %Lu)\n",
- oa.o_id, lli->lli_st_size);
-
- /* truncate == punch from new size to absolute end of file */
- err = obd_punch(llu_i2dtexp(inode), &oa, lsm, lli->lli_st_size,
- OBD_OBJECT_EOF, NULL);
- if (err)
- CERROR("obd_truncate fails (%d) ino %lu\n", err, lli->lli_st_ino);
- else
- obdo_to_inode(inode, &oa, OBD_MD_FLSIZE | OBD_MD_FLBLOCKS |
- OBD_MD_FLATIME | OBD_MD_FLMTIME |
- OBD_MD_FLCTIME);
-
- EXIT;
- return;
-}
-
-int llu_vmtruncate(struct inode * inode, loff_t offset)
-{
- struct llu_inode_info *lli = llu_i2info(inode);
-
- lli->lli_st_size = offset;
-
- llu_truncate(inode);
-
- return 0;
-}