From: Kefu Chai Date: Tue, 20 Sep 2016 09:39:24 +0000 (+0800) Subject: os/filestore/FileJournal: fail out if FileJournal is not block device or regular... X-Git-Tag: v11.0.1~153^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F11146%2Fhead;p=ceph.git os/filestore/FileJournal: fail out if FileJournal is not block device or regular file otherwise JournalingFileStore will assert when deleting FileJournal which still has the non block/regular file opened. Fixes: http://tracker.ceph.com/issues/17307 Signed-off-by: Kefu Chai --- diff --git a/src/os/filestore/FileJournal.cc b/src/os/filestore/FileJournal.cc index 4375a9731da..e9f53cf0a5a 100644 --- a/src/os/filestore/FileJournal.cc +++ b/src/os/filestore/FileJournal.cc @@ -89,13 +89,17 @@ int FileJournal::_open(bool forwrite, bool create) if (S_ISBLK(st.st_mode)) { ret = _open_block_device(); - } else { + } else if (S_ISREG(st.st_mode)) { if (aio && !force_aio) { derr << "FileJournal::_open: disabling aio for non-block journal. Use " << "journal_force_aio to force use of aio anyway" << dendl; aio = false; } ret = _open_file(st.st_size, st.st_blksize, create); + } else { + derr << "FileJournal::_open: wrong journal file type: " << st.st_mode + << dendl; + ret = -EINVAL; } if (ret) @@ -134,6 +138,7 @@ int FileJournal::_open(bool forwrite, bool create) out_fd: VOID_TEMP_FAILURE_RETRY(::close(fd)); + fd = -1; return ret; }