xfs_btree.c (71912e08e06b7041ba3b40945328b84798dfe6fc) | xfs_btree.c (e7ee96dfb8c2687a29d2c5c3b06c967fa54b839c) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. 4 * All Rights Reserved. 5 */ 6#include "xfs.h" 7#include "xfs_fs.h" 8#include "xfs_shared.h" --- 4584 unchanged lines hidden (view full) --- 4593 /* Stop if high_key < low_key(rec). */ 4594 cur->bc_ops->init_key_from_rec(&rec_key, recp); 4595 diff = cur->bc_ops->diff_two_keys(cur, &rec_key, high_key); 4596 if (diff > 0) 4597 break; 4598 4599 /* Callback */ 4600 error = fn(cur, recp, priv); | 1// SPDX-License-Identifier: GPL-2.0 2/* 3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. 4 * All Rights Reserved. 5 */ 6#include "xfs.h" 7#include "xfs_fs.h" 8#include "xfs_shared.h" --- 4584 unchanged lines hidden (view full) --- 4593 /* Stop if high_key < low_key(rec). */ 4594 cur->bc_ops->init_key_from_rec(&rec_key, recp); 4595 diff = cur->bc_ops->diff_two_keys(cur, &rec_key, high_key); 4596 if (diff > 0) 4597 break; 4598 4599 /* Callback */ 4600 error = fn(cur, recp, priv); |
4601 if (error < 0 || error == XFS_BTREE_QUERY_RANGE_ABORT) | 4601 if (error) |
4602 break; 4603 4604advloop: 4605 /* Move on to the next record. */ 4606 error = xfs_btree_increment(cur, 0, &stat); 4607 if (error) 4608 break; 4609 } --- 85 unchanged lines hidden (view full) --- 4695 4696 /* 4697 * If (record's high key >= query's low key) and 4698 * (query's high key >= record's low key), then 4699 * this record overlaps the query range; callback. 4700 */ 4701 if (ldiff >= 0 && hdiff >= 0) { 4702 error = fn(cur, recp, priv); | 4602 break; 4603 4604advloop: 4605 /* Move on to the next record. */ 4606 error = xfs_btree_increment(cur, 0, &stat); 4607 if (error) 4608 break; 4609 } --- 85 unchanged lines hidden (view full) --- 4695 4696 /* 4697 * If (record's high key >= query's low key) and 4698 * (query's high key >= record's low key), then 4699 * this record overlaps the query range; callback. 4700 */ 4701 if (ldiff >= 0 && hdiff >= 0) { 4702 error = fn(cur, recp, priv); |
4703 if (error < 0 || 4704 error == XFS_BTREE_QUERY_RANGE_ABORT) | 4703 if (error) |
4705 break; 4706 } else if (hdiff < 0) { 4707 /* Record is larger than high key; pop. */ 4708 goto pop_up; 4709 } 4710 cur->bc_ptrs[level]++; 4711 continue; 4712 } --- 54 unchanged lines hidden (view full) --- 4767 4768 return error; 4769} 4770 4771/* 4772 * Query a btree for all records overlapping a given interval of keys. The 4773 * supplied function will be called with each record found; return one of the 4774 * XFS_BTREE_QUERY_RANGE_{CONTINUE,ABORT} values or the usual negative error | 4704 break; 4705 } else if (hdiff < 0) { 4706 /* Record is larger than high key; pop. */ 4707 goto pop_up; 4708 } 4709 cur->bc_ptrs[level]++; 4710 continue; 4711 } --- 54 unchanged lines hidden (view full) --- 4766 4767 return error; 4768} 4769 4770/* 4771 * Query a btree for all records overlapping a given interval of keys. The 4772 * supplied function will be called with each record found; return one of the 4773 * XFS_BTREE_QUERY_RANGE_{CONTINUE,ABORT} values or the usual negative error |
4775 * code. This function returns XFS_BTREE_QUERY_RANGE_ABORT, zero, or a 4776 * negative error code. | 4774 * code. This function returns -ECANCELED, zero, or a negative error code. |
4777 */ 4778int 4779xfs_btree_query_range( 4780 struct xfs_btree_cur *cur, 4781 union xfs_btree_irec *low_rec, 4782 union xfs_btree_irec *high_rec, 4783 xfs_btree_query_range_fn fn, 4784 void *priv) --- 99 unchanged lines hidden (view full) --- 4884 4885/* If there's an extent, we're done. */ 4886STATIC int 4887xfs_btree_has_record_helper( 4888 struct xfs_btree_cur *cur, 4889 union xfs_btree_rec *rec, 4890 void *priv) 4891{ | 4775 */ 4776int 4777xfs_btree_query_range( 4778 struct xfs_btree_cur *cur, 4779 union xfs_btree_irec *low_rec, 4780 union xfs_btree_irec *high_rec, 4781 xfs_btree_query_range_fn fn, 4782 void *priv) --- 99 unchanged lines hidden (view full) --- 4882 4883/* If there's an extent, we're done. */ 4884STATIC int 4885xfs_btree_has_record_helper( 4886 struct xfs_btree_cur *cur, 4887 union xfs_btree_rec *rec, 4888 void *priv) 4889{ |
4892 return XFS_BTREE_QUERY_RANGE_ABORT; | 4890 return -ECANCELED; |
4893} 4894 4895/* Is there a record covering a given range of keys? */ 4896int 4897xfs_btree_has_record( 4898 struct xfs_btree_cur *cur, 4899 union xfs_btree_irec *low, 4900 union xfs_btree_irec *high, 4901 bool *exists) 4902{ 4903 int error; 4904 4905 error = xfs_btree_query_range(cur, low, high, 4906 &xfs_btree_has_record_helper, NULL); | 4891} 4892 4893/* Is there a record covering a given range of keys? */ 4894int 4895xfs_btree_has_record( 4896 struct xfs_btree_cur *cur, 4897 union xfs_btree_irec *low, 4898 union xfs_btree_irec *high, 4899 bool *exists) 4900{ 4901 int error; 4902 4903 error = xfs_btree_query_range(cur, low, high, 4904 &xfs_btree_has_record_helper, NULL); |
4907 if (error == XFS_BTREE_QUERY_RANGE_ABORT) { | 4905 if (error == -ECANCELED) { |
4908 *exists = true; 4909 return 0; 4910 } 4911 *exists = false; 4912 return error; 4913} 4914 4915/* Are there more records in this btree? */ --- 19 unchanged lines hidden --- | 4906 *exists = true; 4907 return 0; 4908 } 4909 *exists = false; 4910 return error; 4911} 4912 4913/* Are there more records in this btree? */ --- 19 unchanged lines hidden --- |