[완료] Filesystem에서 file 이름을 원자적으로 교환하는 기법이 있나요?

winner의 이미지

보통 file을 활용하여 transaction 작업을 한다면 기존 file을 복사하여 임시작업 file을 만들고, 임시작업 file 을 변경한 후 문제없이 완료가 된다면 임시작업 file을 원래 file로 전환해야 할 것 같은데요. 마지막 작업에서 원자적인 동작방식을 filesystem에서 지원하는지 궁금합니다.
Windows의 경우 file을 삭제하고, 바로 동일한 file 이름의 file이 생성되면 삭제된 file과 동일한 생성시간을 가졌던 것으로 기억하는데요. 앞의 file 명 변경에 대한 원자적 동작을 유사하게 지원하기 위해서 이런 형태로 동작하는 것 같다는 글을 읽었던 적이 있습니다. 하지만 이걸 모르면 사용자에게 혼란을 주더군요. 일반적인 사용자가 문제될 일은 없겠습니다만 programmer가 file 생성시간을 보고, update 동작을 구현하였을 경우 난감한 경우에 마주칠 수가 있습니다. Updater의 동작을 조사하다가 Daum PotPlater가 아마 file 변경시간을 조사했던 기억이 납니다.

이런 형태의 작업은 많이 있을 것 같은데 이론적으로 최대한 무결성을 보장하는 방식이 있지 않을까 생각해봅니다.

익명 사용자의 이미지

윈도에서 파일을 삭제하고 같은 폴더에서 얼마 후(3분 내) 같은 이름으로 파일을 다시 생성하게되면 동일한 타임스탬프를 같는 것은 맞지만 그게 원자적 동작을 유사하게 하기 위한 것은 아닙니다.

레이몬드 첸의 블로그에 이유가 잘 설명되어 있습니다.
http://blogs.msdn.com/b/oldnewthing/archive/2005/07/15/439261.aspx

비스타 이후 탑재되어 있는 NTFS에서는 transacted operation을 지원합니다.
저는 사용해본 적은 없지만 아래 문서와 관련 문서들을 읽어보시면 도움이 될지도 모르겠습니다.
http://msdn.microsoft.com/en-us/library/aa365241(v=vs.85).aspx

winner의 이미지

원래는 긴 파일명과 DOS의 8.3 파일명의 호환성을 위해서 만들어졌다는 이야기군요.
통상 이 현상을 이야기하면서 Word와 timestamp를 이야기하는데 실제로 Word의 동작은 Command pattern의 연속일지도 모르겠군요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.