summaryrefslogtreecommitdiff
path: root/innobase/fil
diff options
context:
space:
mode:
authorunknown <heikki@hundin.mysql.fi>2002-03-21 18:03:09 +0200
committerunknown <heikki@hundin.mysql.fi>2002-03-21 18:03:09 +0200
commitd3c0752b6aec6afef1f0dba85c9a0f1237843e6d (patch)
tree8484c3bb65d40af0743b44a24a788dc2d5cf7d48 /innobase/fil
parent838c6427b278a016f968338468761dabcfecba29 (diff)
downloadmariadb-git-d3c0752b6aec6afef1f0dba85c9a0f1237843e6d.tar.gz
Many files:
Merge InnoDB-3.23.50 innobase/btr/btr0btr.c: Merge InnoDB-3.23.50 innobase/btr/btr0cur.c: Merge InnoDB-3.23.50 innobase/btr/btr0sea.c: Merge InnoDB-3.23.50 innobase/buf/buf0buf.c: Merge InnoDB-3.23.50 innobase/buf/buf0flu.c: Merge InnoDB-3.23.50 innobase/dict/dict0dict.c: Merge InnoDB-3.23.50 innobase/dict/dict0load.c: Merge InnoDB-3.23.50 innobase/fil/fil0fil.c: Merge InnoDB-3.23.50 innobase/fsp/fsp0fsp.c: Merge InnoDB-3.23.50 innobase/include/buf0flu.h: Merge InnoDB-3.23.50 innobase/include/dict0dict.h: Merge InnoDB-3.23.50 innobase/include/fil0fil.h: Merge InnoDB-3.23.50 innobase/include/fsp0fsp.h: Merge InnoDB-3.23.50 innobase/include/log0log.h: Merge InnoDB-3.23.50 innobase/include/log0recv.h: Merge InnoDB-3.23.50 innobase/include/mem0mem.h: Merge InnoDB-3.23.50 innobase/include/os0file.h: Merge InnoDB-3.23.50 innobase/include/row0mysql.h: Merge InnoDB-3.23.50 innobase/include/srv0srv.h: Merge InnoDB-3.23.50 innobase/include/srv0start.h: Merge InnoDB-3.23.50 innobase/include/trx0sys.h: Merge InnoDB-3.23.50 innobase/include/ut0byte.h: Merge InnoDB-3.23.50 innobase/include/ut0rnd.h: Merge InnoDB-3.23.50 innobase/include/ut0ut.h: Merge InnoDB-3.23.50 innobase/log/log0log.c: Merge InnoDB-3.23.50 innobase/log/log0recv.c: Merge InnoDB-3.23.50 innobase/mem/mem0mem.c: Merge InnoDB-3.23.50 innobase/os/os0file.c: Merge InnoDB-3.23.50 innobase/rem/rem0cmp.c: Merge InnoDB-3.23.50 innobase/row/row0ins.c: Merge InnoDB-3.23.50 innobase/row/row0mysql.c: Merge InnoDB-3.23.50 innobase/row/row0sel.c: Merge InnoDB-3.23.50 innobase/row/row0upd.c: Merge InnoDB-3.23.50 innobase/srv/srv0srv.c: Merge InnoDB-3.23.50 innobase/srv/srv0start.c: Merge InnoDB-3.23.50 innobase/trx/trx0sys.c: Merge InnoDB-3.23.50 innobase/ut/ut0mem.c: Merge InnoDB-3.23.50 innobase/ut/ut0ut.c: Merge InnoDB-3.23.50 sql/ha_innobase.cc: Merge InnoDB-3.23.50 sql/ha_innobase.h: Merge InnoDB-3.23.50
Diffstat (limited to 'innobase/fil')
-rw-r--r--innobase/fil/fil0fil.c80
1 files changed, 75 insertions, 5 deletions
diff --git a/innobase/fil/fil0fil.c b/innobase/fil/fil0fil.c
index 138f1a78985..ca508785497 100644
--- a/innobase/fil/fil0fil.c
+++ b/innobase/fil/fil0fil.c
@@ -89,8 +89,8 @@ struct fil_node_struct {
char* name; /* the file name or path */
ibool open; /* TRUE if file open */
os_file_t handle; /* OS handle to the file, if file open */
- ulint size; /* size of the file in database blocks
- (where the possible last incomplete block
+ ulint size; /* size of the file in database pages
+ (where the possible last incomplete megabyte
is ignored) */
ulint n_pending;
/* count of pending i/o-ops on this file */
@@ -945,6 +945,76 @@ fil_node_complete_io(
}
}
+/**************************************************************************
+Tries to extend a data file by the number of pages given. Any fractions of a
+megabyte are ignored. */
+
+ibool
+fil_extend_last_data_file(
+/*======================*/
+ /* out: TRUE if success, also if we run
+ out of disk space we may return TRUE */
+ ulint* actual_increase,/* out: number of pages we were able to
+ extend, here the orginal size of the file and
+ the resulting size of the file are rounded
+ downwards to a full megabyte, and the
+ difference expressed in pages is returned */
+ ulint size_increase) /* in: try to extend this many pages */
+{
+ fil_node_t* node;
+ fil_space_t* space;
+ fil_system_t* system = fil_system;
+ byte* buf;
+ ibool success;
+ ulint i;
+
+ mutex_enter(&(system->mutex));
+
+ HASH_SEARCH(hash, system->spaces, 0, space, space->id == 0);
+
+ ut_a(space);
+
+ node = UT_LIST_GET_LAST(space->chain);
+
+ fil_node_prepare_for_io(node, system, space);
+
+ buf = mem_alloc(1024 * 1024);
+
+ memset(buf, '\0', 1024 * 1024);
+
+ for (i = 0; i < size_increase / ((1024 * 1024) / UNIV_PAGE_SIZE); i++) {
+
+ success = os_file_write(node->name, node->handle, buf,
+ (node->size << UNIV_PAGE_SIZE_SHIFT) & 0xFFFFFFFF,
+ node->size >> (32 - UNIV_PAGE_SIZE_SHIFT),
+ 1024 * 1024);
+
+ if (!success) {
+
+ break;
+ }
+
+ node->size += ((1024 * 1024) / UNIV_PAGE_SIZE);
+ space->size += ((1024 * 1024) / UNIV_PAGE_SIZE);
+
+ os_has_said_disk_full = FALSE;
+ }
+
+ mem_free(buf);
+
+ fil_node_complete_io(node, system, OS_FILE_WRITE);
+
+ mutex_exit(&(system->mutex));
+
+ *actual_increase = i * ((1024 * 1024) / UNIV_PAGE_SIZE);
+
+ fil_flush(0);
+
+ srv_data_file_sizes[srv_n_data_files - 1] += *actual_increase;
+
+ return(TRUE);
+}
+
/************************************************************************
Reads or writes data. This operation is asynchronous (aio). */
@@ -966,9 +1036,9 @@ fil_io(
ulint byte_offset, /* in: remainder of offset in bytes; in
aio this must be divisible by the OS block
size */
- ulint len, /* in: how many bytes to read; this must
- not cross a file boundary; in aio this must
- be a block size multiple */
+ ulint len, /* in: how many bytes to read or write; this
+ must not cross a file boundary; in aio this
+ must be a block size multiple */
void* buf, /* in/out: buffer where to store read data
or from where to write; in aio this must be
appropriately aligned */