]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/filestore/FileJournal: fail out if FileJournal is not block device or regular...
authorKefu Chai <kchai@redhat.com>
Tue, 20 Sep 2016 09:39:24 +0000 (17:39 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 20 Sep 2016 09:42:02 +0000 (17:42 +0800)
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 <kchai@redhat.com>
src/os/filestore/FileJournal.cc

index 4375a9731dabe4fec0e5f8cd8b9b48ebf87efc05..e9f53cf0a5a429abf98af76a6cc487e897acbdf4 100644 (file)
@@ -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;
 }