From efe42792b363e97dd5ccb74be1abac2d4e79ca9e Mon Sep 17 00:00:00 2001 From: Mayank Prasad Date: Thu, 24 May 2012 23:00:32 +0530 Subject: Bug#13417440 : 63340: ARCHIVE FILE IO NOT INSTRUMENTED Details: - Archive storage engine file access were not instrumented and thus were not shown in PS tables. Fix: - Added instrumentation code by using PS Apis for I/O. --- storage/archive/azio.c | 25 +++++++++++++++---------- storage/archive/ha_archive.cc | 25 +++++++++++++++++++------ 2 files changed, 34 insertions(+), 16 deletions(-) (limited to 'storage/archive') diff --git a/storage/archive/azio.c b/storage/archive/azio.c index 5fc9bc875f8..ec4b5bcb7cd 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -37,6 +37,8 @@ void putLong(File file, uLong x); uLong getLong(azio_stream *s); void read_header(azio_stream *s, unsigned char *buffer); +extern PSI_file_key arch_key_file_data; + /* =========================================================================== Opens a gzip (.gz) file for reading or writing. The mode parameter is as in fopen ("rb" or "wb"). The file is given either by file descriptor @@ -113,7 +115,7 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd) s->stream.avail_out = AZ_BUFSIZE_WRITE; errno = 0; - s->file = fd < 0 ? my_open(path, Flags, MYF(0)) : fd; + s->file = fd < 0 ? mysql_file_open(arch_key_file_data, path, Flags, MYF(0)) : fd; DBUG_EXECUTE_IF("simulate_archive_open_failure", { if (s->file >= 0) @@ -235,8 +237,8 @@ int get_byte(s) if (s->stream.avail_in == 0) { errno = 0; - s->stream.avail_in= (uInt) my_read(s->file, (uchar *)s->inbuf, - AZ_BUFSIZE_READ, MYF(0)); + s->stream.avail_in= (uInt) mysql_file_read(s->file, (uchar *)s->inbuf, + AZ_BUFSIZE_READ, MYF(0)); if (s->stream.avail_in == 0) { s->z_eof = 1; @@ -277,7 +279,8 @@ void check_header(azio_stream *s) if (len < 2) { if (len) s->inbuf[0] = s->stream.next_in[0]; errno = 0; - len = (uInt)my_read(s->file, (uchar *)s->inbuf + len, AZ_BUFSIZE_READ >> len, MYF(0)); + len = (uInt)mysql_file_read(s->file, (uchar *)s->inbuf + len, + AZ_BUFSIZE_READ >> len, MYF(0)); if (len == (uInt)-1) s->z_err = Z_ERRNO; s->stream.avail_in += len; s->stream.next_in = s->inbuf; @@ -468,7 +471,8 @@ unsigned int ZEXPORT azread ( azio_stream *s, voidp buf, size_t len, int *error) if (s->stream.avail_out > 0) { s->stream.avail_out -= - (uInt)my_read(s->file, (uchar *)next_out, s->stream.avail_out, MYF(0)); + (uInt)mysql_file_read(s->file, (uchar *)next_out, + s->stream.avail_out, MYF(0)); } len -= s->stream.avail_out; s->in += len; @@ -481,7 +485,8 @@ unsigned int ZEXPORT azread ( azio_stream *s, voidp buf, size_t len, int *error) if (s->stream.avail_in == 0 && !s->z_eof) { errno = 0; - s->stream.avail_in = (uInt)my_read(s->file, (uchar *)s->inbuf, AZ_BUFSIZE_READ, MYF(0)); + s->stream.avail_in = (uInt)mysql_file_read(s->file, (uchar *)s->inbuf, + AZ_BUFSIZE_READ, MYF(0)); if (s->stream.avail_in == 0) { s->z_eof = 1; @@ -548,8 +553,8 @@ unsigned int azwrite (azio_stream *s, const voidp buf, unsigned int len) { s->stream.next_out = s->outbuf; - if (my_write(s->file, (uchar *)s->outbuf, AZ_BUFSIZE_WRITE, - MYF(0)) != AZ_BUFSIZE_WRITE) + if (mysql_file_write(s->file, (uchar *)s->outbuf, AZ_BUFSIZE_WRITE, + MYF(0)) != AZ_BUFSIZE_WRITE) { s->z_err = Z_ERRNO; break; @@ -596,7 +601,7 @@ int do_flush (azio_stream *s, int flush) if (len != 0) { s->check_point= my_tell(s->file, MYF(0)); - if ((uInt)my_write(s->file, (uchar *)s->outbuf, len, MYF(0)) != len) + if ((uInt)mysql_file_write(s->file, (uchar *)s->outbuf, len, MYF(0)) != len) { s->z_err = Z_ERRNO; return Z_ERRNO; @@ -783,7 +788,7 @@ void putLong (File file, uLong x) for (n = 0; n < 4; n++) { buffer[0]= (int)(x & 0xff); - my_write(file, buffer, 1, MYF(0)); + mysql_file_write(file, buffer, 1, MYF(0)); x >>= 8; } } diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index d040d694e1f..dba647b8d1a 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -114,6 +114,8 @@ static HASH archive_open_tables; #define DATA_BUFFER_SIZE 2 // Size of the data used in the data file #define ARCHIVE_CHECK_HEADER 254 // The number we use to determine corruption +extern "C" PSI_file_key arch_key_file_data; + /* Static declarations for handerton */ static handler *archive_create_handler(handlerton *hton, TABLE_SHARE *table, @@ -159,6 +161,14 @@ static PSI_mutex_info all_archive_mutexes[]= { &az_key_mutex_ARCHIVE_SHARE_mutex, "ARCHIVE_SHARE::mutex", 0} }; +PSI_file_key arch_key_file_metadata, arch_key_file_data, arch_key_file_frm; +static PSI_file_info all_archive_files[]= +{ + { &arch_key_file_metadata, "metadata", 0}, + { &arch_key_file_data, "data", 0}, + { &arch_key_file_frm, "FRM", 0} +}; + static void init_archive_psi_keys(void) { const char* category= "archive"; @@ -169,6 +179,9 @@ static void init_archive_psi_keys(void) count= array_elements(all_archive_mutexes); PSI_server->register_mutex(category, all_archive_mutexes, count); + + count= array_elements(all_archive_files); + PSI_server->register_file(category, all_archive_files, count); } #endif /* HAVE_PSI_INTERFACE */ @@ -262,7 +275,7 @@ int archive_discover(handlerton *hton, THD* thd, const char *db, build_table_filename(az_file, sizeof(az_file) - 1, db, name, ARZ, 0); - if (!(my_stat(az_file, &file_stat, MYF(0)))) + if (!(mysql_file_stat(arch_key_file_data, az_file, &file_stat, MYF(0)))) goto err; if (!(azopen(&frm_stream, az_file, O_RDONLY|O_BINARY))) @@ -712,7 +725,7 @@ int ha_archive::create(const char *name, TABLE *table_arg, There is a chance that the file was "discovered". In this case just use whatever file is there. */ - if (!(my_stat(name_buff, &file_stat, MYF(0)))) + if (!(mysql_file_stat(arch_key_file_data, name_buff, &file_stat, MYF(0)))) { my_errno= 0; if (!(azopen(&create_stream, name_buff, O_CREAT|O_RDWR|O_BINARY))) @@ -729,19 +742,19 @@ int ha_archive::create(const char *name, TABLE *table_arg, /* Here is where we open up the frm and pass it to archive to store */ - if ((frm_file= my_open(name_buff, O_RDONLY, MYF(0))) > 0) + if ((frm_file= mysql_file_open(arch_key_file_frm, name_buff, O_RDONLY, MYF(0))) >= 0) { if (!mysql_file_fstat(frm_file, &file_stat, MYF(MY_WME))) { frm_ptr= (uchar *)my_malloc(sizeof(uchar) * file_stat.st_size, MYF(0)); if (frm_ptr) { - my_read(frm_file, frm_ptr, file_stat.st_size, MYF(0)); + mysql_file_read(frm_file, frm_ptr, file_stat.st_size, MYF(0)); azwrite_frm(&create_stream, (char *)frm_ptr, file_stat.st_size); my_free(frm_ptr); } } - my_close(frm_file, MYF(0)); + mysql_file_close(frm_file, MYF(0)); } if (create_info->comment.str) @@ -1607,7 +1620,7 @@ int ha_archive::info(uint flag) { MY_STAT file_stat; // Stat information for the data file - (void) my_stat(share->data_file_name, &file_stat, MYF(MY_WME)); + (void) mysql_file_stat(arch_key_file_data, share->data_file_name, &file_stat, MYF(MY_WME)); if (flag & HA_STATUS_TIME) stats.update_time= (ulong) file_stat.st_mtime; -- cgit v1.2.1 From cf48fcfba33c3c48aa52290a33a7b825e89827c2 Mon Sep 17 00:00:00 2001 From: Marc Alff Date: Thu, 31 May 2012 11:47:13 +0200 Subject: Bug 14116252 - CANNOT BUILD ARCHIVE ENGINE WHEN WITH_PERFSCHEMA_STORAGE_ENGINE=0 Fixed a build break with compiling without the performance schema, instrumentation should be protected by HAVE_PSI_INTERFACE --- storage/archive/azio.c | 2 ++ storage/archive/ha_archive.cc | 2 ++ 2 files changed, 4 insertions(+) (limited to 'storage/archive') diff --git a/storage/archive/azio.c b/storage/archive/azio.c index ec4b5bcb7cd..15b3434ab32 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -37,7 +37,9 @@ void putLong(File file, uLong x); uLong getLong(azio_stream *s); void read_header(azio_stream *s, unsigned char *buffer); +#ifdef HAVE_PSI_INTERFACE extern PSI_file_key arch_key_file_data; +#endif /* =========================================================================== Opens a gzip (.gz) file for reading or writing. The mode parameter diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index dba647b8d1a..24dbaefce27 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -114,7 +114,9 @@ static HASH archive_open_tables; #define DATA_BUFFER_SIZE 2 // Size of the data used in the data file #define ARCHIVE_CHECK_HEADER 254 // The number we use to determine corruption +#ifdef HAVE_PSI_INTERFACE extern "C" PSI_file_key arch_key_file_data; +#endif /* Static declarations for handerton */ static handler *archive_create_handler(handlerton *hton, -- cgit v1.2.1