List:Commits« Previous MessageNext Message »
From:Marc Alff Date:March 22 2010 12:48pm
Subject:bzr push into mysql-next-mr-bugfixing branch (marc.alff:3137 to 3139)
View as plain text  
 3139 Marc Alff	2010-03-22
      Code review comments

    modified:
      storage/perfschema/pfs_instr.cc
 3138 Marc Alff	2010-03-22
      Bug#52134 performance schema file io, symlink in path
      
      Before this fix, a file named "/path/with/link/to/filename"
      would be normalized to:
      - "/path/with/link/to/filename" when the file did not exist (creation),
      - "/real/path/to/filename" when the file did exist (file io, deletion),
      causing instrumentation leak for file io in the performance schema.
      
      With this fix, file name normalization has been revisited to be more robust,
      and always resolve this case to "/real/path/to/filename".
      
      File instrumentation now works properly, even when a symbolic link
      is present in the directory name, which is the case when running tests
      with MTR_MEM=1, where the var directory is a link to shared memory.

    modified:
      mysql-test/suite/perfschema/t/misc.test
      storage/perfschema/pfs_instr.cc
 3137 Jack Andrews	2010-03-22
      Bug #51861  	my_rename on windows: check that "from" exists

    modified:
      mysys/my_rename.c
=== modified file 'mysql-test/suite/perfschema/t/misc.test'
--- a/mysql-test/suite/perfschema/t/misc.test	2010-03-16 14:19:45 +0000
+++ b/mysql-test/suite/perfschema/t/misc.test	2010-03-22 09:08:28 +0000
@@ -18,7 +18,6 @@
 
 --source include/not_embedded.inc
 --source include/have_perfschema.inc
---source include/not_var_link.inc
 
 #
 # Bug#45496 Performance schema: assertion fails in

=== modified file 'storage/perfschema/pfs_instr.cc'
--- a/storage/perfschema/pfs_instr.cc	2010-03-05 01:36:54 +0000
+++ b/storage/perfschema/pfs_instr.cc	2010-03-22 12:48:18 +0000
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008-2009 Sun Microsystems, Inc
+/* Copyright (c) 2008, 2010 Oracle and/or its affiliates. All rights reserved.
 
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -770,16 +770,55 @@ find_or_create_file(PFS_thread *thread, 
     Normalize the file name to avoid duplicates when using aliases:
     - absolute or relative paths
     - symbolic links
+    Names are resolved as follows:
+    - /real/path/to/real_file ==> same
+    - /path/with/link/to/real_file ==> /real/path/to/real_file
+    - real_file ==> /real/path/to/real_file
+    - ./real_file ==> /real/path/to/real_file
+    - /real/path/to/sym_link ==> same
+    - /path/with/link/to/sym_link ==> /real/path/to/sym_link
+    - sym_link ==> /real/path/to/sym_link
+    - ./sym_link ==> /real/path/to/sym_link
+    When the last component of a file is a symbolic link,
+    the last component is *not* resolved, so that all file io
+    operations on a link (create, read, write, delete) are counted
+    against the link itself, not the target file.
+    Resolving the name would lead to create counted against the link,
+    and read/write/delete counted against the target, leading to
+    incoherent results and instrumentation leaks.
+    Also note that, when creating files, this name resolution
+    works properly for files that do not exist (yet) on the file system.
   */
   char buffer[FN_REFLEN];
+  char dirbuffer[FN_REFLEN];
+  size_t dirlen;
   const char *normalized_filename;
   int normalized_length;
 
-  /*
-    Ignore errors, the file may not exist.
-    my_realpath always provide a best effort result in buffer.
-  */
-  (void) my_realpath(buffer, safe_filename, MYF(0));
+  dirlen= dirname_length(safe_filename);
+  if (dirlen == 0)
+  {
+    dirbuffer[0]= FN_CURLIB;
+    dirbuffer[1]= FN_LIBCHAR;
+    dirbuffer[2]= '\0';
+  }
+  else
+  {
+    memcpy(dirbuffer, safe_filename, dirlen);
+    dirbuffer[dirlen]= '\0';
+  }
+
+  if (my_realpath(buffer, dirbuffer, MYF(0)) != 0)
+  {
+    file_lost++;
+    return NULL;
+  }
+
+  /* Append the unresolved file name to the resolved path */
+  char *ptr= buffer + strlen(buffer);
+  *ptr++= FN_LIBCHAR;
+  ptr= strmov(ptr, safe_filename + dirlen);
+  *ptr= '\0';
 
   normalized_filename= buffer;
   normalized_length= strlen(normalized_filename);


Attachment: [text/bzr-bundle] bzr/marc.alff@oracle.com-20100322124818-30y3hnrzlxhkus2l.bundle
Thread
bzr push into mysql-next-mr-bugfixing branch (marc.alff:3137 to 3139)Marc Alff22 Mar