プロフィール

kosaki

Author:kosaki
連絡先はコチラ

ブログ検索
最近の記事
最近のコメント
最近のトラックバック
リンク
カテゴリー
月別アーカイブ
RSSフィード
FC2ブログランキング

スポンサーサイト このエントリーをはてなブックマークに追加

上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。


スポンサー広告 | 【--------(--) --:--:--】 | Trackback(-) | Comments(-)

ディレクトリ操作を asyncに行うのはもはやPOSIX non-comformance このエントリーをはてなブックマークに追加

Linuxでは伝統的にディレクトリ操作(ファイルのrenameとか)を asyncに行なってきた。これはBSDなどよりも性能がいい理由の一つだったんだけど、クラッシュした時にとんでもない壊れ方をするのでまあ色々と評判が悪かった。
さて、じゃあこのようなシステムで安全なアプリケーションを書くためにはどうすればいいかという話になるが、頭の良い人がディレクトリに対してfdatasyncすればいいじゃん。と言い出して、みんなそれがPOSIX filesystem のルールだと思ってたんだな。

で、今回、aio_fsync()がなぜか write permissionを要求してるので、ディレクトリにaio_fsync()できねーじゃねーか。という規格の不整合を上訴したひとがいて、議論の結果「ディレクトリに操作に対してfdatasync()を要求するようなasyncなファイルシステムはPOSIX準拠じゃない」という一文が規格書に追記されることになった。


ええええええーーーーー


いまさらかよ。
まあ、同時にnon-comforming filesystemでどうすればいいのかが追記されたので、今後は混乱は減っていく・・・のかなあ?


http://sourceware.org/ml/libc-alpha/2013-04/msg00578.html

Just to close this thread, Geoff Clare has summarized the changes regarding aio_fsync() and relationship wrt. directory entry data.



"In the April 18 teleconference it was agreed that the standard
should mandate that directory operations are always synchronized
on conforming file systems, and should include warnings about
non-conforming configurations. The proposed changes are as follows.

Changes to XBD...

At page 94 line 2581-2588 section 3.376 change:

For read, when the operation has been completed or diagnosed if
unsuccessful. The read is complete only when an image of the data
has been successfully transferred to the requesting process. If
there were any pending write requests affecting the data to be
read at the time that the synchronized read operation was
requested, these write requests are successfully transferred prior
to reading the data.

For write, when the operation has been completed or diagnosed if
unsuccessful. The write is complete only when the data specified
in the write request is successfully transferred and all file
system information required to retrieve the data is successfully
transferred.

to:

For read operations, when the operation has been completed or
diagnosed if unsuccessful. The operation is complete only when an
image of the data has been successfully transferred to the
requesting process. If there were any pending write requests or
(if the file is a directory) directory modifications affecting
the data to be read at the time that the synchronized read
operation was requested, these requests are successfully
transferred prior to reading the data.

For write operations and directory modification operations, when
the operation has been completed or diagnosed if unsuccessful. The
operation is complete only when the written data or (if the file
is a directory) modified directory entries have been successfully
transferred to storage and all file system information required
to retrieve them is successfully transferred.

At page 107 line 2859 add a new XBD 4.2 section (and renumber the
current 4.2 and all later 4.x sections):

4.2 Directory Operations

All file system operations that read a directory or that modify
the contents of a directory (for example creating, unlinking, or
renaming a file) shall be completed as defined for synchronized
I/O data integrity completion (see section 3.376).

Note: Although conforming file systems are required to
perform all directory modifications as synchronized I/O
operations, some file systems may support non-conforming
configurations (for example via mount options) where
directory modifications are not synchronized. Applications
that rely on directory modifications being synchronized should
only be used with such file systems in their conforming
configuration(s).


Changes to XSH...

At page 574 line 19833 section aio_fsync() change the APPLICATION
USAGE section from:

None.

to:

Refer to fdatasync() and fsync().

At page 815 line 27215 section fdatasync() append to the first
paragraph:

If the file is a directory, an implicit fdatasync() is already
performed on every I/O operation (see XBD 4.2) and consequently
if fdatasync() is called explicitly it shall take no action and
shall return the value 0.

At page 815 line 27232 section fdatasync() change the APPLICATION
USAGE section from:

None.

to:

Although conforming file systems are required to complete all
directory modifications as defined for synchronized I/O data
integrity completion, some file systems may support non-conforming
configurations (for example via mount options) where directory
modifications are not synchronized. When the file system is
configured in this way, calls to fdatasync() on directories may
cause I/O operations to be synchronized, rather than being a no-op.

At page 954 line 31987 section fsync() add a new paragraph to the
APPLICATION USAGE section:

Since conforming file systems are required to complete all
directory modifications as defined for synchronized I/O data
integrity completion (see XBD 4.2), calling fsync() on a directory
only synchronizes the file attributes such as timestamps. However,
some file systems may support non-conforming configurations (for
example via mount options) where modifications to directory
contents are not synchronized. When the file system is configured
in this way, calls to fsync() on directories may cause directory
contents to be synchronized in addition to file attributes.

Changes to XRAT...

At page 3444 line 115531 add a new XRAT A.4.2 section (and renumber
the current A.4.2 and all later A.4.x sections):

A.4.2 Directory Operations

Earlier versions of this standard did not make clear that all directory
modifications are performed as synchronized I/O operations, although
that is the historical behavior and was always intended. Applications
have no need to call fdatasync() or fsync() on a directory unless
they want to synchronize the file attributes (using fsync()), provided
the directory is on a conforming file system. However, since
applications may wish to use fdatasync() or fsync() to synchronize
directory modifications on non-conforming file systems, implementations
are required to support fdatasync() on directories as a no-op on
conforming file systems."

関連記事


linux | 【2013-04-23(Tue) 15:52:06】 | Trackback:(0) | Comments:(0)
  1. 無料アクセス解析
上記広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。