Hi, Vladislav! On Mar 29, Vladislav Vaintroub wrote:
------------------------------------------------------------ revno: 3712 revision-id: wlad@montyprogram.com-20130328203348-1qe9u9nlq6ol9b8l parent: igor@askmonty.org-20130329021836-x6swah73a59im9tn fixes bug: https://mariadb.atlassian.net/browse/MDEV-4338 committer: Vladislav Vaintroub <wlad@montyprogram.com> branch nick: 5.5 timestamp: Thu 2013-03-28 21:33:48 +0100 message: MDEV-4338 : Support atomic option on directFS/FusionIO.
=== modified file 'storage/xtradb/handler/ha_innodb.cc' --- a/storage/xtradb/handler/ha_innodb.cc 2013-03-08 18:08:45 +0000 +++ b/storage/xtradb/handler/ha_innodb.cc 2013-03-28 20:33:48 +0000 @@ -185,6 +185,7 @@ static my_bool innobase_file_format_chec static my_bool innobase_log_archive = FALSE; static char* innobase_log_arch_dir = NULL; #endif /* UNIV_LOG_ARCHIVE */ +static my_bool innobase_use_atomic_writes = TRUE; static my_bool innobase_use_doublewrite = TRUE; static my_bool innobase_use_checksums = TRUE; static my_bool innobase_fast_checksum = FALSE; @@ -3057,6 +3058,35 @@ innobase_init( srv_kill_idle_transaction = 0; #endif
+ srv_use_atomic_writes = (ibool) innobase_use_atomic_writes;
Is that the typical usage pattern in the innodb code? Because it looks a bit silly to me, why couldn't you create a sysvar directly on srv_use_atomic_writes, why an intermediate innobase_use_atomic_writes variable?
+ if (innobase_use_atomic_writes) { + fprintf(stderr, "InnoDB: using atomic writes.\n"); + + /* Force doublewrite buffer off, atomic writes replace it. */ + if (srv_use_doublewrite_buf) { + fprintf(stderr, "InnoDB: Switching off doublewrite buffer " + "because of atomic writes.\n"); + innobase_use_doublewrite = srv_use_doublewrite_buf = FALSE; + } + + /* Force O_DIRECT on Unixes (on Windows writes are always unbuffered)*/ +#ifndef _WIN32 + if(!innobase_file_flush_method || + !strstr(innobase_file_flush_method, "O_DIRECT")) { + innobase_file_flush_method = + srv_file_flush_method_str = (char*)"O_DIRECT"; + fprintf(stderr, "InnoDB: using O_DIRECT due to atomic writes.\n"); + } +#endif +#ifdef HAVE_POSIX_FALLOCATE + /* Due to a bug in directFS, using atomics needs + * posix_fallocate to extend the file + * pwrite() past end of the file won't work + */ + srv_use_posix_fallocate = TRUE; +#endif + }
it'd be nice if you could try os_file_set_atomic_writes() here to see if that works. This function creates and opens quite a few files, you could use one of them to mark it for atomic writes, and if that would fail, you'd disable atomic writes, and wouldn't change innobase_file_flush_method and innobase_use_doublewrite. Btw, why not to use posix_fallocate whenever it's available? Or, at least, with its own --innodb-use-fallocate option? Regards, Sergei