aboutsummaryrefslogtreecommitdiffstats
path: root/community/ceph/fix-seek-data-hole.patch
blob: 56bc790fd36e99635d5e8521cfb8810ebf7852f0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
diff -Nurp a/src/client/Client.cc b/src/client/Client.cc
--- a/src/client/Client.cc	2021-03-31 11:30:56.249817026 +0100
+++ b/src/client/Client.cc	2021-03-31 11:35:17.928535423 +0100
@@ -8987,8 +8987,27 @@ loff_t Client::_lseek(Fh *f, loff_t offs
 {
   Inode *in = f->inode.get();
   loff_t pos = -1;
+  bool whence_check = false;
 
-  if (whence == SEEK_END || whence == SEEK_DATA || whence == SEEK_HOLE) {
+  switch (whence) {
+  case SEEK_END:
+    whence_check = true;
+  break;
+
+#ifdef SEEK_DATA
+  case SEEK_DATA:
+    whence_check = true;
+  break;
+#endif
+
+#ifdef SEEK_HOLE
+  case SEEK_HOLE:
+    whence_check = true;
+  break;
+#endif
+  }
+
+  if (whence_check) {
     int r = _getattr(in, CEPH_STAT_CAP_SIZE, f->actor_perms);
     if (r < 0)
       return r;
@@ -9007,17 +9026,21 @@ loff_t Client::_lseek(Fh *f, loff_t offs
     pos = in->size + offset;
     break;
 
+#ifdef SEEK_DATA
   case SEEK_DATA:
     if (offset < 0 || offset >= in->size)
       return -ENXIO;
     pos = offset;
     break;
+#endif
 
+#ifdef SEEK_HOLE
   case SEEK_HOLE:
     if (offset < 0 || offset >= in->size)
       return -ENXIO;
     pos = in->size;
     break;
+#endif
 
   default:
     ldout(cct, 1) << __func__ << ": invalid whence value " << whence << dendl;