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: v10.2.4~47^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5ae4f316b2cf37ce5d13b1ced4b65962c5583882;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 (cherry picked from commit 7431eec6fd24cd08ca6c76a9893e3f6e8c63a916) --- diff --git a/src/os/filestore/FileJournal.cc b/src/os/filestore/FileJournal.cc index 9e403101c35b..4391a2e0cc0c 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) @@ -127,6 +131,7 @@ int FileJournal::_open(bool forwrite, bool create) out_fd: VOID_TEMP_FAILURE_RETRY(::close(fd)); + fd = -1; return ret; }