/*
- * $Id: aiops.cc,v 1.1 2000/05/03 17:15:46 adrian Exp $
+ * $Id: aiops.cc,v 1.2 2000/06/27 08:33:53 hno Exp $
*
* DEBUG: section 43 AIOPS
* AUTHOR: Stewart Forster <slf@connect.com.au>
_AIO_OP_WRITE,
_AIO_OP_CLOSE,
_AIO_OP_UNLINK,
+ _AIO_OP_TRUNCATE,
_AIO_OP_OPENDIR,
_AIO_OP_STAT
};
int aio_write(int, char *, int, off_t, int, aio_result_t *);
int aio_close(int, aio_result_t *);
int aio_unlink(const char *, aio_result_t *);
+int aio_truncate(const char *, off_t length, aio_result_t *);
int aio_opendir(const char *, aio_result_t *);
aio_result_t *aio_poll_done();
int aio_sync(void);
static void aio_do_close(aio_request_t *);
static void aio_do_stat(aio_request_t *);
static void aio_do_unlink(aio_request_t *);
+static void aio_do_truncate(aio_request_t *);
#if AIO_OPENDIR
static void *aio_do_opendir(aio_request_t *);
#endif
case _AIO_OP_UNLINK:
aio_do_unlink(request);
break;
+ case _AIO_OP_TRUNCATE:
+ aio_do_truncate(request);
+ break;
#if AIO_OPENDIR /* Opendir not implemented yet */
case _AIO_OP_OPENDIR:
aio_do_opendir(request);
case _AIO_OP_UNLINK:
debug(43, 3) ("aio_queue_request: %d : unlink -> %s\n", i, rp->path);
break;
+ case _AIO_OP_TRUNCATE:
+ debug(43, 3) ("aio_queue_request: %d : truncate -> %s\n", i, rp->path);
+ break;
case _AIO_OP_STAT:
debug(43, 3) ("aio_queue_request: %d : stat -> %s\n", i, rp->path);
break;
close(requestp->fd);
break;
case _AIO_OP_UNLINK:
+ case _AIO_OP_TRUNCATE:
case _AIO_OP_OPENDIR:
xfree(requestp->path);
break;
requestp->err = errno;
}
+int
+aio_truncate(const char *path, off_t length, aio_result_t * resultp)
+{
+ aio_request_t *requestp;
+ int len;
+
+ if (!aio_initialised)
+ aio_init();
+ if ((requestp = memPoolAlloc(aio_request_pool)) == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+ len = strlen(path) + 1;
+ if ((requestp->path = (char *) xmalloc(len)) == NULL) {
+ memPoolFree(aio_request_pool, requestp);
+ errno = ENOMEM;
+ return -1;
+ }
+ requestp->offset = length;
+ strncpy(requestp->path, path, len);
+ requestp->resultp = resultp;
+ requestp->request_type = _AIO_OP_TRUNCATE;
+ requestp->cancelled = 0;
+
+ aio_do_request(requestp);
+ return 0;
+}
+
+
+static void
+aio_do_truncate(aio_request_t * requestp)
+{
+ requestp->ret = truncate(requestp->path, requestp->offset);
+ requestp->err = errno;
+}
+
#if AIO_OPENDIR
/* XXX aio_opendir NOT implemented? */
case _AIO_OP_UNLINK:
debug(43, 5) ("UNLINK of %s\n", requestp->path);
break;
+ case _AIO_OP_TRUNCATE:
+ debug(43, 5) ("UNLINK of %s\n", requestp->path);
+ break;
default:
break;
}
/*
- * $Id: async_io.cc,v 1.4 2000/06/08 18:05:37 hno Exp $
+ * $Id: async_io.cc,v 1.5 2000/06/27 08:33:53 hno Exp $
*
* DEBUG: section 32 Asynchronous Disk I/O
* AUTHOR: Pete Bentley <pete@demon.net>
#define _AIO_WRITE 2
#define _AIO_CLOSE 3
#define _AIO_UNLINK 4
+#define _AIO_TRUNCATE 4
#define _AIO_OPENDIR 5
#define _AIO_STAT 6
xfree(path);
} /* aioUnlink */
+void
+aioTruncate(const char *pathname, off_t length, AIOCB * callback, void *callback_data)
+{
+ aio_ctrl_t *ctrlp;
+ char *path;
+ assert(initialised);
+ aio_counts.unlink++;
+ ctrlp = memPoolAlloc(aio_ctrl_pool);
+ ctrlp->fd = -2;
+ ctrlp->done_handler = callback;
+ ctrlp->done_handler_data = callback_data;
+ ctrlp->operation = _AIO_TRUNCATE;
+ path = xstrdup(pathname);
+ cbdataLock(callback_data);
+ if (aio_truncate(path, length, &ctrlp->result) < 0) {
+ int ret = truncate(path, length);
+ if (callback)
+ (callback) (ctrlp->fd, callback_data, ret, errno);
+ cbdataUnlock(callback_data);
+ memPoolFree(aio_ctrl_pool, ctrlp);
+ xfree(path);
+ return;
+ }
+ ctrlp->next = used_list;
+ used_list = ctrlp;
+ xfree(path);
+} /* aioTruncate */
+
int
aioCheckCallbacks(SwapDir * SD)
int aio_close(int, aio_result_t *);
int aio_stat(const char *, struct stat *, aio_result_t *);
int aio_unlink(const char *, aio_result_t *);
+int aio_truncate(const char *, off_t length, aio_result_t *);
int aio_opendir(const char *, aio_result_t *);
aio_result_t *aio_poll_done(void);
int aio_operations_pending(void);
void aioRead(int, int offset, char *, int size, AIOCB *, void *);
void aioStat(char *, struct stat *, AIOCB *, void *);
void aioUnlink(const char *, AIOCB *, void *);
+void aioTruncate(const char *, off_t length, AIOCB *, void *);
int aioCheckCallbacks(SwapDir *);
void aioSync(SwapDir *);
int aioQueueSize(void);
/*
- * $Id: store_dir_aufs.cc,v 1.5 2000/06/26 03:36:13 wessels Exp $
+ * $Id: store_dir_aufs.cc,v 1.6 2000/06/27 08:33:53 hno Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
{
debug(79, 3) ("storeAufsDirUnlinkFile: unlinking fileno %08X\n", f);
/* storeAufsDirMapBitReset(SD, f); */
+#if USE_TRUNCATE_NOT_UNLINK
+ aioTruncate(storeAufsDirFullPath(SD, f, NULL), NULL, NULL);
+#else
aioUnlink(storeAufsDirFullPath(SD, f, NULL), NULL, NULL);
+#endif
}
/*