ENTRY;
oa = ll_i2info(inode)->lli_obdo;
-
+ if (!oa) {
+ /* object not yet allocated */
+ inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+ return;
+ }
CDEBUG(D_INFO, "calling punch for %ld (%Lu bytes at 0)\n",
(long)oa->o_id, (unsigned long long)oa->o_size);
- err = obd_punch(ll_i2obdconn(inode), oa, oa->o_size, 0);
-
+ oa->o_size = inode->i_size;
+ oa->o_valid = OBD_MD_FLSIZE;
+ err = obd_punch(ll_i2obdconn(inode), oa, 0, oa->o_size);
if (err)
CERROR("obd_truncate fails (%d)\n", err);
else
break;
case (IT_CREAT|IT_OPEN):
case IT_CREAT:
+ case IT_MKNOD:
it->it_mode = (it->it_mode | S_IFREG) & ~current->fs->umask;
break;
case IT_SYMLINK:
if (req->rq_reqmsg->bufcount > 1) {
void *handle;
struct inode *inode = de->d_inode;
- struct iattr iattr;
+ //struct iattr iattr;
struct obdo *obdo;
int rc;
obdo = lustre_msg_buf(req->rq_reqmsg, 1);
- iattr.ia_valid = ATTR_MODE;
- iattr.ia_mode = inode->i_mode;
+ //iattr.ia_valid = ATTR_MODE;
+ //iattr.ia_mode = inode->i_mode;
handle = mds_fs_start(mds, de->d_inode, MDS_FSOP_SETATTR);
if (!handle) {
/* XXX error handling */
rc = mds_fs_set_obdo(mds, inode, handle, obdo);
- rc = mds_fs_setattr(mds, de, handle, &iattr);
+ // rc = mds_fs_setattr(mds, de, handle, &iattr);
if (!rc)
rc = mds_update_last_rcvd(mds, handle, req);
else {
CDEBUG(D_INODE, "calling truncate for object #%Ld, valid = %x, "
"o_size = %Ld\n", oa->o_id, oa->o_valid, oa->o_size);
+ oa->o_valid = OBD_MD_FLSIZE;
error = filter_setattr(conn, oa);
oa->o_valid = OBD_MD_FLBLOCKS | OBD_MD_FLCTIME | OBD_MD_FLMTIME;
#!/bin/bash -x
-OST=2
-MDS=3
+OST=`../utils/obdctl name2dev OSCDEV`
+MDS=`../utils/obdctl name2dev MDCDEV`
mkdir /mnt/lustre/foo
mkdir /mnt/lustre/foo2
umount /mnt/lustre
mount -t lustre_lite -o ost=$OST,mds=$MDS none /mnt/lustre
-echo "ready debugger"
-read
-
echo foo >> /mnt/lustre/bar
cat /mnt/lustre/bar
cat /mnt/lustre/bar
-exit;
-
echo foo >> /mnt/lustre/iotest
echo bar >> /mnt/lustre/iotest
cat /mnt/lustre/iotest
umount /mnt/lustre
mount -t lustre_lite -o ost=$OST,mds=$MDS none /mnt/lustre
-cat /mnt/lustre/iotest
\ No newline at end of file
+echo "Testing truncation..."
+echo foo > /mnt/lustre/iotest
+echo bar >> /mnt/lustre/iotest
+cat /mnt/lustre/iotest
+echo "trucating to 3 bytes now..."
+./truncate /mnt/lustre/iotest 4
+cat /mnt/lustre/iotest
+
int err;
if (argc != 3) {
- printf("usage %s file offset (kilobytes)\n", argv[0]);
+ printf("usage %s file bytes\n", argv[0]);
return 1;
}
off = strtoul(argv[2], NULL, 0);
- off *= 1024;
err = truncate64(argv[1], off);
if ( err ) {
printf("Error truncating %s: %s\n", argv[1], strerror(errno));