forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/block/drbd/drbd_int.h
....@@ -1,3 +1,4 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 /*
23 drbd_int.h
34
....@@ -7,19 +8,6 @@
78 Copyright (C) 1999-2008, Philipp Reisner <philipp.reisner@linbit.com>.
89 Copyright (C) 2002-2008, Lars Ellenberg <lars.ellenberg@linbit.com>.
910
10
- drbd is free software; you can redistribute it and/or modify
11
- it under the terms of the GNU General Public License as published by
12
- the Free Software Foundation; either version 2, or (at your option)
13
- any later version.
14
-
15
- drbd is distributed in the hope that it will be useful,
16
- but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- GNU General Public License for more details.
19
-
20
- You should have received a copy of the GNU General Public License
21
- along with drbd; see the file COPYING. If not, write to
22
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
2311
2412 */
2513
....@@ -429,8 +417,12 @@
429417 __EE_CALL_AL_COMPLETE_IO,
430418 __EE_MAY_SET_IN_SYNC,
431419
432
- /* is this a TRIM aka REQ_DISCARD? */
433
- __EE_IS_TRIM,
420
+ /* is this a TRIM aka REQ_OP_DISCARD? */
421
+ __EE_TRIM,
422
+ /* explicit zero-out requested, or
423
+ * our lower level cannot handle trim,
424
+ * and we want to fall back to zeroout instead */
425
+ __EE_ZEROOUT,
434426
435427 /* In case a barrier failed,
436428 * we need to resubmit without the barrier flag. */
....@@ -472,7 +464,8 @@
472464 };
473465 #define EE_CALL_AL_COMPLETE_IO (1<<__EE_CALL_AL_COMPLETE_IO)
474466 #define EE_MAY_SET_IN_SYNC (1<<__EE_MAY_SET_IN_SYNC)
475
-#define EE_IS_TRIM (1<<__EE_IS_TRIM)
467
+#define EE_TRIM (1<<__EE_TRIM)
468
+#define EE_ZEROOUT (1<<__EE_ZEROOUT)
476469 #define EE_RESUBMITTED (1<<__EE_RESUBMITTED)
477470 #define EE_WAS_ERROR (1<<__EE_WAS_ERROR)
478471 #define EE_HAS_DIGEST (1<<__EE_HAS_DIGEST)
....@@ -627,9 +620,9 @@
627620 unsigned int head_index;
628621 unsigned int size;
629622 int total; /* sum of all values */
630
- int values[0];
623
+ int values[];
631624 };
632
-extern struct fifo_buffer *fifo_alloc(int fifo_size);
625
+extern struct fifo_buffer *fifo_alloc(unsigned int fifo_size);
633626
634627 /* flag bits per connection */
635628 enum {
....@@ -724,10 +717,10 @@
724717 struct list_head transfer_log; /* all requests not yet fully processed */
725718
726719 struct crypto_shash *cram_hmac_tfm;
727
- struct crypto_ahash *integrity_tfm; /* checksums we compute, updates protected by connection->data->mutex */
728
- struct crypto_ahash *peer_integrity_tfm; /* checksums we verify, only accessed from receiver thread */
729
- struct crypto_ahash *csums_tfm;
730
- struct crypto_ahash *verify_tfm;
720
+ struct crypto_shash *integrity_tfm; /* checksums we compute, updates protected by connection->data->mutex */
721
+ struct crypto_shash *peer_integrity_tfm; /* checksums we verify, only accessed from receiver thread */
722
+ struct crypto_shash *csums_tfm;
723
+ struct crypto_shash *verify_tfm;
731724 void *int_dig_in;
732725 void *int_dig_vv;
733726
....@@ -848,7 +841,6 @@
848841
849842 sector_t p_size; /* partner's disk size */
850843 struct request_queue *rq_queue;
851
- struct block_device *this_bdev;
852844 struct gendisk *vdisk;
853845
854846 unsigned long last_reattach_jif;
....@@ -1312,10 +1304,6 @@
13121304
13131305 #define DRBD_MAX_SECTORS_FIXED_BM \
13141306 ((MD_128MB_SECT - MD_32kB_SECT - MD_4kB_SECT) * (1LL<<(BM_EXT_SHIFT-9)))
1315
-#if !defined(CONFIG_LBDAF) && BITS_PER_LONG == 32
1316
-#define DRBD_MAX_SECTORS DRBD_MAX_SECTORS_32
1317
-#define DRBD_MAX_SECTORS_FLEX DRBD_MAX_SECTORS_32
1318
-#else
13191307 #define DRBD_MAX_SECTORS DRBD_MAX_SECTORS_FIXED_BM
13201308 /* 16 TB in units of sectors */
13211309 #if BITS_PER_LONG == 32
....@@ -1327,7 +1315,6 @@
13271315 /* we allow up to 1 PiB now on 64bit architecture with "flexible" meta data */
13281316 #define DRBD_MAX_SECTORS_FLEX (1UL << 51)
13291317 /* corresponds to (1UL << 38) bits right now. */
1330
-#endif
13311318 #endif
13321319
13331320 /* Estimate max bio size as 256 * PAGE_SIZE,
....@@ -1463,7 +1450,7 @@
14631450 /* drbd_req */
14641451 extern void do_submit(struct work_struct *ws);
14651452 extern void __drbd_make_request(struct drbd_device *, struct bio *, unsigned long);
1466
-extern blk_qc_t drbd_make_request(struct request_queue *q, struct bio *bio);
1453
+extern blk_qc_t drbd_submit_bio(struct bio *bio);
14671454 extern int drbd_read_remote(struct drbd_device *device, struct drbd_request *req);
14681455 extern int is_valid_ar_handle(struct drbd_request *, sector_t);
14691456
....@@ -1531,8 +1518,9 @@
15311518 }
15321519
15331520
1534
-extern void drbd_csum_bio(struct crypto_ahash *, struct bio *, void *);
1535
-extern void drbd_csum_ee(struct crypto_ahash *, struct drbd_peer_request *, void *);
1521
+extern void drbd_csum_bio(struct crypto_shash *, struct bio *, void *);
1522
+extern void drbd_csum_ee(struct crypto_shash *, struct drbd_peer_request *,
1523
+ void *);
15361524 /* worker callbacks */
15371525 extern int w_e_end_data_req(struct drbd_work *, int);
15381526 extern int w_e_end_rsdata_req(struct drbd_work *, int);
....@@ -1555,6 +1543,8 @@
15551543 extern void drbd_endio_write_sec_final(struct drbd_peer_request *peer_req);
15561544
15571545 /* drbd_receiver.c */
1546
+extern int drbd_issue_discard_or_zero_out(struct drbd_device *device,
1547
+ sector_t start, unsigned int nr_sectors, int flags);
15581548 extern int drbd_receiver(struct drbd_thread *thi);
15591549 extern int drbd_ack_receiver(struct drbd_thread *thi);
15601550 extern void drbd_send_ping_wf(struct work_struct *ws);
....@@ -1579,52 +1569,18 @@
15791569 extern void _drbd_clear_done_ee(struct drbd_device *device, struct list_head *to_be_freed);
15801570 extern int drbd_connected(struct drbd_peer_device *);
15811571
1582
-static inline void drbd_tcp_cork(struct socket *sock)
1583
-{
1584
- int val = 1;
1585
- (void) kernel_setsockopt(sock, SOL_TCP, TCP_CORK,
1586
- (char*)&val, sizeof(val));
1587
-}
1588
-
1589
-static inline void drbd_tcp_uncork(struct socket *sock)
1590
-{
1591
- int val = 0;
1592
- (void) kernel_setsockopt(sock, SOL_TCP, TCP_CORK,
1593
- (char*)&val, sizeof(val));
1594
-}
1595
-
1596
-static inline void drbd_tcp_nodelay(struct socket *sock)
1597
-{
1598
- int val = 1;
1599
- (void) kernel_setsockopt(sock, SOL_TCP, TCP_NODELAY,
1600
- (char*)&val, sizeof(val));
1601
-}
1602
-
1603
-static inline void drbd_tcp_quickack(struct socket *sock)
1604
-{
1605
- int val = 2;
1606
- (void) kernel_setsockopt(sock, SOL_TCP, TCP_QUICKACK,
1607
- (char*)&val, sizeof(val));
1608
-}
1609
-
16101572 /* sets the number of 512 byte sectors of our virtual device */
1611
-static inline void drbd_set_my_capacity(struct drbd_device *device,
1612
- sector_t size)
1613
-{
1614
- /* set_capacity(device->this_bdev->bd_disk, size); */
1615
- set_capacity(device->vdisk, size);
1616
- device->this_bdev->bd_inode->i_size = (loff_t)size << 9;
1617
-}
1573
+void drbd_set_my_capacity(struct drbd_device *device, sector_t size);
16181574
16191575 /*
16201576 * used to submit our private bio
16211577 */
1622
-static inline void drbd_generic_make_request(struct drbd_device *device,
1578
+static inline void drbd_submit_bio_noacct(struct drbd_device *device,
16231579 int fault_type, struct bio *bio)
16241580 {
16251581 __release(local);
16261582 if (!bio->bi_disk) {
1627
- drbd_err(device, "drbd_generic_make_request: bio->bi_disk == NULL\n");
1583
+ drbd_err(device, "drbd_submit_bio_noacct: bio->bi_disk == NULL\n");
16281584 bio->bi_status = BLK_STS_IOERR;
16291585 bio_endio(bio);
16301586 return;
....@@ -1633,7 +1589,7 @@
16331589 if (drbd_insert_fault(device, fault_type))
16341590 bio_io_error(bio);
16351591 else
1636
- generic_make_request(bio);
1592
+ submit_bio_noacct(bio);
16371593 }
16381594
16391595 void drbd_bump_write_ordering(struct drbd_resource *resource, struct drbd_backing_dev *bdev,
....@@ -1688,22 +1644,22 @@
16881644 };
16891645 void drbd_bcast_event(struct drbd_device *device, const struct sib_info *sib);
16901646
1691
-extern void notify_resource_state(struct sk_buff *,
1647
+extern int notify_resource_state(struct sk_buff *,
16921648 unsigned int,
16931649 struct drbd_resource *,
16941650 struct resource_info *,
16951651 enum drbd_notification_type);
1696
-extern void notify_device_state(struct sk_buff *,
1652
+extern int notify_device_state(struct sk_buff *,
16971653 unsigned int,
16981654 struct drbd_device *,
16991655 struct device_info *,
17001656 enum drbd_notification_type);
1701
-extern void notify_connection_state(struct sk_buff *,
1657
+extern int notify_connection_state(struct sk_buff *,
17021658 unsigned int,
17031659 struct drbd_connection *,
17041660 struct connection_info *,
17051661 enum drbd_notification_type);
1706
-extern void notify_peer_device_state(struct sk_buff *,
1662
+extern int notify_peer_device_state(struct sk_buff *,
17071663 unsigned int,
17081664 struct drbd_peer_device *,
17091665 struct peer_device_info *,
....@@ -1776,7 +1732,7 @@
17761732 _drbd_set_state(_NS(device, disk, D_INCONSISTENT), CS_HARD, NULL);
17771733 break;
17781734 }
1779
- /* NOTE fall through for DRBD_META_IO_ERROR or DRBD_FORCE_DETACH */
1735
+ fallthrough; /* for DRBD_META_IO_ERROR or DRBD_FORCE_DETACH */
17801736 case EP_DETACH:
17811737 case EP_CALL_HELPER:
17821738 /* Remember whether we saw a READ or WRITE error.
....@@ -1975,7 +1931,7 @@
19751931 {
19761932 struct task_struct *task = connection->ack_receiver.task;
19771933 if (task && get_t_state(&connection->ack_receiver) == RUNNING)
1978
- force_sig(SIGXCPU, task);
1934
+ send_sig(SIGXCPU, task, 1);
19791935 }
19801936
19811937 static inline void request_ping(struct drbd_connection *connection)